@Override
  protected final void doParse(
      final Element e, final ParserContext parserContext, final BeanDefinitionBuilder builder) {

    builder.addConstructorArgValue(
        parserContext.getDelegate().parseListElement(e, builder.getBeanDefinition()));
  }
 protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
   final SpringXmlBuilder springXmlBuilder = new SpringXmlBuilder(parserContext);
   springXmlBuilder.handle(element);
   final BeanDefinitionBuilder builder = springXmlBuilder.getBuilder();
   builder.setFactoryMethod(methodName);
   return builder.getBeanDefinition();
 }
예제 #3
0
  private ManagedList<AbstractBeanDefinition> parseListeners(
      Element element, ParserContext parserContext) {
    List<Element> listenersElements =
        DomUtils.getChildElementsByTagName(element, LISTENERS_ELEMENT);

    ManagedList<AbstractBeanDefinition> listeners = new ManagedList<AbstractBeanDefinition>();

    if (listenersElements.size() == 1) {
      Element listenersElement = listenersElements.get(0);
      CompositeComponentDefinition compositeDef =
          new CompositeComponentDefinition(
              listenersElement.getTagName(), parserContext.extractSource(element));
      parserContext.pushContainingComponent(compositeDef);
      listeners.setMergeEnabled(false);
      List<Element> listenerElements =
          DomUtils.getChildElementsByTagName(listenersElement, LISTENER_ELEMENT);
      for (Element listenerElement : listenerElements) {
        BeanDefinitionBuilder bd = BeanDefinitionBuilder.genericBeanDefinition(listenerType);
        bd.addPropertyValue(
            "delegate", new RuntimeBeanReference(listenerElement.getAttribute(REF_ATTRIBUTE)));
        listeners.add(bd.getBeanDefinition());
      }
      parserContext.popAndRegisterContainingComponent();
    } else if (listenersElements.size() > 1) {
      parserContext
          .getReaderContext()
          .error(
              "The '<listeners/>' element may not appear more than once in a single <job/>.",
              element);
    }

    return listeners;
  }
 @Override
 protected void createOperationsBean(BeanDefinitionRegistry registry) {
   String beanName = "s3ResourceTemplate";
   BeanDefinitionBuilder builder =
       BeanDefinitionBuilder.genericBeanDefinition(S3ResourceTemplate.class);
   registry.registerBeanDefinition(beanName, builder.getBeanDefinition());
 }
    public List<IPlatformPlugin> getPlugins(IPentahoSession session)
        throws PlatformPluginRegistrationException {
      List<IPlatformPlugin> plugins = new ArrayList<IPlatformPlugin>();

      PlatformPlugin p = new PlatformPlugin(new DefaultListableBeanFactory());
      p.setId("test-plugin");

      p.addStaticResourcePath("notused", "public");

      BeanDefinition def =
          BeanDefinitionBuilder.rootBeanDefinition(JUnitContentGenerator.class.getName())
              .getBeanDefinition();
      p.getBeanFactory().registerBeanDefinition("xjunit.viewer", def);

      def =
          BeanDefinitionBuilder.rootBeanDefinition(JUnitServiceContentGenerator.class.getName())
              .getBeanDefinition();
      p.getBeanFactory().registerBeanDefinition("testservice", def);

      def =
          BeanDefinitionBuilder.rootBeanDefinition(ReportContentGenerator.class.getName())
              .getBeanDefinition();
      p.getBeanFactory().registerBeanDefinition("xjunit.report", def);

      ContentInfo contentInfo = new ContentInfo();
      contentInfo.setDescription("JUnit file type");
      contentInfo.setExtension("xjunit");
      contentInfo.setMimeType("application/zip");
      contentInfo.setTitle("JUNIT");
      p.addContentInfo(contentInfo);

      plugins.add(p);

      return plugins;
    }
  /** {@inheritDoc} */
  @Override
  protected void doParse(
      @Nonnull final Element config,
      @Nonnull final ParserContext parserContext,
      @Nonnull final BeanDefinitionBuilder builder) {

    log.warn("PrincipalConnector feature is DEPRECATED in favor of subject c14n flows");

    builder.setInitMethodName("initialize");
    builder.setDestroyMethodName("destroy");

    super.doParse(config, parserContext, builder);

    // First up, add the per type decoders
    addSAMLDecoders(config, parserContext, builder);

    final String format = StringSupport.trimOrNull(config.getAttributeNS(null, "nameIDFormat"));
    builder.addConstructorArgValue(format);

    final String id = StringSupport.trimOrNull(config.getAttributeNS(null, "id"));
    builder.addPropertyValue("id", id);

    final List<Element> children = ElementSupport.getChildElements(config, RELYING_PARTY);
    final List<String> relyingParties = new ManagedList<>(children.size());

    for (Element child : children) {
      relyingParties.add(child.getTextContent());
    }

    builder.addPropertyValue("relyingParties", relyingParties);
  }
 private BeanDefinition createSecurityFilterChain(BeanDefinition matcher, ManagedList<?> filters) {
   BeanDefinitionBuilder sfc =
       BeanDefinitionBuilder.rootBeanDefinition(DefaultSecurityFilterChain.class);
   sfc.addConstructorArgValue(matcher);
   sfc.addConstructorArgValue(filters);
   return sfc.getBeanDefinition();
 }
  @Override
  protected void doParse(
      Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    String exchangeName = element.getAttribute(NAME_ATTRIBUTE);
    builder.addConstructorArgValue(new TypedStringValue(exchangeName));
    parseBindings(element, parserContext, builder, exchangeName);

    NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(
        builder, element, DURABLE_ATTRIBUTE, true);
    NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(
        builder, element, AUTO_DELETE_ATTRIBUTE, false);

    Element argumentsElement = DomUtils.getChildElementByTagName(element, ARGUMENTS_ELEMENT);
    if (argumentsElement != null) {

      String ref = argumentsElement.getAttribute(REF_ATTRIBUTE);
      Map<?, ?> map =
          parserContext
              .getDelegate()
              .parseMapElement(argumentsElement, builder.getRawBeanDefinition());
      if (StringUtils.hasText(ref)) {
        if (map != null && map.size() > 0) {
          parserContext
              .getReaderContext()
              .error("You cannot have both a 'ref' and a nested map", element);
        }
        builder.addConstructorArgReference(ref);
      } else {
        builder.addConstructorArgValue(map);
      }
    }

    NamespaceUtils.parseDeclarationControls(element, builder);
  }
  @Override
  protected void doParse(
      Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    attributesToProperties(element, builder, "basedir");

    URL configFileURL;

    try {
      configFileURL = parserContext.getReaderContext().getResource().getURL();
    } catch (IOException e) {
      configFileURL = null;
    }

    if (configFileURL != null) {
      builder.addPropertyValue("configFileURL", configFileURL);
    }

    ElementSelector pathSelector = and(sameNs(element), name("path"));
    List<Object> paths = createManagedList(element, parserContext);

    for (Element subElement : subElements(element, pathSelector)) {
      paths.add(parsePath(subElement, parserContext));
    }

    builder.addPropertyValue("paths", paths);
  }
  @Override
  protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder =
        BeanDefinitionBuilder.genericBeanDefinition(AmqpOutboundEndpoint.class);
    String amqpTemplateRef = element.getAttribute("amqp-template");
    if (!StringUtils.hasText(amqpTemplateRef)) {
      amqpTemplateRef = "amqpTemplate";
    }
    builder.addConstructorArgReference(amqpTemplateRef);
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name", true);
    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "exchange-name-expression");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key", true);
    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "routing-key-expression");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-delivery-mode");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "lazy-connect");

    IntegrationNamespaceUtils.configureHeaderMapper(
        element, builder, parserContext, DefaultAmqpHeaderMapper.class, null);

    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "confirm-correlation-expression");
    IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
        builder, element, "confirm-ack-channel");
    IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
        builder, element, "confirm-nack-channel");
    IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "return-channel");

    return builder.getBeanDefinition();
  }
 @Override
 protected void doParse(
     Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
   builder.addConstructorArgValue(this.expectReply);
   String inputChannelAttributeName = this.getInputChannelAttributeName();
   String inputChannelRef = element.getAttribute(inputChannelAttributeName);
   if (!StringUtils.hasText(inputChannelRef)) {
     parserContext
         .getReaderContext()
         .error("a '" + inputChannelAttributeName + "' reference is required", element);
   }
   builder.addPropertyReference("requestChannel", inputChannelRef);
   if (this.expectReply) {
     IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel");
     IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout");
     IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout");
     IntegrationNamespaceUtils.setValueIfAttributeDefined(
         builder, element, "extract-reply-payload");
     IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-key");
     IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "convert-exceptions");
   } else {
     IntegrationNamespaceUtils.setValueIfAttributeDefined(
         builder, element, "send-timeout", "requestTimeout");
   }
   IntegrationNamespaceUtils.setValueIfAttributeDefined(
       builder, element, "supported-methods", "supportedMethodNames");
   IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-payload-type");
   IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "view-name");
   IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "errors-key");
   IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "error-code");
   IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
       builder, element, "message-converters");
   IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "header-mapper");
 }
 /**
  * Create a new {@code BeanDefinitionBuilder} used to construct a {@link GenericBeanDefinition}.
  *
  * @param beanClass the {@code Class} of the bean that the definition is being created for
  * @param instanceSupplier a callback for creating an instance of the bean
  * @since 5.0
  */
 public static <T> BeanDefinitionBuilder genericBeanDefinition(
     Class<T> beanClass, Supplier<T> instanceSupplier) {
   BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
   builder.beanDefinition = new GenericBeanDefinition();
   builder.beanDefinition.setBeanClass(beanClass);
   builder.beanDefinition.setInstanceSupplier(instanceSupplier);
   return builder;
 }
 private void getComponent(ParserContext parserContext, BeanDefinitionBuilder beanDefBuilder) {
   parserContext.registerComponent(
       new BeanComponentDefinition(
           beanDefBuilder.getBeanDefinition(),
           parserContext
               .getReaderContext()
               .registerWithGeneratedName(beanDefBuilder.getBeanDefinition())));
 }
  private static void registerComponent(
      ParserContext parserContext, BeanDefinitionBuilder builder, String beanName) {

    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    parserContext.getRegistry().registerBeanDefinition(beanName, builder.getBeanDefinition());
    BeanDefinitionHolder holder = new BeanDefinitionHolder(builder.getBeanDefinition(), beanName);
    parserContext.registerComponent(new BeanComponentDefinition(holder));
  }
 /**
  * Create a new {@code BeanDefinitionBuilder} used to construct a {@link RootBeanDefinition}.
  *
  * @param beanClass the {@code Class} of the bean that the definition is being created for
  * @param factoryMethodName the name of the method to use to construct the bean instance
  */
 public static BeanDefinitionBuilder rootBeanDefinition(
     Class<?> beanClass, String factoryMethodName) {
   BeanDefinitionBuilder builder = new BeanDefinitionBuilder();
   builder.beanDefinition = new RootBeanDefinition();
   builder.beanDefinition.setBeanClass(beanClass);
   builder.beanDefinition.setFactoryMethodName(factoryMethodName);
   return builder;
 }
예제 #16
0
  protected void parseChild(
      Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Element parent = (Element) element.getParentNode();
    String serviceName = parent.getAttribute(ATTRIBUTE_NAME);
    builder.addPropertyReference("service", serviceName);

    // Create a BeanDefinition for the nested object factory and set it a
    // property value for the component
    AbstractBeanDefinition objectFactoryBeanDefinition = new GenericBeanDefinition();
    objectFactoryBeanDefinition.setBeanClass(OBJECT_FACTORY_TYPE);
    objectFactoryBeanDefinition
        .getPropertyValues()
        .addPropertyValue(AbstractObjectFactory.ATTRIBUTE_OBJECT_CLASS, componentInstanceClass);
    objectFactoryBeanDefinition.setInitMethodName(Initialisable.PHASE_NAME);
    objectFactoryBeanDefinition.setDestroyMethodName(Disposable.PHASE_NAME);
    Map props = new HashMap();
    for (int i = 0; i < element.getAttributes().getLength(); i++) {
      Node n = element.getAttributes().item(i);
      props.put(n.getLocalName(), n.getNodeValue());
    }
    String returnData = null;

    NodeList list = element.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      if ("return-data".equals(list.item(i).getLocalName())) {
        Element rData = (Element) list.item(i);
        if (StringUtils.isNotEmpty(rData.getAttribute("file"))) {
          String file = rData.getAttribute("file");
          try {
            returnData = IOUtils.getResourceAsString(file, getClass());
          } catch (IOException e) {
            throw new BeanCreationException("Failed to load test-data resource: " + file, e);
          }
        } else {
          returnData = rData.getTextContent();
        }
      } else if ("callback".equals(list.item(i).getLocalName())) {
        Element ele = (Element) list.item(i);
        String c = ele.getAttribute("class");
        try {
          EventCallback cb = (EventCallback) ClassUtils.instanciateClass(c);
          props.put("eventCallback", cb);

        } catch (Exception e) {
          throw new BeanCreationException("Failed to load event-callback: " + c, e);
        }
      }
    }

    if (returnData != null) {
      props.put("returnData", returnData);
    }
    objectFactoryBeanDefinition.getPropertyValues().addPropertyValue("properties", props);

    builder.addPropertyValue("objectFactory", objectFactoryBeanDefinition);

    super.parseChild(element, parserContext, builder);
  }
  @Override
  protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder =
        BeanDefinitionBuilder.genericBeanDefinition(
            "org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler");
    builder.addConstructorArgValue(element.getAttribute("url"));
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "http-method");

    String restTemplate = element.getAttribute("rest-template");
    if (StringUtils.hasText(restTemplate)) {
      HttpAdapterParsingUtils.verifyNoRestTemplateAttributes(element, parserContext);
      builder.addConstructorArgReference(restTemplate);
    } else {
      for (String referenceAttributeName :
          HttpAdapterParsingUtils.REST_TEMPLATE_REFERENCE_ATTRIBUTES) {
        IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
            builder, element, referenceAttributeName);
      }
    }

    String headerMapper = element.getAttribute("header-mapper");
    String mappedRequestHeaders = element.getAttribute("mapped-request-headers");
    String mappedResponseHeaders = element.getAttribute("mapped-response-headers");
    if (StringUtils.hasText(headerMapper)) {
      if (StringUtils.hasText(mappedRequestHeaders) || StringUtils.hasText(mappedResponseHeaders)) {
        parserContext
            .getReaderContext()
            .error(
                "Neither 'mappped-request-headers' or 'mapped-response-headers' "
                    + "attributes are allowed when a 'header-mapper' has been specified.",
                parserContext.extractSource(element));
        return null;
      }
      builder.addPropertyReference("headerMapper", headerMapper);
    } else {
      BeanDefinitionBuilder headerMapperBuilder =
          BeanDefinitionBuilder.genericBeanDefinition(
              "org.springframework.integration.http.support.DefaultHttpHeaderMapper");
      headerMapperBuilder.setFactoryMethod("outboundMapper");
      IntegrationNamespaceUtils.setValueIfAttributeDefined(
          headerMapperBuilder, element, "mapped-request-headers", "outboundHeaderNames");
      IntegrationNamespaceUtils.setValueIfAttributeDefined(
          headerMapperBuilder, element, "mapped-response-headers", "inboundHeaderNames");
      builder.addPropertyValue("headerMapper", headerMapperBuilder.getBeanDefinition());
    }
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "charset");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "extract-request-payload", "extractPayload");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "expected-response-type");
    IntegrationNamespaceUtils.setValueIfAttributeDefined(
        builder, element, "reply-timeout", "sendTimeout");
    IntegrationNamespaceUtils.setReferenceIfAttributeDefined(
        builder, element, "reply-channel", "outputChannel");
    HttpAdapterParsingUtils.configureUriVariableExpressions(builder, element);
    IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "transfer-cookies");
    return builder;
  }
 @Override
 protected AbstractBeanDefinition parseInternal(
     final Element element, final ParserContext parserContext) {
   BeanDefinitionBuilder result =
       BeanDefinitionBuilder.rootBeanDefinition(ZookeeperRegistryCenter.class);
   result.addConstructorArgValue(buildZookeeperConfigurationBeanDefinition(element));
   result.setInitMethodName("init");
   return result.getBeanDefinition();
 }
예제 #19
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;
 }
예제 #20
0
 protected void doParse(
     Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
   Map parsedMap =
       parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());
   builder.addPropertyValue("sourceMap", parsedMap);
   builder.addPropertyValue("targetMapClass", mapClass.getName());
   getBeanAssembler(element, builder)
       .setBeanFlag(MuleHierarchicalBeanDefinitionParserDelegate.MULE_NO_RECURSE);
 }
  /** {@inheritDoc} */
  protected void doParse(Element config, BeanDefinitionBuilder builder) {
    log.info("Parsing configuration for JSP error handler.");
    super.doParse(config, builder);

    if (config.hasAttributeNS(null, "jspPagePath")) {
      builder.addConstructorArgValue(config.getAttributeNS(null, "jspPagePath"));
    } else {
      builder.addConstructorArgValue(config.getAttributeNS(null, "/error.jsp"));
    }
  }
 protected void parseChild(
     Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
   super.parseChild(element, parserContext, builder);
   final Map parseMap =
       ((MuleHierarchicalBeanDefinitionParserDelegate) parserContext.getDelegate())
           .parseMapElement(
               element, childElementName, childElementKeyAttribute, childElementValueAttribute);
   builder.addPropertyValue("sourceMap", parseMap);
   builder.addPropertyValue("targetMapClass", super.getBeanClass(element));
 }
  private BeanDefinition parsePath(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(SearchPath.class);
    String type = defaultIfNull(trimToNull(element.getAttribute("type")), "relative");
    String path = trimToEmpty(element.getTextContent());

    builder.addConstructorArgValue(path);
    builder.addConstructorArgValue("relative".equals(type));

    return builder.getBeanDefinition();
  }
 protected void doParse(Element element, BeanDefinitionBuilder bean) {
   String id = element.getAttribute("id");
   String name = element.getAttribute("name");
   if (StringUtils.hasText(id)) {
     bean.addPropertyValue("id", Integer.valueOf(id));
   }
   if (StringUtils.hasText(name)) {
     bean.addPropertyValue("name", name);
   }
 }
 @Override
 protected void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
   super.doParse(element, ctx, bean);
   bean.setLazyInit(false);
   // put the bean id into the property map
   Map<String, Object> map = getPropertyMap(bean, true);
   map.put("beanId", resolveId(element, bean.getBeanDefinition(), ctx));
   // set the bean scope to be prototype, then we can get a new instance in each look up
   bean.setScope(BeanDefinition.SCOPE_PROTOTYPE);
 }
 public BeanDefinition parse(Element element, ParserContext parserContext) {
   getComponent(
       parserContext, BeanDefinitionBuilder.rootBeanDefinition(CounterBeanPostProcessor.class));
   getComponent(
       parserContext,
       BeanDefinitionBuilder.rootBeanDefinition(ExceptionCounterBeanPostProcessor.class));
   getComponent(
       parserContext, BeanDefinitionBuilder.rootBeanDefinition(TimedBeanPostProcessor.class));
   return null;
 }
  /**
   * Registers bean definitions for a {@link PluginRegistry} to capture {@link RelProvider}
   * instances. Wraps the registry into a {@link DelegatingRelProvider} bean definition backed by
   * the registry.
   *
   * @param registry
   */
  private static void registerRelProviderPluginRegistryAndDelegate(
      BeanDefinitionRegistry registry) {

    Class<?> defaultRelProviderType =
        EVO_PRESENT ? EvoInflectorRelProvider.class : DefaultRelProvider.class;
    RootBeanDefinition defaultRelProviderBeanDefinition =
        new RootBeanDefinition(defaultRelProviderType);
    registry.registerBeanDefinition("defaultRelProvider", defaultRelProviderBeanDefinition);

    RootBeanDefinition annotationRelProviderBeanDefinition =
        new RootBeanDefinition(AnnotationRelProvider.class);
    registry.registerBeanDefinition("annotationRelProvider", annotationRelProviderBeanDefinition);

    BeanDefinitionBuilder registryFactoryBeanBuilder =
        BeanDefinitionBuilder.rootBeanDefinition(PluginRegistryFactoryBean.class);
    registryFactoryBeanBuilder.addPropertyValue("type", RelProvider.class);
    registryFactoryBeanBuilder.addPropertyValue("exclusions", DelegatingRelProvider.class);

    AbstractBeanDefinition registryBeanDefinition = registryFactoryBeanBuilder.getBeanDefinition();
    registry.registerBeanDefinition("relProviderPluginRegistry", registryBeanDefinition);

    BeanDefinitionBuilder delegateBuilder =
        BeanDefinitionBuilder.rootBeanDefinition(DelegatingRelProvider.class);
    delegateBuilder.addConstructorArgValue(registryBeanDefinition);

    AbstractBeanDefinition beanDefinition = delegateBuilder.getBeanDefinition();
    beanDefinition.setPrimary(true);
    registry.registerBeanDefinition(DELEGATING_REL_PROVIDER_BEAN_NAME, beanDefinition);
  }
  /**
   * @param storedProcComponent
   * @param parserContext
   */
  public static ManagedList<BeanDefinition> getSqlParameterDefinitionBeanDefinitions(
      Element storedProcComponent, ParserContext parserContext) {
    List<Element> sqlParameterDefinitionChildElements =
        DomUtils.getChildElementsByTagName(storedProcComponent, "sql-parameter-definition");
    ManagedList<BeanDefinition> sqlParameterList = new ManagedList<BeanDefinition>();

    for (Element childElement : sqlParameterDefinitionChildElements) {

      String name = childElement.getAttribute("name");
      String sqlType = childElement.getAttribute("type");
      String direction = childElement.getAttribute("direction");
      String scale = childElement.getAttribute("scale");

      final BeanDefinitionBuilder parameterBuilder;

      if ("OUT".equalsIgnoreCase(direction)) {
        parameterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SqlOutParameter.class);
      } else if ("INOUT".equalsIgnoreCase(direction)) {
        parameterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SqlInOutParameter.class);
      } else {
        parameterBuilder = BeanDefinitionBuilder.genericBeanDefinition(SqlParameter.class);
      }

      if (StringUtils.hasText(name)) {
        parameterBuilder.addConstructorArgValue(name);
      } else {
        parserContext
            .getReaderContext()
            .error(
                "The 'name' attribute must be set for the Sql parameter element.",
                storedProcComponent);
      }

      if (StringUtils.hasText(sqlType)) {

        JdbcTypesEnum jdbcTypeEnum = JdbcTypesEnum.convertToJdbcTypesEnum(sqlType);

        if (jdbcTypeEnum != null) {
          parameterBuilder.addConstructorArgValue(jdbcTypeEnum.getCode());
        } else {
          parameterBuilder.addConstructorArgValue(sqlType);
        }

      } else {
        parameterBuilder.addConstructorArgValue(Types.VARCHAR);
      }

      if (StringUtils.hasText(scale)) {
        parameterBuilder.addConstructorArgValue(new TypedStringValue(scale, Integer.class));
      }

      sqlParameterList.add(parameterBuilder.getBeanDefinition());
    }
    return sqlParameterList;
  }
예제 #29
0
    @Override
    protected final void doParse(
        Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
      Object condition = parseCondition(element, parserContext, builder);

      if (condition != null) {
        builder.addPropertyValue("condition", condition);
      }

      builder.addPropertyValue("block", parsePipeline(element, parserContext));
    }
  /**
   * Parse the bean definition and build up the bean.
   *
   * @param element the XML element which contains the attributes.
   * @param bean the builder which builds the bean.
   */
  @Override
  protected void doParse(final Element element, final BeanDefinitionBuilder bean) {
    String converterRef = element.getAttribute("converter-ref");
    String dbRef = element.getAttribute("db-ref");

    bean.addConstructorArgReference(StringUtils.hasText(dbRef) ? dbRef : BeanNames.COUCHBASE);

    if (StringUtils.hasText(converterRef)) {
      bean.addConstructorArgReference(converterRef);
    }
  }