Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext register

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext register

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext register.

Prototype

public void register(Class<?>... annotatedClasses) 

Source Link

Document

Register one or more annotated classes to be processed.

Usage

From source file:com.mycompany.spring.propertysource.views.NewMain.java

/**
 * @param args the command line arguments
 *//* w w w . java 2s. co  m*/
public static void main(String[] args) {
    // TODO code application logic here
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(AppConfig.class);
    ctx.refresh();
}

From source file:prospring3.ch6.Ch6Main.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(Ch6Config.class);
    ctx.refresh();// www.  j ava  2  s  .c  om

    final TwitterServiceClient twitterService = ctx.getBean(TwitterServiceClient.class);
    twitterService.deassociateAll();

    System.out.println("Finish");
}

From source file:com.mycompany.swing2explore.views.NewMain.java

/**
 * @param args the command line arguments
 *//*from   w  ww  .  j  a  va 2s  .co m*/
public static void main(String[] args) {
    //ctx = new AnnotationConfigApplicationContext(PersistenceJPAConfig.class);
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(PersistenceJPAConfig.class);
    //ctx.scan("com.mycompany.swing2explore");
    ctx.refresh();
    System.out.println("main is ok");
    // TODO code application logic here
    PersonView personView = ctx.getBean("personViewController", PersonView.class);
    personView.personView();
    personView.pesan("ini adalah pesan untuk service");
}

From source file:org.sansdemeure.zenindex.main.Main.java

public static void main(String[] args) {

    Instant start = Instant.now();

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(ServiceConfig.class);
    ctx.refresh();/*from  w ww  . ja v a 2s. c  o m*/

    BatchService batch = (BatchService) ctx.getBean("batchService");
    batch.start(new File(args[0]));

    ctx.close();

    Instant end = Instant.now();
    logger.info("Duration of batch {}", Duration.between(start, end));

}

From source file:io.gravitee.gateway.platforms.jetty.bootstrap.Bootstrap.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    t.setName("graviteeio-gateway");

    final AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(JettyConfiguration.class);
    ctx.registerShutdownHook();//from   ww w  .  ja  va 2 s . c  om
    ctx.refresh();

    try {
        final Node node = ctx.getBean(Node.class);
        node.start();

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                LoggerFactory.getLogger(Bootstrap.class).info("Shutting-down Gravitee Gateway...");
                node.stop();
                ctx.close();
            }
        });
    } catch (Exception ex) {
        LOGGER.error("Unable to start Gravitee Gateway", ex);
    }
}

From source file:eu.trentorise.game.Application.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(AppConfig.class);
    ctx.register(MongoConfig.class);
    ctx.refresh();/*  w w w. j  a  v  a  2  s  .  com*/
    Workflow gameWorkflow = ctx.getBean("workflow", Workflow.class);

    /**
     * input map known fields
     * 
     * bikeDistance walkDistance busDistance trainDistance carDistance ->
     * double , distances must be expressed in km
     * 
     * bikeSharing -> boolean
     * 
     * park -> park id
     * 
     * sustainable -> boolean
     * 
     * p+r -> boolean
     * 
     * 
     * 
     */

    Map<String, Object> data = new HashMap<String, Object>();
    // data.put("bikeDistance", 8.43);
    // data.put("walkDistance", 3.100);
    // data.put("carDistance", 0.00);
    // data.put("busDistance", 0.00);
    // data.put("bikesharing", true);
    // data.put("sustainable", true);
    // data.put("p+r", true);
    // data.put("park", "MANIFATTURA");
    gameWorkflow.apply("demo-game", "save_itinerary", "1", data, null);
}

From source file:piecework.client.LoadTester.java

public static final void main(String[] args) throws Exception {
    String profile = args.length > 0 ? args[0] : "workstation";

    StandardEnvironment environment = new StandardEnvironment();
    environment.setActiveProfiles(profile);
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.setEnvironment(environment);/* w w  w.  j  a va 2 s.  c o  m*/
    ctx.register(ClientConfiguration.class);
    ctx.refresh();

    KeyManagerCabinet cabinet = ctx.getBean(KeyManagerCabinet.class);
    SecuritySettings securitySettings = ctx.getBean(SecuritySettings.class);

    LoadTester loadTester = new LoadTester(cabinet.getKeystore(), securitySettings);
    loadTester.retrieveAllTasks();
}

From source file:lab.example.service.LotteryService.java

public static void main(String[] args) throws Exception {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(LotteryService.class);

    SpringApplication application = new SpringApplication(LotteryService.class);

    application.setApplicationContextClass(AnnotationConfigApplicationContext.class);
    SpringApplication.run(LotteryService.class, args);
}

From source file:lab.example.service.MessageListener.java

public static void main(String[] args) throws Exception {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(MessageListener.class);

    SpringApplication application = new SpringApplication(MessageListener.class);

    application.setApplicationContextClass(AnnotationConfigApplicationContext.class);
    SpringApplication.run(MessageListener.class, args);
}

From source file:org.schemaspy.Main.java

public static void main(String[] argv) throws Exception {
    Logger logger = Logger.getLogger(Main.class.getName());

    final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(
            "org.schemaspy.service");
    applicationContext.register(SchemaAnalyzer.class);

    if (argv.length == 1 && "-gui".equals(argv[0])) { // warning: serious temp hack
        new MainFrame().setVisible(true);
        return;/*from w w w  . j  a  v  a2 s .  c  o m*/
    }

    SchemaAnalyzer analyzer = applicationContext.getBean(SchemaAnalyzer.class);

    int rc = 1;

    try {
        rc = analyzer.analyze(new Config(argv)) == null ? 1 : 0;
    } catch (ConnectionFailure couldntConnect) {
        logger.log(Level.WARNING, "Connection Failure", couldntConnect);
        rc = 3;
    } catch (EmptySchemaException noData) {
        logger.log(Level.WARNING, "Empty schema", noData);
        rc = 2;
    } catch (InvalidConfigurationException badConfig) {
        logger.info("");
        if (badConfig.getParamName() != null)
            logger.log(Level.WARNING, "Bad parameter specified for " + badConfig.getParamName());
        logger.log(Level.WARNING, "Bad config " + badConfig.getMessage());
        if (badConfig.getCause() != null && !badConfig.getMessage().endsWith(badConfig.getMessage()))
            logger.log(Level.WARNING, " caused by " + badConfig.getCause().getMessage());

        logger.log(Level.FINE, "Command line parameters: " + Arrays.asList(argv));
        logger.log(Level.FINE, "Invalid configuration detected", badConfig);
    } catch (ProcessExecutionException badLaunch) {
        logger.log(Level.WARNING, badLaunch.getMessage(), badLaunch);
    } catch (Exception exc) {
        logger.log(Level.SEVERE, exc.getMessage(), exc);
    }

    System.exit(rc);
}