Пример #1
0
 public static void updateProperty(BeanRule beanRule, String text) {
   if (!beanRule.isOffered()) {
     List<Parameters> propertyParametersList = ItemRule.toItemParametersList(text);
     if (propertyParametersList == null) {
       return;
     }
     ItemRuleMap propertyItemRuleMap = ItemRule.toItemRuleMap(propertyParametersList);
     if (propertyItemRuleMap == null) {
       return;
     }
     beanRule.setPropertyItemRuleMap(propertyItemRuleMap);
   }
 }
Пример #2
0
 public static void updateConstructorArgument(BeanRule beanRule, String text) {
   if (!beanRule.isOffered()) {
     List<Parameters> argumentParametersList = ItemRule.toItemParametersList(text);
     if (argumentParametersList == null) {
       return;
     }
     ItemRuleMap constructorArgumentItemRuleMap = ItemRule.toItemRuleMap(argumentParametersList);
     if (constructorArgumentItemRuleMap == null) {
       return;
     }
     beanRule.setConstructorArgumentItemRuleMap(constructorArgumentItemRuleMap);
   }
 }
Пример #3
0
  public static BeanRule newOfferedBeanInstance(
      String id,
      String offerBeanId,
      String offerMethodName,
      String initMethodName,
      String destroyMethodName,
      String factoryMethodName,
      String scope,
      Boolean singleton,
      Boolean lazyInit,
      Boolean important) {

    if (offerBeanId == null || offerMethodName == null) {
      throw new IllegalArgumentException(
          "The 'bean' element requires both 'offerBean' attribute and 'offerMethod' attribute.");
    }

    ScopeType scopeType = ScopeType.resolve(scope);

    if (scope != null && scopeType == null) {
      throw new IllegalArgumentException("No scope type registered for '" + scope + "'.");
    }

    if (scopeType == null) {
      scopeType =
          (singleton == null || singleton == Boolean.TRUE)
              ? ScopeType.SINGLETON
              : ScopeType.PROTOTYPE;
    }

    BeanRule beanRule = new BeanRule();
    beanRule.setId(id);
    beanRule.setScopeType(scopeType);
    beanRule.setSingleton(singleton);
    beanRule.setOfferBeanId(offerBeanId);
    beanRule.setOfferMethodName(offerMethodName);
    beanRule.setOffered(true);
    beanRule.setInitMethodName(initMethodName);
    beanRule.setDestroyMethodName(destroyMethodName);
    beanRule.setFactoryMethodName(factoryMethodName);
    beanRule.setLazyInit(lazyInit);
    beanRule.setImportant(important);
    return beanRule;
  }
Пример #4
0
 public static BeanRule replicate(BeanRule beanRule) {
   BeanRule br = new BeanRule();
   br.setId(beanRule.getId());
   if (beanRule.getScanPattern() == null) {
     br.setBeanClass(beanRule.getBeanClass());
   }
   br.setScopeType(beanRule.getScopeType());
   br.setSingleton(beanRule.getSingleton());
   br.setOfferBeanId(beanRule.getOfferBeanId());
   br.setOfferMethodName(beanRule.getOfferMethodName());
   br.setInitMethodName(beanRule.getInitMethodName());
   br.setDestroyMethodName(beanRule.getDestroyMethodName());
   br.setFactoryMethodName(beanRule.getFactoryMethodName());
   br.setConstructorArgumentItemRuleMap(beanRule.getConstructorArgumentItemRuleMap());
   br.setPropertyItemRuleMap(beanRule.getPropertyItemRuleMap());
   br.setLazyInit(beanRule.getLazyInit());
   br.setImportant(beanRule.getImportant());
   br.setDescription(beanRule.getDescription());
   br.setReplicated(true);
   return br;
 }
Пример #5
0
  public static BeanRule newInstance(
      String id,
      String className,
      String scanPattern,
      String maskPattern,
      String initMethodName,
      String destroyMethodName,
      String factoryMethodName,
      String scope,
      Boolean singleton,
      Boolean lazyInit,
      Boolean important) {

    if (className == null && scanPattern == null) {
      throw new IllegalArgumentException("The 'bean' element requires a 'class' attribute.");
    }

    ScopeType scopeType = ScopeType.resolve(scope);

    if (scope != null && scopeType == null) {
      throw new IllegalArgumentException("No scope type registered for '" + scope + "'.");
    }

    if (scopeType == null) {
      scopeType =
          (singleton == null || singleton == Boolean.TRUE)
              ? ScopeType.SINGLETON
              : ScopeType.PROTOTYPE;
    }

    BeanRule beanRule = new BeanRule();
    beanRule.setId(id);
    if (scanPattern == null) {
      beanRule.setClassName(className);
    } else {
      beanRule.setScanPattern(scanPattern);
      beanRule.setMaskPattern(maskPattern);
    }
    beanRule.setScopeType(scopeType);
    beanRule.setSingleton(singleton);
    beanRule.setInitMethodName(initMethodName);
    beanRule.setDestroyMethodName(destroyMethodName);
    beanRule.setFactoryMethodName(factoryMethodName);
    beanRule.setLazyInit(lazyInit);
    beanRule.setImportant(important);
    return beanRule;
  }