List of usage examples for org.springframework.context.support FileSystemXmlApplicationContext getBeanNamesForType
@Override
public String[] getBeanNamesForType(ResolvableType type)
From source file:org.apache.ftpserver.main.Daemon.java
/** * Get the configuration object.//from w w w . ja v a 2s .c om */ private static FtpServer getConfiguration(String[] args) throws Exception { FtpServer server = null; if (args == null || args.length < 2) { LOG.info("Using default configuration...."); server = new FtpServerFactory().createServer(); } else if ((args.length == 2) && args[1].equals("-default")) { // supported for backwards compatibility, but not documented System.out.println("The -default switch is deprecated, please use --default instead"); LOG.info("Using default configuration...."); server = new FtpServerFactory().createServer(); } else if ((args.length == 2) && args[1].equals("--default")) { LOG.info("Using default configuration...."); server = new FtpServerFactory().createServer(); } else if (args.length == 2) { LOG.info("Using xml configuration file " + args[1] + "..."); FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(args[1]); if (ctx.containsBean("server")) { server = (FtpServer) ctx.getBean("server"); } else { String[] beanNames = ctx.getBeanNamesForType(FtpServer.class); if (beanNames.length == 1) { server = (FtpServer) ctx.getBean(beanNames[0]); } else if (beanNames.length > 1) { System.out .println("Using the first server defined in the configuration, named " + beanNames[0]); server = (FtpServer) ctx.getBean(beanNames[0]); } else { System.err.println("XML configuration does not contain a server configuration"); } } } else { throw new FtpException("Invalid configuration option"); } return server; }
From source file:org.apache.smscserver.main.Daemon.java
/** * Get the configuration object.//from w w w . j ava 2s .c om */ private static SmscServer getConfiguration(String[] args) throws Exception { SmscServer server = null; if ((args == null) || (args.length < 2)) { Daemon.LOG.info("Using default configuration...."); server = new SmscServerFactory().createServer(); } else if ((args.length == 2) && args[1].equals("-default")) { // supported for backwards compatibility, but not documented System.out.println("The -default switch is deprecated, please use --default instead"); Daemon.LOG.info("Using default configuration...."); server = new SmscServerFactory().createServer(); } else if ((args.length == 2) && args[1].equals("--default")) { Daemon.LOG.info("Using default configuration...."); server = new SmscServerFactory().createServer(); } else if (args.length == 2) { Daemon.LOG.info("Using xml configuration file " + args[1] + "..."); FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(args[1]); if (ctx.containsBean("server")) { server = (SmscServer) ctx.getBean("server"); } else { String[] beanNames = ctx.getBeanNamesForType(SmscServer.class); if (beanNames.length == 1) { server = (SmscServer) ctx.getBean(beanNames[0]); } else if (beanNames.length > 1) { System.out .println("Using the first server defined in the configuration, named " + beanNames[0]); server = (SmscServer) ctx.getBean(beanNames[0]); } else { System.err.println("XML configuration does not contain a server configuration"); } } } else { throw new SmscException("Invalid configuration option"); } return server; }
From source file:com.snp.site.init.SystemInit.java
public static void initSystemStaitcData(ServletContextEvent sce) { try {//from w w w. j a v a 2s . c om // siteStrMap = getMapFromePropFile(getClassPath() + "/lang", // "txt"); // snpStrMap = getMapFromePropFile(getClassPath() + "/lang", "txt"); FtpServer ftpserver = null; String config = "conf/ftp/conf/ftpd-typical.xml"; FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(config); String[] beanNames = ctx.getBeanNamesForType(FtpServer.class); ftpserver = (FtpServer) ctx.getBean(beanNames[0]); ftpserver.start(); DefaultFtpServer defaultFtpServer = (DefaultFtpServer) ftpserver; System.out.println(defaultFtpServer); // PropertiesUserManager propertiesUserManager = // (PropertiesUserManager) defaultFtpServer.getUserManager(); SystemInit.serverFtp = defaultFtpServer; } catch (Exception e) { log.error("", e); } }
From source file:org.apache.smscserver.main.CommandLine.java
/** * Get the configuration object./*from ww w . jav a 2 s.co m*/ */ protected SmscServer getConfiguration(String[] args) throws Exception { SmscServer server = null; if (args.length == 0) { System.out.println("Using default configuration"); server = new SmscServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("-default")) { // supported for backwards compatibility, but not documented System.out.println("The -default switch is deprecated, please use --default instead"); System.out.println("Using default configuration"); server = new SmscServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("--default")) { System.out.println("Using default configuration"); server = new SmscServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("--help")) { this.usage(); } else if ((args.length == 1) && args[0].equals("-?")) { this.usage(); } else if (args.length == 1) { System.out.println("Using XML configuration file " + args[0] + "..."); FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(args[0]); if (ctx.containsBean("server")) { server = (SmscServer) ctx.getBean("server"); } else { String[] beanNames = ctx.getBeanNamesForType(SmscServer.class); if (beanNames.length == 1) { server = (SmscServer) ctx.getBean(beanNames[0]); } else if (beanNames.length > 1) { System.err .println("Using the first server defined in the configuration, named " + beanNames[0]); server = (SmscServer) ctx.getBean(beanNames[0]); } else { System.err.println("XML configuration does not contain a server configuration"); } } } else { this.usage(); } return server; }
From source file:org.apache.ftpserver.main.CommandLine.java
/** * Get the configuration object.// ww w .j a v a2s . c o m */ protected FtpServer getConfiguration(String[] args) throws Exception { FtpServer server = null; if (args.length == 0) { System.out.println("Using default configuration"); server = new FtpServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("-default")) { // supported for backwards compatibility, but not documented System.out.println("The -default switch is deprecated, please use --default instead"); System.out.println("Using default configuration"); server = new FtpServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("--default")) { System.out.println("Using default configuration"); server = new FtpServerFactory().createServer(); } else if ((args.length == 1) && args[0].equals("--help")) { usage(); } else if ((args.length == 1) && args[0].equals("-?")) { usage(); } else if (args.length == 1) { System.out.println("Using XML configuration file " + args[0] + "..."); FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(args[0]); if (ctx.containsBean("server")) { server = (FtpServer) ctx.getBean("server"); } else { String[] beanNames = ctx.getBeanNamesForType(FtpServer.class); if (beanNames.length == 1) { server = (FtpServer) ctx.getBean(beanNames[0]); } else if (beanNames.length > 1) { System.out .println("Using the first server defined in the configuration, named " + beanNames[0]); server = (FtpServer) ctx.getBean(beanNames[0]); } else { System.err.println("XML configuration does not contain a server configuration"); } } } else { usage(); } return server; }