/**
  * Set the names of the beans that should automatically get wrapped with proxies. A name can
  * specify a prefix to match by ending with "*", e.g. "myBean,tx*" will match the bean named
  * "myBean" and all beans whose name start with "tx".
  *
  * <p><b>NOTE:</b> In case of a FactoryBean, only the objects created by the FactoryBean will get
  * proxied. This default behavior applies as of Spring 2.0. If you intend to proxy a FactoryBean
  * instance itself (a rare use case, but Spring 1.2's default behavior), specify the bean name of
  * the FactoryBean including the factory-bean prefix "&": e.g. "&myFactoryBean".
  *
  * @see org.springframework.beans.factory.FactoryBean
  * @see org.springframework.beans.factory.BeanFactory#FACTORY_BEAN_PREFIX
  */
 public void setBeanNames(String... beanNames) {
   Assert.notEmpty(beanNames, "'beanNames' must not be empty");
   this.beanNames = new ArrayList<String>(beanNames.length);
   for (String mappedName : beanNames) {
     this.beanNames.add(StringUtils.trimWhitespace(mappedName));
   }
 }
 private void addNoRollbackRuleAttributesTo(
     List<RollbackRuleAttribute> rollbackRules, String noRollbackForValue) {
   String[] exceptionTypeNames = StringUtils.commaDelimitedListToStringArray(noRollbackForValue);
   for (String typeName : exceptionTypeNames) {
     rollbackRules.add(new NoRollbackRuleAttribute(StringUtils.trimWhitespace(typeName)));
   }
 }
 /**
  * Set the regular expressions defining methods to match. Matching will be the union of all these;
  * if any match, the pointcut matches.
  */
 public void setPatterns(String[] patterns) {
   Assert.notEmpty(patterns, "'patterns' must not be empty");
   this.patterns = new String[patterns.length];
   for (int i = 0; i < patterns.length; i++) {
     this.patterns[i] = StringUtils.trimWhitespace(patterns[i]);
   }
   initPatternRepresentation(this.patterns);
 }
 /**
  * Set the regular expressions defining methods to match for exclusion. Matching will be the union
  * of all these; if any match, the pointcut matches.
  */
 public void setExcludedPatterns(String[] excludedPatterns) {
   Assert.notEmpty(excludedPatterns, "'excludedPatterns' must not be empty");
   this.excludedPatterns = new String[excludedPatterns.length];
   for (int i = 0; i < excludedPatterns.length; i++) {
     this.excludedPatterns[i] = StringUtils.trimWhitespace(excludedPatterns[i]);
   }
   initExcludedPatternRepresentation(this.excludedPatterns);
 }
 public String getPageTitle() {
   if (StringUtils.isEmpty(this.pathToPage)) return "";
   this.pageTitle = StringUtils.getFilename(this.pathToPage);
   this.pageTitle = StringUtils.stripFilenameExtension(this.pageTitle);
   this.pageTitle = StringUtils.replace(this.pageTitle, "_", " ");
   this.pageTitle = StringUtils.capitalize(this.pageTitle);
   this.pageTitle = StringUtils.trimWhitespace(this.pageTitle);
   return this.pageTitle;
 }
 /**
  * Given an args pointcut body (could be <code>args</code> or <code>at_args</code>), add any
  * candidate variable names to the given list.
  */
 private void maybeExtractVariableNamesFromArgs(String argsSpec, List<String> varNames) {
   if (argsSpec == null) {
     return;
   }
   String[] tokens = StringUtils.tokenizeToStringArray(argsSpec, ",");
   for (int i = 0; i < tokens.length; i++) {
     tokens[i] = StringUtils.trimWhitespace(tokens[i]);
     String varName = maybeExtractVariableName(tokens[i]);
     if (varName != null) {
       varNames.add(varName);
     }
   }
 }
  /**
   * Get all property values, given a prefix (which will be stripped) and add the bean they define
   * to the factory with the given name
   *
   * @param beanName name of the bean to define
   * @param map Map containing string pairs
   * @param prefix prefix of each entry, which will be stripped
   * @param resourceDescription description of the resource that the Map came from (for logging
   *     purposes)
   * @throws BeansException if the bean definition could not be parsed or registered
   */
  protected void registerBeanDefinition(
      String beanName, Map map, String prefix, String resourceDescription) throws BeansException {

    String className = null;
    String parent = null;
    boolean isAbstract = false;
    boolean singleton = true;
    boolean lazyInit = false;

    MutablePropertyValues pvs = new MutablePropertyValues();
    for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
      Map.Entry entry = (Map.Entry) it.next();
      String key = StringUtils.trimWhitespace((String) entry.getKey());
      if (key.startsWith(prefix + SEPARATOR)) {
        String property = key.substring(prefix.length() + SEPARATOR.length());
        if (isClassKey(property)) {
          className = StringUtils.trimWhitespace((String) entry.getValue());
        } else if (isParentKey(property)) {
          parent = StringUtils.trimWhitespace((String) entry.getValue());
        } else if (ABSTRACT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          isAbstract = TRUE_VALUE.equals(val);
        } else if (SINGLETON_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          singleton = (val == null) || TRUE_VALUE.equals(val);
        } else if (LAZY_INIT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          lazyInit = TRUE_VALUE.equals(val);
        } else if (property.endsWith(REF_SUFFIX)) {
          // This isn't a real property, but a reference to another prototype
          // Extract property name: property is of form dog(ref)
          property = property.substring(0, property.length() - REF_SUFFIX.length());
          String ref = StringUtils.trimWhitespace((String) entry.getValue());

          // It doesn't matter if the referenced bean hasn't yet been registered:
          // this will ensure that the reference is resolved at runtime.
          Object val = new RuntimeBeanReference(ref);
          pvs.addPropertyValue(new PropertyValue(property, val));
        } else {
          // It's a normal bean property.
          pvs.addPropertyValue(new PropertyValue(property, readValue(entry)));
        }
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Registering bean definition for bean name '" + beanName + "' with " + pvs);
    }

    // Just use default parent if we're not dealing with the parent itself,
    // and if there's no class name specified. The latter has to happen for
    // backwards compatibility reasons.
    if (parent == null && className == null && !beanName.equals(this.defaultParentBean)) {
      parent = this.defaultParentBean;
    }

    try {
      AbstractBeanDefinition bd =
          BeanDefinitionReaderUtils.createBeanDefinition(
              className, parent, null, pvs, getBeanClassLoader());
      bd.setAbstract(isAbstract);
      bd.setSingleton(singleton);
      bd.setLazyInit(lazyInit);
      getBeanFactory().registerBeanDefinition(beanName, bd);
    } catch (ClassNotFoundException ex) {
      throw new BeanDefinitionStoreException(
          resourceDescription, beanName, "Bean class [" + className + "] not found", ex);
    } catch (NoClassDefFoundError err) {
      throw new BeanDefinitionStoreException(
          resourceDescription,
          beanName,
          "Class that bean class [" + className + "] depends on not found",
          err);
    }
  }
  /**
   * Get all property values, given a prefix (which will be stripped) and add the bean they define
   * to the factory with the given name
   *
   * @param beanName name of the bean to define
   * @param map Map containing string pairs
   * @param prefix prefix of each entry, which will be stripped
   * @param resourceDescription description of the resource that the Map came from (for logging
   *     purposes)
   * @throws BeansException if the bean definition could not be parsed or registered
   */
  protected void registerBeanDefinition(
      String beanName, Map<?, ?> map, String prefix, String resourceDescription)
      throws BeansException {

    String className = null;
    String parent = null;
    String scope = GenericBeanDefinition.SCOPE_SINGLETON;
    boolean isAbstract = false;
    boolean lazyInit = false;

    ConstructorArgumentValues cas = new ConstructorArgumentValues();
    MutablePropertyValues pvs = new MutablePropertyValues();

    for (Map.Entry<?, ?> entry : map.entrySet()) {
      String key = StringUtils.trimWhitespace((String) entry.getKey());
      if (key.startsWith(prefix + SEPARATOR)) {
        String property = key.substring(prefix.length() + SEPARATOR.length());
        if (CLASS_KEY.equals(property)) {
          className = StringUtils.trimWhitespace((String) entry.getValue());
        } else if (PARENT_KEY.equals(property)) {
          parent = StringUtils.trimWhitespace((String) entry.getValue());
        } else if (ABSTRACT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          isAbstract = TRUE_VALUE.equals(val);
        } else if (SCOPE_KEY.equals(property)) {
          // Spring 2.0 style
          scope = StringUtils.trimWhitespace((String) entry.getValue());
        } else if (SINGLETON_KEY.equals(property)) {
          // Spring 1.2 style
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          scope =
              ((val == null || TRUE_VALUE.equals(val)
                  ? GenericBeanDefinition.SCOPE_SINGLETON
                  : GenericBeanDefinition.SCOPE_PROTOTYPE));
        } else if (LAZY_INIT_KEY.equals(property)) {
          String val = StringUtils.trimWhitespace((String) entry.getValue());
          lazyInit = TRUE_VALUE.equals(val);
        } else if (property.startsWith(CONSTRUCTOR_ARG_PREFIX)) {
          if (property.endsWith(REF_SUFFIX)) {
            int index =
                Integer.parseInt(property.substring(1, property.length() - REF_SUFFIX.length()));
            cas.addIndexedArgumentValue(
                index, new RuntimeBeanReference(entry.getValue().toString()));
          } else {
            int index = Integer.parseInt(property.substring(1));
            cas.addIndexedArgumentValue(index, readValue(entry));
          }
        } else if (property.endsWith(REF_SUFFIX)) {
          // This isn't a real property, but a reference to another prototype
          // Extract property name: property is of form dog(ref)
          property = property.substring(0, property.length() - REF_SUFFIX.length());
          String ref = StringUtils.trimWhitespace((String) entry.getValue());

          // It doesn't matter if the referenced bean hasn't yet been registered:
          // this will ensure that the reference is resolved at runtime.
          Object val = new RuntimeBeanReference(ref);
          pvs.add(property, val);
        } else {
          // It's a normal bean property.
          pvs.add(property, readValue(entry));
        }
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Registering bean definition for bean name '" + beanName + "' with " + pvs);
    }

    // Just use default parent if we're not dealing with the parent itself,
    // and if there's no class name specified. The latter has to happen for
    // backwards compatibility reasons.
    if (parent == null && className == null && !beanName.equals(this.defaultParentBean)) {
      parent = this.defaultParentBean;
    }

    try {
      AbstractBeanDefinition bd =
          BeanDefinitionReaderUtils.createBeanDefinition(parent, className, getBeanClassLoader());
      bd.setScope(scope);
      bd.setAbstract(isAbstract);
      bd.setLazyInit(lazyInit);
      bd.setConstructorArgumentValues(cas);
      bd.setPropertyValues(pvs);
      getRegistry().registerBeanDefinition(beanName, bd);
    } catch (ClassNotFoundException ex) {
      throw new CannotLoadBeanClassException(resourceDescription, beanName, className, ex);
    } catch (LinkageError err) {
      throw new CannotLoadBeanClassException(resourceDescription, beanName, className, err);
    }
  }