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

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

Introduction

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

Prototype

@Override
    public void refresh() throws BeansException, IllegalStateException 

Source Link

Usage

From source file:com.mesut.springpropertyinjection.App.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.scan("com.mesut");
    context.refresh();

    Person person = context.getBean(Person.class);
    System.out.println("Sonuc: " + person);
    context.close();/*from   w ww  .j  av a2s  . com*/
}

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

/**
 * @param args the command line arguments
 *///from   w  w  w.  j a v  a 2  s. c  o  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();

    final TwitterServiceClient twitterService = ctx.getBean(TwitterServiceClient.class);
    twitterService.deassociateAll();//from w  ww.  j a  v  a  2  s.c  o m

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

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();

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

    ctx.close();//w w w  .j  a  v  a  2 s  .  c om

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

}

From source file:org.jmangos.auth.AuthServer.java

/**
 * The main method./*  ww w  .j a  v a  2  s  .co  m*/
 * 
 * @param args
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(final String[] args) throws Exception {

    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.scan("org.jmangos.commons", "org.jmangos.auth");
    context.refresh();
    ServiceContent.setContext(context);
    context.getBean(NetworkService.class).start();
}

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

/**
 * @param args the command line arguments
 *//*  www  .  j  ava2  s  .  c  o  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.jmangos.realm.RealmServer.java

/**
 * The main method./* w  w w. j a va 2s.  c o m*/
 * 
 * @param args
 *            the arguments
 */
public static void main(final String[] args) {

    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.scan("org.jmangos.commons", "org.jmangos.world", "org.jmangos.realm");
    context.refresh();
    ServiceContent.setContext(context);
    context.getBean(NetworkService.class).start();

    console.setVariable("applicationContext", context);
    console.setVariable("itemStorage", context.getBean(ItemStorages.class));
    // console.run();
}

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();// ww  w.  ja v a  2 s. c o m
    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();
    Workflow gameWorkflow = ctx.getBean("workflow", Workflow.class);

    /**//from   w w  w .  ja  va2 s.  com
     * 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  ava2  s .  c om
    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();
}