Package org.springframework.beans.factory.config

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


  public CachingListenerValidatorImplTests(String name) {
    super(name);
  }

  public void testValidateWithBeanDefinitionHolder() {
    BeanDefinition beanDefinition = createCachingListenerBeanDefinition();
    BeanDefinitionHolder holder = createBeanDefinitionHolder(beanDefinition);

    validator.validate(holder, 0, parserContext);
  }
View Full Code Here


    validator.validate(holder, 0, parserContext);
  }

  public void testValidateWithBeanDefinitionNotDescribingCachingListener() {
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    BeanDefinitionHolder holder = createBeanDefinitionHolder(beanDefinition);

    assertValidationThrowsException(holder);
  }
View Full Code Here

  public void testValidateWithObjectNotBeingReferenceOrHolder() {
    assertValidationThrowsException("cachingListener");
  }

  public void testValidateWithRuntimeBeanReference() {
    BeanDefinition beanDefinition = createCachingListenerBeanDefinition();
    String beanName = CACHING_LISTENER_BEAN_NAME;
    registry.registerBeanDefinition(beanName, beanDefinition);
    RuntimeBeanReference reference = new RuntimeBeanReference(beanName);

    validator.validate(reference, 0, parserContext);
View Full Code Here

        definition.getConstructorArgumentValues(), 0,
        RuntimeBeanReference.class);
  }

  private void assertCachingInterceptorIsRegistered() {
    BeanDefinition definition = registry
        .getBeanDefinition(MetadataCachingInterceptor.class.getName());

    ConfigAssert.assertBeanDefinitionHasProperty(definition, propertySource
        .getCacheKeyGeneratorProperty());
    ConfigAssert.assertBeanDefinitionHasProperty(definition, propertySource
View Full Code Here

        definition.getConstructorArgumentValues(), 0,
        RuntimeBeanReference.class);
  }

  private void assertFlushingInterceptorIsRegistered() {
    BeanDefinition definition = registry
        .getBeanDefinition(MetadataFlushingInterceptor.class.getName());

    ConfigAssert.assertBeanDefinitionHasProperty(definition, propertySource
        .getCacheProviderFacadeProperty());
    ConfigAssert.assertBeanDefinitionHasProperty(definition, propertySource
View Full Code Here

    PropertyValue configLocation = parseConfigLocationProperty(element);
    cacheManagerProperties.addPropertyValue(configLocation);
    registry.registerBeanDefinition(id, cacheManager);

    BeanDefinition cacheProviderFacade = registry
        .getBeanDefinition(cacheProviderFacadeId);
    cacheProviderFacade.getPropertyValues().addPropertyValue("cacheManager",
        new RuntimeBeanReference(id));
  }
View Full Code Here

    beanReferenceParserControl.replay();

    // method to test.
    parser.parseCacheSetupStrategy(proxyElement, parserContext, propertySource);

    BeanDefinition proxyDefinition = registry
        .getBeanDefinition(proxyElementBuilder.id);

    // verify property "target" is correct.
    PropertyValue target = proxyDefinition.getPropertyValues()
        .getPropertyValue("target");
    assertEquals(holder, target.getValue());
    assertCacheProxyFactoryBeanDefinitionIsCorrect(proxyDefinition);

    beanReferenceParserControl.verify();
View Full Code Here

    {
      Iterator<String> it = names.iterator();
      while (it.hasNext())
      {
        final String possibility = it.next();
        BeanDefinition beanDef = getBeanDefinition(
          ((AbstractApplicationContext)ctx).getBeanFactory(), possibility);
        if (BeanFactoryUtils.isFactoryDereference(possibility) ||
          possibility.startsWith("scopedTarget.") ||
          (beanDef != null && !beanDef.isAutowireCandidate()))
        {
          it.remove();
        }
      }
    }

    if (names.isEmpty())
    {
      if (required)
      {
        throw new IllegalStateException("bean of type [" + clazz.getName() + "] not found");
      }
      return null;
    }
    else if (names.size() > 1)
    {
      if (ctx instanceof AbstractApplicationContext)
      {
        List<String> primaries = new ArrayList<String>();
        for (String name : names)
        {
          BeanDefinition beanDef = getBeanDefinition(
            ((AbstractApplicationContext)ctx).getBeanFactory(), name);
          if (beanDef instanceof AbstractBeanDefinition)
          {
            if (beanDef.isPrimary())
            {
              primaries.add(name);
            }
          }
        }
View Full Code Here

        return false;
    }

    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String searchValue) {
        ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext)context;
        BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanName);
        if (!ctxt.getBeanFactory().isSingleton(beanName) || def.isAbstract()) {
            return false;
        }
        Collection<?> ids = null;
        PropertyValue pv = def.getPropertyValues().getPropertyValue(propertyName);
       
        if (pv != null) {
            Object value = pv.getValue();
            if (!(value instanceof Collection)) {
                throw new RuntimeException("The property " + propertyName + " must be a collection!");
View Full Code Here

        if (beanName != null)
        {
            modelBean = (ModelBean)modelBeanMap.get(beanName);
            if (modelBean == null)
            {
                BeanDefinition bd = springFactory.getBeanDefinition(beanName);
                Object bean = springFactory.getBean(beanName);
                if (bd == null || bean == null)
                {
                    return new ModelBeanImpl(beanName, ModelBean.POJO);
                }                  
                String lookup = null;
                boolean requiresExternalSupport = false;
                PropertyValue value = bd.getPropertyValues().getPropertyValue("lookupKey");
                if (value != null)
                {
                    lookup = (String)value.getValue();
                }               
                if (bean instanceof ExternalComponentSupport)
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.BeanDefinition

Copyright © 2018 www.massapicom. 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.