Examples of AnnotationConfigApplicationContext


Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    private static final Logger logger = LoggerFactory.getLogger(SpringObjectFactory.class);

    @Override
    public <T, U extends T> U newClassInstance(AtmosphereFramework framework, Class<T> classType, Class<U> classToInstantiate) throws InstantiationException, IllegalAccessException {
        ApplicationContext context =
            new AnnotationConfigApplicationContext(classToInstantiate);
        U t = context.getBean(classToInstantiate);
        if (t == null) {
            logger.info("Unable to find {}. Creating the object directly.", classToInstantiate.getName());
            return classToInstantiate.newInstance();
        }
        return t;
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

                                               Class<T> classType,
                                               Class<U> classToInstantiate)
            throws InstantiationException, IllegalAccessException {

        WebApplicationContext parent = WebApplicationContextUtils.getWebApplicationContext(framework.getServletContext());
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.setParent(parent);
        context.register(classToInstantiate);
        context.refresh();
        U t = context.getBean(classToInstantiate);

        if (framework.objectFactory().getClass().getName().equals("org.atmosphere.inject.InjectableObjectFactory")) {
            InjectableObjectFactory.class.cast(framework.objectFactory()).injectAtmosphereInternalObject(t, classToInstantiate, framework);
        }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

*/
public class CNoXML {

  public static void main(String[] args) throws Exception {
    ConfigurableApplicationContext ctx =
        new AnnotationConfigApplicationContext(CConfig.class);
    System.out.println(ctx.getBean(FooService.class).foo("foo"));
    ctx.close();
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    private ClientTracer clientTracer;

    @Override
    protected Application configure() {
        ApplicationContext context = new AnnotationConfigApplicationContext(JerseyTestSpringConfig.class);
        clientTracer = context.getBean(ClientTracer.class);
        return new JerseyTestConfig().property("contextConfig", context);
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

  AnnotationConfigApplicationContext context;

  @Before
  public void setUp() {
    this.context = new AnnotationConfigApplicationContext(TestConfig.class);
  }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

    public ApplicationContext loadContext(String... locations) {
        if (logger.isDebugEnabled()) {
            logger.debug("Creating a JavaConfigApplicationContext for {}", Arrays.asList(locations));
        }

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

        List<Class<?>> configClasses = new ArrayList<Class<?>>();
        List<String> basePackages = new ArrayList<String>();
        for (String location : locations) {
            // if the location refers to a class, use it. Otherwise assume it's a base package name
            try {
                final Class<?> aClass = this.getClass().getClassLoader().loadClass(location);
                configClasses.add(aClass);
            } catch (ClassNotFoundException e) {
                if (Package.getPackage(location) == null) {
                    throw new IllegalArgumentException(
                            String.format("A non-existent class or package name was specified: [%s]", location));
                }
                basePackages.add(location);
            }
        }

        logger.debug("Setting config classes to {}", configClasses);
        logger.debug("Setting base packages to {}", basePackages);

        for (Class<?> configClass : configClasses) {
            context.register(configClass);
        }
       
        for (String basePackage : basePackages) {
            context.scan(basePackage);
        }
       
        context.refresh();
       
        return context;
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

public class MongoDbSpringDslOperationsTest extends MongoDbOperationsTest {
   
    @Override
    protected CamelContext createCamelContext() throws Exception {
        applicationContext = new AnnotationConfigApplicationContext(MongoBasicOperationsConfiguration.class);
        CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
        return ctx;
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

        super.tearDown();
    }

    @Override
    protected CamelContext createCamelContext() throws Exception {
        applicationContext = new AnnotationConfigApplicationContext(EmbedMongoConfiguration.class);
        CamelContext ctx = SpringCamelContext.springCamelContext(applicationContext);
        PropertiesComponent pc = new PropertiesComponent("classpath:mongodb.test.properties");
        ctx.addComponent("properties", pc);
        return ctx;
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

   
    private AnnotationConfigApplicationContext context;
   
    @Before
    public void setUp() {
        context = new AnnotationConfigApplicationContext(TestCofig.class);
    }
View Full Code Here

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext

      init(xml);
    }
  }

  public AnnotationConfigApplicationContext createAnnotationConfigApplicationContext() {
    final AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    if (ArrayUtils.isNotEmpty(configurationClasses)) {
      for (final Class<?> c : configurationClasses) {
        ctx.register(c);
      }
    }
    if (ArrayUtils.isNotEmpty(configurationPackages)) {
      for (final Package p : configurationPackages) {
        ctx.scan(p.getName());
      }
    }

    ctx.refresh();
    ctx.registerShutdownHook();
    return ctx;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.