List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:playground.Application.java
public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground"); DispatcherHandler dispatcherHandler = new DispatcherHandler(); dispatcherHandler.setApplicationContext(context); HttpServer server = new ReactorHttpServer(); server.setPort(8080);// w ww. jav a2 s . co m server.setHandler(dispatcherHandler); server.afterPropertiesSet(); server.start(); CompletableFuture<Void> stop = new CompletableFuture<>(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { stop.complete(null); })); synchronized (stop) { stop.wait(); } }
From source file:ch.rasc.wampspring.demo.client.Subscriber.java
public static void main(String[] args) throws InterruptedException { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( Subscriber.class)) { if (!latch.await(3, TimeUnit.MINUTES)) { System.out.println("SOMETHING WENT WRONG"); }//w w w . j a v a 2 s . com System.out.println("THE END"); } }
From source file:org.github.aenygmatic.payroll.PayrollSystem.java
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( "org.github.aenygmatic.payroll"); PayrollSystem system = context.getBean(PayrollSystem.class); system.hireAndPayAll();/* w w w . j a v a2s .c o m*/ }
From source file:com.khartec.waltz.jobs.InvolvementHarness.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); DataSource dataSource = ctx.getBean(DataSource.class); InvolvementDao dao = ctx.getBean(InvolvementDao.class); InvolvementService service = ctx.getBean(InvolvementService.class); System.out.println("-- Waiting ..."); // Thread.sleep(5000); System.out.println("-- Starting ..."); // viaJdbc(dataSource); // viaJooqSql(dsl); // viaJooqOrig(dsl); // viaJooqJoins(dsl); // viaJooqSql(dsl); // viaDao(dao); // viaJdbc(dataSource); EntityIdSelectionOptions options = ImmutableEntityIdSelectionOptions.builder() .desiredKind(EntityKind.END_USER_APPLICATION) .entityReference(ImmutableEntityReference.builder().kind(EntityKind.PERSON).id(218).build()) .scope(HierarchyQueryScope.CHILDREN).build(); List<EndUserApplication> endUserApps = service.findAllEndUserApplicationsBySelector(options); System.out.println("got end user apps: " + endUserApps.size()); }
From source file:at.ac.tuwien.dsg.comot.m.adapter.Main.java
public static void main(String[] args) { Options options = createOptions();//from w w w .j ava 2 s. c o m try { CommandLineParser parser = new PosixParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("mh") && cmd.hasOption("ih") && cmd.hasOption("ip")) { Integer infoPort = null; try { infoPort = new Integer(cmd.getOptionValue("ip")); } catch (NumberFormatException e) { LOG.warn("infoPort must be a number"); showHelp(options); } AppContextAdapter.setBrokerHost(cmd.getOptionValue("mh")); AppContextAdapter.setInfoHost(cmd.getOptionValue("ih")); AppContextAdapter.setInfoPort(infoPort); context = new AnnotationConfigApplicationContext(AppContextAdapter.class); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (context != null) { context.close(); } } }); if (cmd.hasOption("m") || cmd.hasOption("r") || cmd.hasOption("s")) { Manager manager = context.getBean(EpsAdapterManager.class); String serviceId = getServiceInstanceId(); String participantId = context.getBean(InfoClient.class).getOsuInstanceByServiceId(serviceId) .getId(); if (cmd.hasOption("m")) { Monitoring processor = context.getBean(Monitoring.class); manager.start(participantId, processor); } else if (cmd.hasOption("r")) { Control processor = context.getBean(Control.class); manager.start(participantId, processor); } else if (cmd.hasOption("s")) { Deployment processor = context.getBean(Deployment.class); manager.start(participantId, processor); } } else { LOG.warn("No adapter type specified"); showHelp(options); } } else { LOG.warn("Required parameters were not specified."); showHelp(options); } } catch (Exception e) { LOG.error("{}", e); showHelp(options); } }
From source file:sample.ServerConfig.java
@SuppressWarnings("resource") public static void main(final String[] args) throws IOException { // <5> new AnnotationConfigApplicationContext(ServerConfig.class).registerShutdownHook(); }
From source file:cu.uci.uengine.amqp.SubmitsListener.java
public static final void main(String[] args) throws IOException { AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(Config.class); //TODO: @Lan refactorizar esto, sobre todo quitar la variable isDebuguin esttica y hacer un mecanismo ms prctico. if (args.length > 0) { isDebugging = Arrays.asList(args).contains("debug"); if (isDebugging) { log.info("DEBUGGING IS ENABLED!!"); }//from w w w . ja v a 2s . com } }
From source file:com.iluwatar.repository.AppConfig.java
/** * Program entry point//w w w. j ava 2s .c o m * * @param args * command line args */ public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); PersonRepository repository = context.getBean(PersonRepository.class); Person peter = new Person("Peter", "Sagan", 17); Person nasta = new Person("Nasta", "Kuzminova", 25); Person john = new Person("John", "lawrence", 35); Person terry = new Person("Terry", "Law", 36); // Add new Person records repository.save(peter); repository.save(nasta); repository.save(john); repository.save(terry); // Count Person records System.out.println("Count Person records: " + repository.count()); // Print all records List<Person> persons = (List<Person>) repository.findAll(); for (Person person : persons) { System.out.println(person); } // Update Person nasta.setName("Barbora"); nasta.setSurname("Spotakova"); repository.save(nasta); System.out.println("Find by id 2: " + repository.findOne(2L)); // Remove record from Person repository.delete(2L); // count records System.out.println("Count Person records: " + repository.count()); // find by name Person p = repository.findOne(new PersonSpecifications.NameEqualSpec("John")); System.out.println("Find by John is " + p); // find by age persons = repository.findAll(new PersonSpecifications.AgeBetweenSpec(20, 40)); System.out.println("Find Person with age between 20,40: "); for (Person person : persons) { System.out.println(person); } context.close(); }
From source file:com.malsolo.mongodb.humongous.main.Main.java
public static void main(String... args) { ApplicationContext context = new AnnotationConfigApplicationContext(Application.class); MongoOperations ops = context.getBean("mongoTemplate", MongoOperations.class); //Create article /*/*from ww w .j a v a 2 s . c o m*/ Article article = new Article(); article.setAuthorId(UUID.randomUUID()); article.setAuthor("Javier"); article.setDate(new Date()); article.setTitle("Ttulo"); //Inserts ops.insert(article); */ //Find one article Article article = ops.findOne(query(where("author").is("Javier")), Article.class); System.out.println(article); ArticleRepository articleRepository = context.getBean("articleRepository", ArticleRepository.class); article = articleRepository.findByAuthor("Javier"); System.out.println(article); Comment comment = new Comment(); comment.setAuthor("David el Gnomo"); comment.setDate(new Date()); comment.setText("Another comment"); ops.upsert(query(where("author").is("Javier")), new Update().push("comments", comment), Article.class); }
From source file:org.sonews.Application.java
/** * The main entrypoint./* w w w. j a v a 2 s. com*/ * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { System.out.println(VERSION); Thread.currentThread().setName("Mainthread"); // Command line arguments boolean async = false; boolean feed = false; // Enable feeding? boolean purger = false; // Enable message purging? int port = -1; for (int n = 0; n < args.length; n++) { switch (args[n]) { case "-async": { async = true; break; } case "-c": case "-config": { Config.inst().set(Config.LEVEL_CLI, Config.CONFIGFILE, args[++n]); System.out.println("Using config file " + args[n]); break; } case "-C": case "-context": { // FIXME: Additional context files n++; break; } case "-dumpjdbcdriver": { System.out.println("Available JDBC drivers:"); Enumeration<Driver> drvs = DriverManager.getDrivers(); while (drvs.hasMoreElements()) { System.out.println(drvs.nextElement()); } return; } case "-feed": { feed = true; break; } case "-h": case "-help": { printArguments(); return; } case "-p": { port = Integer.parseInt(args[++n]); break; } case "-plugin-storage": { System.out.println("Warning: -plugin-storage is not implemented!"); break; } case "-purger": { purger = true; break; } case "-v": case "-version": // Simply return as the version info is already printed above return; } } ApplicationContext context = new AnnotationConfigApplicationContext(Application.class); context = new FileSystemXmlApplicationContext(new String[] { "sonews.xml" }, context); // Enable storage backend StorageProvider sprov = context.getBean("storageProvider", StorageProvider.class); StorageManager.enableProvider(sprov); ChannelLineBuffers.allocateDirect(); // Add shutdown hook Runtime.getRuntime().addShutdownHook(new ShutdownHook()); // Start the listening daemon if (port <= 0) { port = Config.inst().get(Config.PORT, 119); } NNTPDaemon daemon = context.getBean(NNTPDaemon.class); daemon.setPort(port); daemon.start(); // Start Connections purger thread... Connections.getInstance().start(); // Start feeds if (feed) { FeedManager.startFeeding(); } if (purger) { Purger purgerDaemon = new Purger(); purgerDaemon.start(); } // Wait for main thread to exit (setDaemon(false)) daemon.join(); }