Example #1
0
 // @Override
 public BeanDefinitionBuilder createBeanDefinitionBuilder(Element element, Class beanClass) {
   BeanDefinitionBuilder builder = super.createBeanDefinitionBuilder(element, beanClass);
   String global = element.getAttribute(AbstractMuleBeanDefinitionParser.ATTRIBUTE_REF);
   if (StringUtils.isNotBlank(global)) {
     builder.addConstructorArgReference(global);
     builder.addDependsOn(global);
   }
   return builder;
 }
Example #2
0
 protected void addDependsOn(CamelContextFactoryBean factoryBean, BeanDefinitionBuilder builder) {
   String dependsOn = factoryBean.getDependsOn();
   if (ObjectHelper.isNotEmpty(dependsOn)) {
     // comma, whitespace and semi colon is valid separators in Spring depends-on
     String[] depends = dependsOn.split(",|;|\\s");
     if (depends == null) {
       throw new IllegalArgumentException("Cannot separate depends-on, was: " + dependsOn);
     } else {
       for (String depend : depends) {
         depend = depend.trim();
         LOG.debug("Adding dependsOn {} to CamelContext({})", depend, factoryBean.getId());
         builder.addDependsOn(depend);
       }
     }
   }
 }
    public void handle(Element element) {
      handleCommonBeanAttributes(element, builder, parserContext);
      final NamedNodeMap attrs = element.getAttributes();
      if (attrs != null) {
        Node instanceRefNode = attrs.getNamedItem("instance-ref");
        if (instanceRefNode == null) {
          throw new IllegalStateException(
              "'instance-ref' attribute is required for creating" + " Hazelcast " + type);
        }
        final String instanceRef = getValue(instanceRefNode);
        builder.getRawBeanDefinition().setFactoryBeanName(instanceRef);
        builder.addDependsOn(instanceRef);

        Node nameNode = attrs.getNamedItem("name");
        if (nameNode == null) {
          nameNode = attrs.getNamedItem("id");
        }
        builder.addConstructorArgValue(getValue(nameNode));
      }
    }
Example #4
0
  @Override
  protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
    boolean isAbstract = false;
    boolean publish = true;
    NamedNodeMap atts = element.getAttributes();
    String bus = element.getAttribute("bus");
    if (StringUtils.isEmpty(bus)) {
      addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR);
    } else {
      bean.addConstructorArgReference(bus);
    }
    for (int i = 0; i < atts.getLength(); i++) {
      Attr node = (Attr) atts.item(i);
      String val = node.getValue();
      String pre = node.getPrefix();
      String name = node.getLocalName();

      if ("createdFromAPI".equals(name)) {
        bean.setAbstract(true);
        isAbstract = true;
      } else if (isAttribute(pre, name) && !"publish".equals(name) && !"bus".equals(name)) {
        if ("endpointName".equals(name) || "serviceName".equals(name)) {
          QName q = parseQName(element, val);
          bean.addPropertyValue(name, q);
        } else if ("depends-on".equals(name)) {
          bean.addDependsOn(val);
        } else if (IMPLEMENTOR.equals(name)) {
          loadImplementor(bean, val);
        } else if (!"name".equals(name)) {
          mapToProperty(bean, name, val);
        }
      } else if ("abstract".equals(name)) {
        bean.setAbstract(true);
        isAbstract = true;
      } else if ("publish".equals(name)) {
        publish = "true".equals(val);
      }
    }

    Element elem = DOMUtils.getFirstElement(element);
    while (elem != null) {
      String name = elem.getLocalName();
      if ("properties".equals(name)) {
        Map<?, ?> map = ctx.getDelegate().parseMapElement(elem, bean.getBeanDefinition());
        bean.addPropertyValue("properties", map);
      } else if ("binding".equals(name)) {
        setFirstChildAsProperty(elem, ctx, bean, "bindingConfig");
      } else if ("inInterceptors".equals(name)
          || "inFaultInterceptors".equals(name)
          || "outInterceptors".equals(name)
          || "outFaultInterceptors".equals(name)
          || "features".equals(name)
          || "schemaLocations".equals(name)
          || "handlers".equals(name)) {
        List<?> list = ctx.getDelegate().parseListElement(elem, bean.getBeanDefinition());
        bean.addPropertyValue(name, list);
      } else if (IMPLEMENTOR.equals(name)) {
        ctx.getDelegate().parseConstructorArgElement(elem, bean.getBeanDefinition());
      } else {
        setFirstChildAsProperty(elem, ctx, bean, name);
      }
      elem = DOMUtils.getNextElement(elem);
    }
    if (!isAbstract) {
      if (publish) {
        bean.setInitMethodName("publish");
      }
      bean.setDestroyMethodName("stop");
    }
    // We don't want to delay the registration of our Server
    bean.setLazyInit(false);
  }