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

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

Introduction

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

Prototype

@Override
    public Object getBean(String name) throws BeansException 

Source Link

Usage

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:com.weib.concert.ConcertMain.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConcertConfig.class);
    //        Director director = context.getBean(Director.class);
    //        director.perform();
    Performance concert = (Performance) context.getBean("concert"); //??Bean Qualifier
    concert.perform();/*from   w ww .  ja va  2s. c  o m*/

    Performance play = (Performance) context.getBean("play"); //??Bean 
    play.perform();

    /**
     * public class EncoreableIntroducer {
     *       @DeclareParents(value="com.weib.concert.beans.Performance+",   //??
     *               defaultImpl=PerformanceEncoreable.class)            //
     *       public static Encoreable encoreable;
     * }
     */
    Encoreable encoreablePlay = (Encoreable) play; //??(Performance??playproxy??)
    encoreablePlay.performEncore(); //

    context.close();

    AnnotationConfigApplicationContext cdContext = new AnnotationConfigApplicationContext(CDConfig.class);
    CDPlayer cdplayer = cdContext.getBean(CDPlayer.class);
    cdplayer.playAll();
    cdplayer.playShuffle();

    cdContext.close();
}

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

public static void main(String... args) throws Exception {

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);/*from   w w w  .j  a va2  s  . co  m*/
    }

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

    DiseaseParser diseaseParser = context.getBean(DiseaseParser.class);

    diseaseParser.parse(args[1]);

}

From source file:com.iluwatar.repository.AppConfig.java

/**
 * Program entry point//  w w  w.j  a v  a  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:uk.ac.ebi.ep.sitemap.main.SiteMapMain.java

public static void main(String... args) throws Exception {

    //////////////comment here ///////////////////////
    //        args = new String[4];
    //        //String dbConfig = "ep-mm-db-enzdev";
    //        //String dbConfig = "ep-mm-db-enzprel";
    //        String userHome = System.getProperty("user.home");
    //        String filename = "SiteMap";
    //        String testing = "true";
    //        //from w  w w .ja v a  2s.  c o m
    //               
    //        args[0] = "vezpdev";
    //        args[1] = userHome;
    //        args[2] = filename;
    //        args[3] = testing;
    //////////////uncomment for testing parameters only ///////////////////////          
    if (args == null) {
        System.out.println("Please provide required parameters");
        System.exit(0);
    }

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig");
    context.refresh();

    UniprotEntryService service = context.getBean(UniprotEntryService.class);

    SiteMapGenerator siteMapGenerator = new EnzymePortalSiteMap(service);
    boolean testMode = Boolean.parseBoolean(args[3]);
    siteMapGenerator.generateSitemap(args[1], args[2], testMode);

}

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

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);/*w  w w. ja  v  a 2  s.  c om*/
    }

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

    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);
    compoundService.loadCofactors();

}

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

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);/*from   www .ja  va  2  s . co  m*/
    }

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

    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);
    compoundService.loadChEBICompounds();

}

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

public static void main(String... args) throws Exception {
    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);//  w w w.  java  2  s.c  om
    }

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.getEnvironment().setActiveProfiles(args[0]);
    context.scan("uk.ac.ebi.ep.data.dataconfig", "uk.ac.ebi.ep.parser.config");
    context.refresh();
    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);

    compoundService.parseIntenzAndLoadCompoundsAndReactions(args[1]);

}

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

public static void main(String... args) throws Exception {

    if (args == null || args.length == 0) {
        System.out.println("Please provide required parameters");
        System.exit(0);//from   ww w. j  a  v a2s.co  m
    }

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

    EnzymePortalCompoundParser compoundService = context.getBean(EnzymePortalCompoundParser.class);
    compoundService.parseAndLoadChEMBLCompounds(args[1]);

}

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);//from   w ww  . j a va 2 s  .com
    }

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

}