List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:au.org.ala.layers.client.Client.java
public static void main(String[] args) { System.out.println("Layers Store CLI client"); ApplicationContext context = new ClassPathXmlApplicationContext("spring/app-config.xml"); LayerDAO layerDao = (LayerDAO) context.getBean("layerDao"); List<Layer> layers = layerDao.getLayers(); System.out.println("Got " + layers.size() + " layers"); Iterator<Layer> it = layers.iterator(); while (it.hasNext()) { Layer l = it.next();/*from ww w. ja v a 2 s. c o m*/ System.out.println(" > " + l.getName()); } }
From source file:com.dangdang.ddframe.rdb.sharding.example.config.spring.SpringNamespaceWithAssignedDataSourceMain.java
public static void main(final String[] args) throws SQLException { // CHECKSTYLE:ON ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "META-INF/applicationContextWithAssignedDataSource.xml"); OrderService service = applicationContext.getBean(OrderService.class); service.insert();/* ww w . ja v a 2s. co m*/ service.select(); service.delete(); service.select(); ConfigService configService = applicationContext.getBean(ConfigService.class); configService.select(); }
From source file:koper.demo.main.KafkaReceiverDemo.java
public static void main(String[] args) { final ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:kafka/context-data-consumer.xml"); final ConsumerLauncher consumerLauncher = context.getBean(ConsumerLauncher.class); // we have close the switch in context-data-consumer.xml profile(autoStart) temporary consumerLauncher.start();// w w w .j a v a 2 s. c o m logger.info("KafkaReceiverDemo started!"); }
From source file:org.easyrules.samples.spring.Launcher.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext( "org/easyrules/samples/spring/application-context.xml"); RulesEngine rulesEngine = (RulesEngine) context.getBean("rulesEngine"); AnotherDummyRule rule = context.getBean(AnotherDummyRule.class); rulesEngine.registerRule(rule);//from w w w . java 2s . c o m rulesEngine.fireRules(); }
From source file:com.stormpath.shiro.spring.boot.examples.App.java
public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(App.class, args); //You can interact with your application's record in Stormpath: Application myApp = ctx.getBean(Application.class); System.out.println("\n"); System.out.println("Welcome to the '" + myApp.getName() + "' application!"); //You can also obtain the Stormpath Client to interact with your tenant too: Client stormpathClient = ctx.getBean(Client.class); System.out.println("My tenant info: " + stormpathClient.getCurrentTenant()); System.out.println("\n"); SecurityManager securityManager = ctx.getBean(SecurityManager.class); System.out.println("My securityManager: " + securityManager.toString()); System.out.println("\n"); System.out.println(ctx.getBean(Realm.class)); }
From source file:org.tdmx.server.runtime.ServerLauncher.java
public static void main(String[] args) { String javaVersion = System.getProperty("java.version"); StringTokenizer tokens = new StringTokenizer(javaVersion, ".-_"); int majorVersion = Integer.parseInt(tokens.nextToken()); int minorVersion = Integer.parseInt(tokens.nextToken()); if (majorVersion < 2 && minorVersion < 7) { log.error("TDMX-Server requires Java 7 or later."); log.error("Your java version is " + javaVersion); log.error("Java Home: " + System.getProperty("java.home")); System.exit(-1);/* w w w . j av a 2 s. c o m*/ } // Construct the SpringApplication BeanFactoryLocator beanFactoryLocator = ContextSingletonBeanFactoryLocator.getInstance(); BeanFactoryReference beanFactoryReference = beanFactoryLocator.useBeanFactory("applicationContext"); ApplicationContext context = (ApplicationContext) beanFactoryReference.getFactory(); SslServerSocketInfo si = (SslServerSocketInfo) context.getBean("server.sslInfo"); log.info("JVM supportedCipherSuites: " + StringUtils.arrayToCommaDelimitedString(si.getSupportedCipherSuites())); log.info("JVM supportedProtocols: " + StringUtils.arrayToCommaDelimitedString(si.getSupportedProtocols())); log.info("default TrustManagerFactoryAlgorithm: " + si.getDefaultTrustManagerFactoryAlgorithm()); // Start the Jetty ServerContainer sc = (ServerContainer) context.getBean("server.Container"); sc.runUntilStopped(); }
From source file:com.vmware.example.lucene.loader.CacheBatchLoader.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("cacheloading-app-context.xml"); CacheBatchLoader batchLoader = context.getBean(CacheBatchLoader.class); batchLoader.start();//from www. j av a 2 s .c o m }
From source file:com.greglturnquist.embeddablesdr.Application.java
public static void main(String[] args) { ApplicationContext ctx = SpringApplication.run(Application.class, args); SystemRepository repository = ctx.getBean(SystemRepository.class); System system1 = new System(); system1.setName("router101"); system1 = repository.save(system1);//from w ww.jav a 2 s .com System system2 = new System(); system2.setName("switch405"); system2 = repository.save(system2); SystemDependency dep1 = new SystemDependency(); dep1.setDescription("WLAN"); dep1.setTarget(system1); SystemDependency dep2 = new SystemDependency(); dep2.setDescription("UPS"); dep2.setTarget(system1); ArrayList<SystemDependency> dependencies1 = new ArrayList<>(); dependencies1.add(dep1); dependencies1.add(dep2); system1.setDependencies(dependencies1); system1 = repository.save(system1); SystemDependency dep3 = new SystemDependency(); dep3.setDescription("MUX"); dep3.setTarget(system1); SystemDependency dep4 = new SystemDependency(); dep4.setDescription("Backup Battery"); dep4.setTarget(system2); ArrayList<SystemDependency> dependencies2 = new ArrayList<>(); dependencies2.add(dep3); dependencies2.add(dep4); system2.setDependencies(dependencies2); system2 = repository.save(system2); }
From source file:org.ala.hbase.InfosourceUidLoader.java
/** * Usage: outputFileName [option: cassandraAddress cassandraPort] * /*ww w . j a v a 2s . c o m*/ * @param args */ public static void main(String[] args) throws Exception { ApplicationContext context = SpringUtils.getContext(); InfosourceUidLoader loader = context.getBean(InfosourceUidLoader.class); try { loader.doFullScan(); } catch (Exception e) { System.out.println("***** Fatal Error !!!.... shutdown cassandra connection."); e.printStackTrace(); logger.error(e); System.exit(0); } System.exit(0); }
From source file:com.acmemotors.Main.java
public static void main(String[] args) throws Exception { ApplicationContext context = SpringApplication.run(Main.class, args); OBD2Controller controller = context.getBean(OBD2Controller.class); System.out.println("The car's VIN: " + controller.getVin()); System.out.println(//from ww w. ja v a2s .c om "LONGITUDE,LATITUDE,RPM,SPEED(MPH),FUEL SYSTEM STATUS,ENGINE LOAD,COOLANT TEMP,SHORT TERM FUEL PERCENT,LONG TERM FUEL PERCENT,INTAKE PRESSURE,INTAKE AIR TEMP,MAF RATE,THROTTLE POSITION,OBD VERSION,RUNNING TIME(SECONDS),FUEL LEVEL,RELATIVE THROTTLE POSITION,ABSOLUTE THROTTLE POSITION B,ACCELERATOR POSITION D,ACCELERATOR POSITION E"); while (true) { controller.getCarState(); Thread.sleep(1000); } }