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

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

Introduction

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

Prototype

public AnnotationConfigApplicationContext() 

Source Link

Document

Create a new AnnotationConfigApplicationContext that needs to be populated through #register calls and then manually #refresh refreshed .

Usage

From source file:uk.ac.ebi.ep.parser.main.PDBeParser.java

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

    String profile = "";

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);/*  w w  w . j a  v a  2s  .  c  om*/
    }

    if (args.length == 1) {

        profile = args[0];

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles(profile);
        context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
        context.refresh();

        EnzymePortalPDBeParser pdbParser = context.getBean(EnzymePortalPDBeParser.class);

        pdbParser.updatePDBeData();
    }

}

From source file:uk.ac.ebi.ep.parser.main.PathwaysParser.java

public static void main(String args[]) throws Exception {
    String file = "";
    String profile = "";

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);/* w ww . j a  va  2s  .c  om*/
    }

    if (args.length == 2) {

        profile = args[0];
        file = args[1];

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.getEnvironment().setActiveProfiles(profile);
        //context.scan("uk.ac.ebi.ep.data.dataconfig");
        context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
        context.refresh();

        EnzymePortalPathwaysParser pathwaysParser = context.getBean(EnzymePortalPathwaysParser.class);

        pathwaysParser.parseReactomeFile(file);//Total time: 1:57:24.500s
    }

}

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

/**
 * @param args the command line arguments
 *//* w  w  w. ja v  a 2 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.cloudfoundry.workers.stocks.batch.Main.java

public static void main(String[] args) throws Throwable {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
    annotationConfigApplicationContext.getEnvironment().setActiveProfiles(isCloudFoundry() ? "cloud" : "local");
    annotationConfigApplicationContext.scan(BatchConfiguration.class.getPackage().getName());
    annotationConfigApplicationContext.refresh();
}

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();/*from   w  w  w .j  a va 2 s  .  c o m*/
    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:org.cloudfoundry.workers.stocks.integration.service.Main.java

public static void main(String args[]) throws Throwable {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
    annotationConfigApplicationContext.getEnvironment().setActiveProfiles(isCloudFoundry() ? "cloud" : "local");
    annotationConfigApplicationContext.scan(ServiceConfiguration.class.getPackage().getName());
    annotationConfigApplicationContext.refresh();

}

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 w  w  .j  av  a  2  s . c  om

    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();/*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:org.cloudfoundry.workers.stocks.integration.client.Main.java

public static void main(String args[]) throws Throwable {
    AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();
    annotationConfigApplicationContext.getEnvironment().setActiveProfiles(isCloudFoundry() ? "cloud" : "local");
    annotationConfigApplicationContext.scan(ClientConfiguration.class.getPackage().getName());
    annotationConfigApplicationContext.refresh();

    StockClientGateway clientGateway = annotationConfigApplicationContext.getBean(StockClientGateway.class);
    Logger log = Logger.getLogger(Main.class.getName());
    String symbol = "VMW";
    StockSymbolLookup lookup = clientGateway.lookup(symbol);
    log.info("client: retrieved stock information: " + ToStringBuilder.reflectionToString(lookup));

}

From source file:at.christophwurst.orm.consoleclient.TestClient.java

public static void main(String[] args) {
    try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
        context.register(AppConfig.class);
        context.refresh();/*  ww w .  j a v a 2 s.  c  om*/

        Client client = context.getBean(Client.class);
        System.out.println(client.getClass().getName());

        ProjectCommands prc = context.getBean(ProjectCommands.class);
        prc.registerCommands(client);
        StatisticsCommands stc = context.getBean(StatisticsCommands.class);
        stc.registerCommands(client);
        ScrumCommands scc = context.getBean(ScrumCommands.class);
        scc.registerCommands(client);
        EmployeeCommands emc = context.getBean(EmployeeCommands.class);
        emc.registerCommands(client);

        client.run();
    }
}