Examples of AutowireCapableBeanFactory


Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    public static ApplicationContext getApplicationContext() { 
        return s_appContext; 
    }
   
    public static void initComponentsLifeCycle() {
        AutowireCapableBeanFactory  beanFactory = s_appContext.getAutowireCapableBeanFactory();

      Map<String, ComponentMethodInterceptable> interceptableComponents = getApplicationContext().getBeansOfType(
        ComponentMethodInterceptable.class);
      for(Map.Entry<String, ComponentMethodInterceptable> entry : interceptableComponents.entrySet()) {
        Object bean = getTargetObject(entry.getValue());
        beanFactory.configureBean(bean, entry.getKey());
      }
     
      Map<String, ComponentLifecycle> lifecycleComponents = getApplicationContext().getBeansOfType(ComponentLifecycle.class);
      Map[] classifiedComponents = new Map[ComponentLifecycle.MAX_RUN_LEVELS];
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    }
    }

    public static <T> T inject(Object instance) {
        // autowire dynamically loaded object
        AutowireCapableBeanFactory  beanFactory = s_appContext.getAutowireCapableBeanFactory();
        beanFactory.autowireBean(instance);
        return (T)instance;
    }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

  /**
   * Handle Spring-initialization of resoures produced by the UIMA framework.
   */
  public static Resource initResource(Resource aResource, ApplicationContext aApplicationContext) {
    AutowireCapableBeanFactory beanFactory = aApplicationContext.getAutowireCapableBeanFactory();

    if (aResource instanceof PrimitiveAnalysisEngine_impl) {
      PropertyAccessor pa = PropertyAccessorFactory.forDirectFieldAccess(aResource);

      // Access the actual AnalysisComponent and initialize it
      AnalysisComponent analysisComponent = (AnalysisComponent) pa
              .getPropertyValue("mAnalysisComponent");
      initializeBean(beanFactory, analysisComponent, aResource.getMetaData().getName());
      pa.setPropertyValue("mAnalysisComponent", analysisComponent);

      return aResource;
    } else {
      return (Resource) beanFactory.initializeBean(aResource, aResource.getMetaData().getName());
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

   * @see #prepareTestInstance(TestContext)
   * @see #beforeTestMethod(TestContext)
   */
  protected void injectDependencies(final TestContext testContext) throws Exception {
    Object bean = testContext.getTestInstance();
    AutowireCapableBeanFactory beanFactory = testContext.getApplicationContext().getAutowireCapableBeanFactory();
    beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
    beanFactory.initializeBean(bean, testContext.getTestClass().getName());
    testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE);
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    private void initWildcardDefinitionMap() {
        if (null != appContexts) {
            for (ApplicationContext appContext : appContexts) {
                for (String n : appContext.getBeanDefinitionNames()) {
                    if (isWildcardBeanName(n)) {
                        AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
                        BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
                        BeanDefinition bd = bdr.getBeanDefinition(n);
                        String className = bd.getBeanClassName();
                        if (null != className) {
                            if (!wildCardBeanDefinitions.containsKey(className)) {
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

        return null;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        AutowireCapableBeanFactory autowireCapableBeanFactory = applicationContext.getAutowireCapableBeanFactory();
        if (!(autowireCapableBeanFactory instanceof DefaultListableBeanFactory)) {
            throw new IllegalArgumentException(
                    "The implementation returned from applicationContext.getAutowireCapableBeanFactory() "
                            + "doesn't implement DefaultListableBeanFactory");
        }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

        Map<String, T> beans = context.getBeansOfType(clazz);
        return beans.size() == 1 ? getSingleBean(beans) : getPrimaryBean(beans);
    }

    private T getPrimaryBean(Map<String, T> beans) {
        AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
        for(Map.Entry<String, T> bean : beans.entrySet()) {
            if(factory instanceof ConfigurableListableBeanFactory &&
                    ((ConfigurableListableBeanFactory) factory).getBeanDefinition(bean.getKey()).isPrimary()) {
                return bean.getValue();
            }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

     */
    public static void postRegisterSingleton(ApplicationContext applicationContext, String beanName,
            Object bean) {
       
            // TODO: this is ugly
            AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory();
            if (! (factory instanceof DefaultSingletonBeanRegistry)) {
                throw new AssertionError(String.format(
                        "Autowire capabale bean factory %1$s is not instanceof %2$s",
                        factory.getClass().getName(),
                         DefaultSingletonBeanRegistry.class.getName()));
            }
           
            DefaultSingletonBeanRegistry registry = (DefaultSingletonBeanRegistry) factory;           
            // Register singleton
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    private void initWildcardDefinitionMap() {
        if (null != appContexts) {
            for (ApplicationContext appContext : appContexts) {
                for (String n : appContext.getBeanDefinitionNames()) {
                    if (isWildcardBeanName(n)) {
                        AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
                        BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
                        BeanDefinition bd = bdr.getBeanDefinition(n);
                        String className = bd.getBeanClassName();
                        if (null != className) {
                            String orig = n;
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

            cls = Class
                .forName("org.springframework.context.annotation.CommonAnnotationBeanPostProcessor");
        } catch (ClassNotFoundException e) {
            //ignore
        }
        AutowireCapableBeanFactory fact = ctx.getAutowireCapableBeanFactory();
        if (fact instanceof DefaultListableBeanFactory) {
            DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory)fact;
            for (BeanPostProcessor bpp : dlbf.getBeanPostProcessors()) {
                if (cls != null && cls.isInstance(bpp)) {
                    impl.getServerFactory().setBlockPostConstruct(true);
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.