List of usage examples for org.springframework.beans.factory.xml ParserContext isDefaultLazyInit
public boolean isDefaultLazyInit()
From source file:de.itsvs.cwtrpc.controller.config.CacheControlConfigBeanDefinitionParser.java
protected AbstractBeanDefinition createUriConfigBeanDefinition(Element element, ParserContext parserContext) { final BeanDefinitionBuilder bdd; bdd = BeanDefinitionBuilder.rootBeanDefinition(CacheControlUriConfig.class); if (parserContext.isDefaultLazyInit()) { bdd.setLazyInit(true);/* ww w . ja v a 2 s . c om*/ } bdd.getRawBeanDefinition().setSource(parserContext.extractSource(element)); bdd.addConstructorArgValue(createUriPattern(element, parserContext)); if (element.hasAttribute(XmlNames.SERVICE_INTERFACE_ATTR)) { bdd.addPropertyValue("serviceInterface", element.getAttribute(XmlNames.SERVICE_INTERFACE_ATTR)); } update(element, bdd, XmlNames.METHOD_ATTR, "method"); update(element, bdd, XmlNames.PUBLIC_ATTR, "publicContent"); update(element, bdd, XmlNames.PRIVATE_ATTR, "privateContent"); update(element, bdd, XmlNames.NO_CACHE_ATTR, "noCache"); update(element, bdd, XmlNames.NO_STORE_ATTR, "noStore"); update(element, bdd, XmlNames.NO_TRANSFORM_ATTR, "noTransform"); update(element, bdd, XmlNames.MUST_REVALIDATE_ATTR, "mustRevalidate"); update(element, bdd, XmlNames.PROXY_REVALIDATE_ATTR, "proxyRevalidate"); update(element, bdd, XmlNames.MAX_AGE_ATTR, "maxAge"); update(element, bdd, XmlNames.S_MAXAGE_ATTR, "sharedMaxage"); update(element, bdd, XmlNames.EXPIRES_ATTR, "expires"); update(element, bdd, XmlNames.PRAGMA_NO_CACHE_ATTR, "pragmaNoCache"); return bdd.getBeanDefinition(); }
From source file:de.itsvs.cwtrpc.controller.config.AutowiredRemoteServiceGroupConfigBeanDefinitionParser.java
protected BeanDefinition parseFilter(Element element, ParserContext parserContext) { final BeanDefinitionBuilder bdd; final Object type; final String expression; bdd = BeanDefinitionBuilder.rootBeanDefinition(PatternFactory.class); bdd.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isDefaultLazyInit()) { bdd.setLazyInit(true);//from w w w. j a v a 2s.com } if (element.hasAttribute(XmlNames.TYPE_ATTR)) { type = element.getAttribute(XmlNames.TYPE_ATTR); } else { type = DEFAULT_PATTERN_TYPE; } expression = element.getAttribute(XmlNames.EXPRESSION_ATTR); if (!StringUtils.hasText(expression)) { parserContext.getReaderContext().error("Filter expression must not be empty", parserContext.extractSource(element)); } bdd.setFactoryMethod("compile"); bdd.addConstructorArgValue(type); bdd.addConstructorArgValue(MatcherType.PACKAGE); bdd.addConstructorArgValue(expression); return bdd.getBeanDefinition(); }
From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceGroupConfigBeanDefinitionParser.java
protected AbstractBeanDefinition createServiceConfigBeanDefinition(Element element, ParserContext parserContext) { final String serviceName; final BeanDefinitionBuilder bdd; final String relativePath; serviceName = element.getAttribute(XmlNames.SERVICE_REF_ATTR); if (!StringUtils.hasText(serviceName)) { parserContext.getReaderContext().error("Service reference must not be empty", parserContext.extractSource(element)); }/* w w w .j a v a 2 s . co m*/ bdd = BeanDefinitionBuilder.rootBeanDefinition(RemoteServiceConfig.class); if (parserContext.isDefaultLazyInit()) { bdd.setLazyInit(true); } bdd.getRawBeanDefinition().setSource(parserContext.extractSource(element)); bdd.addConstructorArgValue(serviceName); if (element.hasAttribute(XmlNames.SERVICE_INTERFACE_ATTR)) { bdd.addPropertyValue("serviceInterface", element.getAttribute(XmlNames.SERVICE_INTERFACE_ATTR)); } if (element.hasAttribute(XmlNames.RELATIVE_PATH_ATTR)) { relativePath = element.getAttribute(XmlNames.RELATIVE_PATH_ATTR); if (!StringUtils.hasText(relativePath)) { parserContext.getReaderContext().error("Relative path must not be empty", parserContext.extractSource(element)); } bdd.addPropertyValue("relativePath", relativePath); } getBaseServiceConfigParser().update(element, parserContext, bdd); return bdd.getBeanDefinition(); }
From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { final CompositeComponentDefinition compositeDef; final BeanDefinitionBuilder bdd; final AbstractBeanDefinition beanDefinition; String id;//from w ww . j a v a 2s . com compositeDef = new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); parserContext.pushContainingComponent(compositeDef); bdd = BeanDefinitionBuilder.rootBeanDefinition(RemoteServiceControllerConfig.class); bdd.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isDefaultLazyInit()) { bdd.setLazyInit(true); } bdd.addConstructorArgReference(getSerializationPolicyProviderBeanRef(element, parserContext).getBeanName()); bdd.addPropertyValue("serviceModuleConfigs", parseModules(element, parserContext)); getBaseServiceConfigParser().update(element, parserContext, bdd, RemoteServiceControllerConfig.DEFAULT_RPC_VALIDATOR_SERVICE_NAME); id = element.getAttribute(XmlNames.ID_ATTR); if (!StringUtils.hasText(id)) { id = RemoteServiceControllerConfig.DEFAULT_BEAN_ID; } beanDefinition = bdd.getBeanDefinition(); parserContext.registerBeanComponent(new BeanComponentDefinition(beanDefinition, id)); parserContext.popAndRegisterContainingComponent(); return beanDefinition; }
From source file:com.apporiented.spring.override.AbstractGenericBeanDefinitionParser.java
/** * Creates a {@link org.springframework.beans.factory.support.BeanDefinitionBuilder} instance for the * bean class and passes it to the// w w w . ja va 2 s. c o m * {@link #doParse} strategy method. * @param element the element that is to be parsed into a single BeanDefinition * @param parserContext the object encapsulating the current state of the parsing process * @return the BeanDefinition resulting from the parsing of the supplied {@link org.w3c.dom.Element} * @throws IllegalStateException if the bean {@link Class} returned from * bean class is <code>null</code> * @see #doParse */ protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isNested()) { // Inner bean definition must receive same scope as containing bean. builder.setScope(parserContext.getContainingBeanDefinition().getScope()); } if (parserContext.isDefaultLazyInit()) { // Default-lazy-init applies to custom bean definitions as well. builder.setLazyInit(true); } builder.setAutowireMode(autowireMode); builder.setFactoryMethod(factoryMethod); doParse(element, parserContext, builder); return builder.getBeanDefinition(); }
From source file:de.itsvs.cwtrpc.controller.config.CacheControlConfigBeanDefinitionParser.java
protected AbstractBeanDefinition createUriPattern(Element element, ParserContext parserContext) { final String value; final Object type; final RootBeanDefinition beanDefinition; value = element.getAttribute(XmlNames.VALUE_ATTR); if (!StringUtils.hasText(value)) { parserContext.getReaderContext().error("URI value must not be empty", parserContext.extractSource(element)); }//w ww . j a v a 2s. co m if (element.hasAttribute(XmlNames.TYPE_ATTR)) { type = element.getAttribute(XmlNames.TYPE_ATTR); } else { type = CacheControlUriConfig.DEFAULT_PATTERN_TYPE; } beanDefinition = new RootBeanDefinition(PatternFactory.class); beanDefinition.setSource(parserContext.extractSource(element)); if (parserContext.isDefaultLazyInit()) { beanDefinition.setLazyInit(true); } beanDefinition.setFactoryMethodName("compile"); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, type); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(1, MatcherType.URI); beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(2, value); return beanDefinition; }
From source file:net.phoenix.thrift.xml.ComplexBeanDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); String parentName = getParentName(element); if (parentName != null) { builder.getRawBeanDefinition().setParentName(parentName); }/*from ww w. j a v a2s . com*/ Class<?> beanClass = getBeanClass(element); if (beanClass != null) { builder.getRawBeanDefinition().setBeanClass(beanClass); } else { String beanClassName = getBeanClassName(element); if (beanClassName != null) { builder.getRawBeanDefinition().setBeanClassName(beanClassName); } } builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isNested()) { // Inner bean definition must receive same scope as containing bean. builder.setScope(parserContext.getContainingBeanDefinition().getScope()); } if (parserContext.isDefaultLazyInit()) { // Default-lazy-init applies to custom bean definitions as well. builder.setLazyInit(true); } preParse(element, parserContext, builder); AbstractBeanDefinition target = builder.getBeanDefinition(); postParse(element, parserContext, target); return target; }
From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParser.java
protected BeanReference getSerializationPolicyProviderBeanRef(Element element, ParserContext parserContext) { final String serializationPolicyProviderName; if (element.hasAttribute(XmlNames.SERIALIZATION_POLICY_PROVIDER_REF_ATTR) && !ExtendedSerializationPolicyProvider.DEFAULT_BEAN_ID .equals(element.getAttribute(XmlNames.SERIALIZATION_POLICY_PROVIDER_REF_ATTR))) { serializationPolicyProviderName = element.getAttribute(XmlNames.SERIALIZATION_POLICY_PROVIDER_REF_ATTR); } else {/*from www .j a v a2s . co m*/ serializationPolicyProviderName = ExtendedSerializationPolicyProvider.DEFAULT_BEAN_ID; if (!parserContext.getRegistry().containsBeanDefinition(serializationPolicyProviderName)) { final RootBeanDefinition bd; if (log.isInfoEnabled()) { log.info("Registering default serialization policy provider with name '" + serializationPolicyProviderName + "'"); } bd = new RootBeanDefinition(DefaultExtendedSerializationPolicyProvider.class); bd.setSource(parserContext.extractSource(element)); if (parserContext.isDefaultLazyInit()) { bd.setLazyInit(true); } parserContext .registerBeanComponent(new BeanComponentDefinition(bd, serializationPolicyProviderName)); } } return new RuntimeBeanReference(serializationPolicyProviderName); }
From source file:org.springframework.data.jdbc.config.oracle.PoolingDataSourceBeanDefinitionParser.java
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { //ToDo look for username-connection-proxy boolean useWrapper = false; String connectionContextProviderRef = null; Element usernameConnectionProxyElement = DomUtils.getChildElementByTagName(element, USERNAME_CONNECTION_PROXY);// w w w. j av a 2 s . co m if (usernameConnectionProxyElement != null) { if (logger.isDebugEnabled()) { logger.debug("Using username-connection-proxy"); } if (usernameConnectionProxyElement.hasAttribute(CONNECTION_CONTEXT_PROVIDER)) { if (logger.isDebugEnabled()) { logger.debug(CONNECTION_CONTEXT_PROVIDER + ": " + usernameConnectionProxyElement.getAttribute(CONNECTION_CONTEXT_PROVIDER)); } connectionContextProviderRef = usernameConnectionProxyElement .getAttribute(CONNECTION_CONTEXT_PROVIDER); } useWrapper = true; //builder.addPropertyValue("connectionProperties", connProperties); } BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); builder.getRawBeanDefinition().setBeanClassName(getBeanClassName(element)); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); builder.getRawBeanDefinition().setDestroyMethodName("close"); if (parserContext.isNested()) { // Inner bean definition must receive same scope as containing bean. builder.setScope(parserContext.getContainingBeanDefinition().getScope()); } if (parserContext.isDefaultLazyInit()) { // Default-lazy-init applies to custom bean definitions as well. builder.setLazyInit(true); } doParse(element, parserContext, builder); if (useWrapper) { BeanDefinitionBuilder wrapper = BeanDefinitionBuilder.genericBeanDefinition(); wrapper.getRawBeanDefinition() .setBeanClassName("org.springframework.data.jdbc.support.oracle.ProxyDataSource"); wrapper.addConstructorArgValue(builder.getBeanDefinition()); if (connectionContextProviderRef == null) { wrapper.addConstructorArgValue(null); } else { wrapper.addConstructorArgReference(connectionContextProviderRef); } return wrapper.getBeanDefinition(); } else { return builder.getBeanDefinition(); } }