Package org.springframework.beans.factory.config

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


    {
      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


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

    if (names.isEmpty())
    {
      throw new IllegalStateException("bean of type [" + clazz.getName() + "] not found");
    }
    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 (((AbstractBeanDefinition)beanDef).isPrimary())
            {
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.isAutowireCandidate())
        {
          it.remove();
        }
      }
    }

    if (names.isEmpty())
    {
      throw new IllegalStateException("bean of type [" + clazz.getName() + "] not found");
    }
    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 (((AbstractBeanDefinition)beanDef).isPrimary())
            {
View Full Code Here

    }

    protected void createBeanPostProcessor(ParserContext parserContext, String contextId, Element childElement, BeanDefinitionBuilder parentBuilder) {
        String beanPostProcessorId = contextId + ":beanPostProcessor";
        childElement.setAttribute("id", beanPostProcessorId);
        BeanDefinition definition = beanPostProcessorParser.parse(childElement, parserContext);
        definition.getPropertyValues().addPropertyValue("camelContext", new RuntimeBeanReference(contextId));
        parentBuilder.addPropertyReference("beanPostProcessor", beanPostProcessorId);
    }
View Full Code Here

                    String localName = child.getLocalName();
                    if (localName.equals("beanPostProcessor")) {
                        createBeanPostProcessor(parserContext, contextId, childElement, builder);
                        createdBeanPostProcessor = true;
                    } else if (localName.equals("endpoint")) {
                        BeanDefinition definition = endpointParser.parse(childElement, parserContext);
                        String id = childElement.getAttribute("id");
                        if (ObjectHelper.isNotNullAndNonEmpty(id)) {
                            // TODO we can zap this?
                            definition.getPropertyValues()
                                .addPropertyValue("camelContext", new RuntimeBeanReference(contextId));
                            // definition.getPropertyValues().addPropertyValue("context",
                            // builder.getBeanDefinition());
                            parserContext.registerComponent(new BeanComponentDefinition(definition, id));
                        }
                    } else {
                        BeanDefinitionParser parser = parserMap.get(localName);
                        if (parser != null) {
                            BeanDefinition definition = parser.parse(childElement, parserContext);
                            String id = childElement.getAttribute("id");
                            if (ObjectHelper.isNotNullAndNonEmpty(id)) {
                                parserContext.registerComponent(new BeanComponentDefinition(definition, id));
                                if (localName.equals("jmxAgent")) {
                                    builder.addPropertyReference("camelJMXAgent", id);
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

                throw new IllegalStateException ("Illegal inner child element");
            }
      BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
      BeanDefinitionHolder beanDefinitionHolder = delegate.parseBeanDefinitionElement(beanElement);
      beanDefinitionHolder = delegate.decorateBeanDefinitionIfRequired(beanElement, beanDefinitionHolder);
      BeanDefinition beanDefinition = beanDefinitionHolder.getBeanDefinition();
      innerComponentDefinition = new BeanComponentDefinition(beanDefinition, beanDefinitionHolder.getBeanName());
    }
    return innerComponentDefinition;
  }
View Full Code Here

        if (first == null) {
            throw new IllegalStateException(propertyName + " property must have child elements!");
        }
       
        String id;
        BeanDefinition child;
        if (first.getNamespaceURI().equals(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI)) {
            String name = first.getLocalName();
            if ("ref".equals(name)) {
                id = first.getAttribute("bean");
                if (id == null) {
View Full Code Here

        ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext)beanFactory;

        // Take any bean name or alias that has a web service annotation
        for (int i = 0; i < beanNames.length; i++) {

            BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]);

            if (!beanFactory.isSingleton(beanNames[i]) || def.isAbstract()) {
                continue;
            }

            try {
                Collection<?> ids = null;
                PropertyValue pv = def.getPropertyValues().getPropertyValue(idsProperty);
               
                if (pv != null) {
                    Object value = pv.getValue();
                    if (!(value instanceof Collection)) {
                        throw new RuntimeException("The property " + idsProperty + " must be a collection!");
View Full Code Here

        ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext)beanFactory;

        // Take any bean name or alias that has a web service annotation
        for (int i = 0; i < beanNames.length; i++) {
            BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]);

            if (!beanFactory.isSingleton(beanNames[i]) || def.isAbstract()) {
                continue;
            }

            try {
                Collection<?> ids = null;
                PropertyValue pv = def.getPropertyValues().getPropertyValue(idsProperty);
               
                if (pv != null) {
                    Object value = pv.getValue();
                    if (!(value instanceof Collection)) {
                        throw new RuntimeException("The property " + idsProperty + " must be a collection!");
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.