Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.AbstractBeanDefinition


    try {
      String parent = null;
      if (ele.hasAttribute(PARENT_ATTRIBUTE)) {
        parent = ele.getAttribute(PARENT_ATTRIBUTE);
      }
      AbstractBeanDefinition bd = createBeanDefinition(className, parent);

      parseBeanDefinitionAttributes(ele, beanName, containingBean, bd);
      bd.setDescription(DomUtils.getChildElementValueByTagName(ele, DESCRIPTION_ELEMENT));

      parseMetaElements(ele, bd);
      parseLookupOverrideSubElements(ele, bd.getMethodOverrides());
      parseReplacedMethodSubElements(ele, bd.getMethodOverrides());

      parseConstructorArgElements(ele, bd);
      parsePropertyElements(ele, bd);
      parseQualifierElements(ele, bd);

      bd.setResource(this.readerContext.getResource());
      bd.setSource(extractSource(ele));

      return bd;
    }
    catch (ClassNotFoundException ex) {
      error("Bean class [" + className + "] not found", ele, ex);
View Full Code Here


      String setterName = "set" + StringUtils.capitalize(propertyName);
      Signature signature = new Signature(setterName, Type.VOID_TYPE, new Type[] { Type.getType(propertyType) });
      maker.add(signature, new Type[0]);
    }
    if (bd instanceof AbstractBeanDefinition) {
      AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
      if (abd.getInitMethodName() != null) {
        Signature signature = new Signature(abd.getInitMethodName(), Type.VOID_TYPE, new Type[0]);
        maker.add(signature, new Type[0]);
      }
      if (abd.getDestroyMethodName() != null) {
        Signature signature = new Signature(abd.getDestroyMethodName(), Type.VOID_TYPE, new Type[0]);
        maker.add(signature, new Type[0]);
      }
    }
    return maker.create();
  }
View Full Code Here

   * Parses the supplied <code>&lt;advisor&gt;</code> element and registers the resulting
   * {@link org.springframework.aop.Advisor} and any resulting {@link org.springframework.aop.Pointcut}
   * with the supplied {@link BeanDefinitionRegistry}.
   */
  private void parseAdvisor(Element advisorElement, ParserContext parserContext) {
    AbstractBeanDefinition advisorDef = createAdvisorBeanDefinition(advisorElement, parserContext);
    String id = advisorElement.getAttribute(ID);

    try {
      this.parseState.push(new AdvisorEntry(id));
      String advisorBeanName = id;
      if (StringUtils.hasText(advisorBeanName)) {
        parserContext.getRegistry().registerBeanDefinition(advisorBeanName, advisorDef);
      }
      else {
        advisorBeanName = parserContext.getReaderContext().registerWithGeneratedName(advisorDef);
      }

      Object pointcut = parsePointcutProperty(advisorElement, parserContext);
      if (pointcut instanceof BeanDefinition) {
        advisorDef.getPropertyValues().add(POINTCUT, pointcut);
        parserContext.registerComponent(
            new AdvisorComponentDefinition(advisorBeanName, advisorDef, (BeanDefinition) pointcut));
      }
      else if (pointcut instanceof String) {
        advisorDef.getPropertyValues().add(POINTCUT, new RuntimeBeanReference((String) pointcut));
        parserContext.registerComponent(
            new AdvisorComponentDefinition(advisorBeanName, advisorDef));
      }
    }
    finally {
View Full Code Here

                  aspectElement, this.parseState.snapshot());
              return;
            }
            beanReferences.add(new RuntimeBeanReference(aspectName));
          }
          AbstractBeanDefinition advisorDefinition = parseAdvice(
              aspectName, i, aspectElement, (Element) node, parserContext, beanDefinitions, beanReferences);
          beanDefinitions.add(advisorDefinition);
        }
      }
View Full Code Here

      parserContext.getReaderContext().error(
          "Exactly one of the " + DEFAULT_IMPL + " or " + DELEGATE_REF + " attributes must be specified",
          declareParentsElement, this.parseState.snapshot());
    }

    AbstractBeanDefinition definition = builder.getBeanDefinition();
    definition.setSource(parserContext.extractSource(declareParentsElement));
    parserContext.getReaderContext().registerWithGeneratedName(definition);
    return definition;
  }
View Full Code Here

          new RootBeanDefinition(SimpleBeanFactoryAwareAspectInstanceFactory.class);
      aspectFactoryDef.getPropertyValues().add("aspectBeanName", aspectName);
      aspectFactoryDef.setSynthetic(true);

      // register the pointcut
      AbstractBeanDefinition adviceDef = createAdviceDefinition(
          adviceElement, parserContext, aspectName, order, methodDefinition, aspectFactoryDef,
          beanDefinitions, beanReferences);

      // configure the advisor
      RootBeanDefinition advisorDefinition = new RootBeanDefinition(AspectJPointcutAdvisor.class);
View Full Code Here

   */
  private AbstractBeanDefinition parsePointcut(Element pointcutElement, ParserContext parserContext) {
    String id = pointcutElement.getAttribute(ID);
    String expression = pointcutElement.getAttribute(EXPRESSION);

    AbstractBeanDefinition pointcutDefinition = null;
   
    try {
      this.parseState.push(new PointcutEntry(id));
      pointcutDefinition = createPointcutDefinition(expression);
      pointcutDefinition.setSource(parserContext.extractSource(pointcutElement));

      String pointcutBeanName = id;
      if (StringUtils.hasText(pointcutBeanName)) {
        parserContext.getRegistry().registerBeanDefinition(pointcutBeanName, pointcutDefinition);
      }
View Full Code Here

      return null;
    }
    else if (element.hasAttribute(POINTCUT)) {
      // Create a pointcut for the anonymous pc and register it.
      String expression = element.getAttribute(POINTCUT);
      AbstractBeanDefinition pointcutDefinition = createPointcutDefinition(expression);
      pointcutDefinition.setSource(parserContext.extractSource(element));
      return pointcutDefinition;
    }
    else if (element.hasAttribute(POINTCUT_REF)) {
      String pointcutRef = element.getAttribute(POINTCUT_REF);
      if (!StringUtils.hasText(pointcutRef)) {
View Full Code Here

      // nothing to enhance -> return immediately
      return;
    }
    ConfigurationClassEnhancer enhancer = new ConfigurationClassEnhancer(beanFactory);
    for (Map.Entry<String, AbstractBeanDefinition> entry : configBeanDefs.entrySet()) {
      AbstractBeanDefinition beanDef = entry.getValue();
      try {
        Class<?> configClass = beanDef.resolveBeanClass(this.beanClassLoader);
        Class<?> enhancedClass = enhancer.enhance(configClass);
        if (configClass != enhancedClass) {
          if (logger.isDebugEnabled()) {
            logger.debug(String.format("Replacing bean definition '%s' existing class name '%s' " +
                "with enhanced class name '%s'", entry.getKey(), configClass.getName(), enhancedClass.getName()));
          }
          beanDef.setBeanClass(enhancedClass);
        }
      }
      catch (Throwable ex) {
        throw new IllegalStateException("Cannot load configuration class: " + beanDef.getBeanClassName(), ex);
      }
    }
  }
View Full Code Here

    String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
    if (StringUtils.hasText(serverBeanName)) {
      builder.addPropertyReference("server", serverBeanName);
    }
    else {
      AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
      if (specialServer != null) {
        builder.addPropertyValue("server", specialServer);
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.AbstractBeanDefinition

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.