List of usage examples for org.springframework.util.xml DomUtils getChildElementsByTagName
public static List<Element> getChildElementsByTagName(Element ele, String childEleName)
From source file:fr.acxio.tools.agia.alfresco.configuration.NodeDefinitionParser.java
protected BeanDefinition parseProperty(Element sElement, ParserContext sParserContext) { BeanDefinitionBuilder aBuilder = BeanDefinitionBuilder .genericBeanDefinition(PropertyDefinitionFactoryBean.class); aBuilder.addPropertyValue("localName", sElement.getAttribute(PROPDEF_LOCALNAME)); String aConverterID = sElement.getAttribute(PROPDEF_CONVERTERREF); if (StringUtils.hasText(aConverterID)) { aBuilder.addPropertyReference("converter", aConverterID); }/*www .j a va 2s . c om*/ List<Element> aValuesElements = DomUtils.getChildElementsByTagName(sElement, PROPDEF_VALUE); ManagedList<String> aValues = new ManagedList<String>(aValuesElements.size()); for (Element aElement : aValuesElements) { aValues.add(aElement.getTextContent()); } aBuilder.addPropertyValue("values", aValues); return aBuilder.getBeanDefinition(); }
From source file:org.focusns.common.web.page.config.xml.XmlPageFactory.java
private PageConfig parsePageConfigFile(Element pageEle) { ///*from w ww . j a v a2s. c o m*/ String path = pageEle.getAttribute("path"); String layout = pageEle.getAttribute("layout"); String authority = pageEle.getAttribute("authority"); Map<String, String> parameters = getParameters(pageEle); // PageConfig pageConfig = new PageConfig(path, layout); pageConfig.setAuthority(authority); pageConfig.setParameters(parameters); List<Element> positionEles = DomUtils.getChildElementsByTagName(pageEle, "position"); for (Element positionEle : positionEles) { // String position = positionEle.getAttribute("name"); PositionConfig positionConfig = new PositionConfig(pageConfig); positionConfig.setName(position); List<Element> widgetEles = DomUtils.getChildElementsByTagName(positionEle, "widget"); for (Element widgetEle : widgetEles) { // String styleId = widgetEle.getAttribute("styleId"); String styleClass = widgetEle.getAttribute("styleClass"); // String context = widgetEle.getAttribute("context"); String target = widgetEle.getAttribute("target"); String mode = widgetEle.getAttribute("mode"); String cache = widgetEle.getAttribute("cache"); String order = widgetEle.getAttribute("order"); // WidgetConfig widgetConfig = new WidgetConfig(positionConfig); widgetConfig.setStyleId(styleId); widgetConfig.setStyleClass(styleClass); widgetConfig.setContext(context); widgetConfig.setTarget(target); widgetConfig.setMode(mode); widgetConfig.setCache("".equals(cache) ? 0 : Integer.parseInt(cache)); widgetConfig.setOrder("".equals(order) ? 0 : Integer.parseInt(order)); // preference element Element preferenceEle = DomUtils.getChildElementByTagName(widgetEle, "preference"); if (preferenceEle != null) { for (Element prefEle : DomUtils.getChildElements(preferenceEle)) { String name = prefEle.getAttribute("name"); String value = DomUtils.getTextValue(prefEle); widgetConfig.getPreferences().put(name, value); } } // navigation Element navigationEle = DomUtils.getChildElementByTagName(widgetEle, "navigation"); if (navigationEle != null) { Map<String, String> navigationMap = new HashMap<String, String>(); List<Element> eventEles = DomUtils.getChildElementsByTagName(navigationEle, "event"); for (Element eventEle : eventEles) { String eventOn = eventEle.getAttribute("on"); String eventTo = DomUtils.getTextValue(eventEle); navigationMap.put(eventOn, eventTo); } widgetConfig.setNavigationMap(navigationMap); } // validation Element validationEle = DomUtils.getChildElementByTagName(widgetEle, "validation"); if (validationEle != null) { widgetConfig.setValidationForm(validationEle.getAttribute("formId")); Element targetEle = DomUtils.getChildElementByTagName(validationEle, "target"); if (targetEle != null) { widgetConfig.setValidationTarget(DomUtils.getTextValue(targetEle).trim()); } Element groupsEle = DomUtils.getChildElementByTagName(validationEle, "groups"); if (groupsEle != null) { List<String> validationGroups = new ArrayList<String>(); List<Element> groupEles = DomUtils.getChildElementsByTagName(groupsEle, "group"); for (Element groupEle : groupEles) { validationGroups.add(DomUtils.getTextValue(groupEle).trim()); } widgetConfig.setValidationGroups(validationGroups); } } // positionConfig.addWidgetConfig(widgetConfig); // pageConfig.addWidgetConfig(position, widgetConfig); } pageConfig.addPositionConfig(positionConfig); } // return pageConfig; }
From source file:org.springmodules.cache.config.AbstractCacheSetupStrategyParser.java
private Object parseCacheKeyGenerator(Element element, ParserContext parserContext) { Object keyGenerator = null;//w ww . ja v a 2 s.c o m List cacheKeyGeneratorElements = DomUtils.getChildElementsByTagName(element, "cacheKeyGenerator"); if (!CollectionUtils.isEmpty(cacheKeyGeneratorElements)) { Element cacheKeyGeneratorElement = (Element) cacheKeyGeneratorElements.get(0); keyGenerator = beanReferenceParser.parse(cacheKeyGeneratorElement, parserContext); } return keyGenerator; }
From source file:org.drools.container.spring.namespace.KnowledgeBaseDefinitionParser.java
@SuppressWarnings("unchecked") public static ManagedList getResources(Element element, ParserContext parserContext, BeanDefinitionBuilder factory) { Element resourcesElm = DomUtils.getChildElementByTagName(element, "resources"); ManagedList resources = null;/*from ww w. j a va2 s . com*/ if (resourcesElm != null) { List<Element> childElements = DomUtils.getChildElementsByTagName(resourcesElm, "resource"); if (childElements != null && !childElements.isEmpty()) { resources = new ManagedList(); for (Element childResource : childElements) { BeanDefinition resourceDefinition = parserContext.getDelegate() .parseCustomElement(childResource, factory.getBeanDefinition()); resources.add(resourceDefinition); } } } return resources; }
From source file:org.springjutsu.validation.namespace.ValidationEntityDefinitionParser.java
/** * Parses nested validation rule and template-ref structures * @param ruleNode the ValidationRule node * @param modelClass the model class// ww w.j a va 2 s .c o m * @return a @link{ValidationStructure} object whose * nested rules and template references are those * rules and template references stemming from the ruleNode. */ protected ValidationStructure parseNestedValidation(Element ruleNode, Class<?> modelClass) { ValidationStructure structure = new ValidationStructure(); if (ruleNode == null) { return structure; } List<Element> validationRuleNodes = DomUtils.getChildElementsByTagName(ruleNode, "rule"); if (validationRuleNodes != null) { for (Element rule : validationRuleNodes) { String path = rule.getAttribute("path"); if (path != null && path.length() > 0 && !path.contains("${") && !PathUtils.pathExists(modelClass, path)) { throw new ValidationParseException( "Path \"" + path + "\" does not exist on class " + modelClass.getCanonicalName()); } String type = rule.getAttribute("type"); String value = rule.getAttribute("value"); String message = rule.getAttribute("message"); String errorPath = rule.getAttribute("errorPath"); String collectionStrategy = rule.getAttribute("collectionStrategy"); String onFail = rule.getAttribute("onFail"); ValidationRule validationRule = new ValidationRule(path, type, value); validationRule.setMessage(message); validationRule.setErrorPath(errorPath); validationRule.setCollectionStrategy(CollectionStrategy.forXmlValue(collectionStrategy)); validationRule.setOnFail(RuleErrorMode.forXmlValue(onFail)); ValidationStructure subStructure = parseNestedValidation(rule, modelClass); validationRule.setRules(subStructure.rules); validationRule.setTemplateReferences(subStructure.refs); validationRule.setValidationContexts(subStructure.contexts); structure.rules.add(validationRule); } } List<Element> validationTemplateReferenceNodes = DomUtils.getChildElementsByTagName(ruleNode, "template-ref"); if (validationTemplateReferenceNodes != null) { for (Element templateReference : validationTemplateReferenceNodes) { String basePath = templateReference.getAttribute("basePath"); if (basePath != null && basePath.length() > 0 && !basePath.contains("${") && !PathUtils.pathExists(modelClass, basePath)) { throw new ValidationParseException( "Path \"" + basePath + "\" does not exist on class " + modelClass.getCanonicalName()); } String templateName = templateReference.getAttribute("templateName"); ValidationTemplateReference templateRef = new ValidationTemplateReference(basePath, templateName); structure.refs.add(templateRef); } } List<Element> formNodes = DomUtils.getChildElementsByTagName(ruleNode, "form"); if (formNodes != null) { for (Element formNode : formNodes) { // get form paths. String formPaths = formNode.getAttribute("path"); Set<String> formConstraints = new HashSet<String>(); for (String formPath : formPaths.split(",")) { String candidateFormPath = formPath.trim(); candidateFormPath = RequestUtils.removeLeadingAndTrailingSlashes(candidateFormPath).trim(); if (!candidateFormPath.isEmpty()) { formConstraints.add(candidateFormPath); } } ValidationContext formContext = new ValidationContext(); formContext.setType("form"); ValidationContext flowContext = new ValidationContext(); flowContext.setType("webflow"); for (String formConstraint : formConstraints) { if (formConstraint.contains(":")) { flowContext.getQualifiers().add(formConstraint); } else { formContext.getQualifiers().add(formConstraint); } } // get rules & templates. ValidationStructure formSpecificValidationStructure = parseNestedValidation(formNode, modelClass); formContext.setRules(formSpecificValidationStructure.rules); formContext.setTemplateReferences(formSpecificValidationStructure.refs); formContext.setValidationContexts(formSpecificValidationStructure.contexts); flowContext.setRules(formSpecificValidationStructure.rules); flowContext.setTemplateReferences(formSpecificValidationStructure.refs); flowContext.setValidationContexts(formSpecificValidationStructure.contexts); if (!formContext.getQualifiers().isEmpty()) { structure.contexts.add(formContext); } if (!flowContext.getQualifiers().isEmpty()) { structure.contexts.add(flowContext); } } } List<Element> groupNodes = DomUtils.getChildElementsByTagName(ruleNode, "group"); if (groupNodes != null) { for (Element groupNode : groupNodes) { // get form paths. String groupQualifiers = groupNode.getAttribute("qualifiers"); Set<String> groupConstraints = new HashSet<String>(); for (String qualifier : groupQualifiers.split(",")) { groupConstraints.add(qualifier.trim()); } ValidationContext groupContext = new ValidationContext(); groupContext.setType("group"); groupContext.setQualifiers(groupConstraints); // get rules & templates. ValidationStructure groupSpecificValidationStructure = parseNestedValidation(groupNode, modelClass); groupContext.setRules(groupSpecificValidationStructure.rules); groupContext.setTemplateReferences(groupSpecificValidationStructure.refs); groupContext.setValidationContexts(groupSpecificValidationStructure.contexts); structure.contexts.add(groupContext); } } List<Element> contextNodes = DomUtils.getChildElementsByTagName(ruleNode, "context"); if (contextNodes != null) { for (Element contextNode : contextNodes) { // get form paths. String contextQualifiers = contextNode.getAttribute("qualifiers"); Set<String> contextConstraints = new HashSet<String>(); for (String qualifier : contextQualifiers.split(",")) { contextConstraints.add(qualifier.trim()); } ValidationContext context = new ValidationContext(); context.setType(contextNode.getAttribute("type")); context.setQualifiers(contextConstraints); // get rules & templates. ValidationStructure contextSpecificValidationStructure = parseNestedValidation(contextNode, modelClass); context.setRules(contextSpecificValidationStructure.rules); context.setTemplateReferences(contextSpecificValidationStructure.refs); context.setValidationContexts(contextSpecificValidationStructure.contexts); structure.contexts.add(context); } } return structure; }
From source file:org.smf4j.spring.CsvFileBeanDefinitionParser.java
private String createLayout(Element element, ParserContext context, BeanDefinitionBuilder builder) { List<String> filters = new ArrayList<String>(); List<Element> children = DomUtils.getChildElementsByTagName(element, FILTER_TAG); for (Element child : children) { String tmp = child.getAttribute(VALUE_ATTR); if (StringUtils.hasLength(tmp)) { filters.add(tmp);/* w w w . j av a 2 s. c om*/ } } BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(CSVFILELAYOUT_CLASS); bdb.addPropertyValue(FILTERS_ATTR, filters); return context.getReaderContext().registerWithGeneratedName(bdb.getBeanDefinition()); }
From source file:com.diaimm.april.db.jpa.hibernate.multidbsupport.PersistenceUnitReader.java
/** * Parse the validated document and add entries to the given unit info list. *///from w w w. j a v a 2 s . com protected List<SpringPersistenceUnitInfo> parseDocument(Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException { Element persistence = document.getDocumentElement(); String version = persistence.getAttribute(PERSISTENCE_VERSION); URL rootUrl = determinePersistenceUnitRootUrl(resource); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); for (Element unit : units) { infos.add(parsePersistenceUnitInfo(unit, version, rootUrl)); } return infos; }
From source file:com.gfactor.jpa.core.MyPersistenceUnitReader.java
/** * Parse the validated document and add entries to the given unit info list. *///from w w w.ja v a2 s. c o m protected List<MySpringPersistenceUnitInfo> parseDocument(Resource resource, Document document, List<MySpringPersistenceUnitInfo> infos) throws IOException { Element persistence = document.getDocumentElement(); String version = persistence.getAttribute(PERSISTENCE_VERSION); URL unitRootURL = determinePersistenceUnitRootUrl(resource); List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT); for (Element unit : units) { MySpringPersistenceUnitInfo info = parsePersistenceUnitInfo(unit, version); info.setPersistenceUnitRootUrl(unitRootURL); infos.add(info); } return infos; }
From source file:com.dangdang.ddframe.job.spring.namespace.parser.common.AbstractJobBeanDefinitionParser.java
private List<BeanDefinition> createJobListeners(final Element element) { List<Element> listenerElements = DomUtils.getChildElementsByTagName(element, LISTENER_TAG); List<BeanDefinition> result = new ManagedList<>(listenerElements.size()); for (Element each : listenerElements) { String className = each.getAttribute(CLASS_ATTRIBUTE); BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(className); factory.setScope(BeanDefinition.SCOPE_PROTOTYPE); try {//from w w w. j a v a2 s. co m Class listenerClass = Class.forName(className); if (AbstractDistributeOnceElasticJobListener.class.isAssignableFrom(listenerClass)) { factory.addConstructorArgValue(each.getAttribute(STARTED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); factory.addConstructorArgValue(each.getAttribute(COMPLETED_TIMEOUT_MILLISECONDS_ATTRIBUTE)); } } catch (final ClassNotFoundException ex) { throw new RuntimeException(ex); } result.add(factory.getBeanDefinition()); } return result; }
From source file:org.drools.container.spring.namespace.KnowledgeSessionDefinitionParser.java
@SuppressWarnings("unchecked") protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { String id = element.getAttribute("id"); emptyAttributeCheck(element.getLocalName(), "id", id); String kbase = element.getAttribute(KBASE_ATTRIBUTE); emptyAttributeCheck(element.getLocalName(), KBASE_ATTRIBUTE, kbase); String sessionType = element.getAttribute(TYPE_ATTRIBUTE); BeanDefinitionBuilder factory;// w w w. j a v a 2 s . c o m if ("stateful".equals(sessionType)) { factory = BeanDefinitionBuilder.rootBeanDefinition(StatefulKnowledgeSessionBeanFactory.class); } else if ("stateless".equals(sessionType)) { factory = BeanDefinitionBuilder.rootBeanDefinition(StatelessKnowledgeSessionBeanFactory.class); } else { throw new IllegalArgumentException( "Invalid value for " + TYPE_ATTRIBUTE + " attribute: " + sessionType); } factory.addPropertyReference("kbase", kbase); String node = element.getAttribute(GRID_NODE_ATTRIBUTE); if (node != null && node.length() > 0) { factory.addPropertyReference("node", node); } String name = element.getAttribute(NAME_ATTRIBUTE); if (StringUtils.hasText(name)) { factory.addPropertyValue("name", name); } else { factory.addPropertyValue("name", id); } // Additions for JIRA JBRULES-3076 String listeners = element.getAttribute(LISTENERS_ATTRIBUTE); if (StringUtils.hasText(listeners)) { factory.addPropertyValue("eventListenersFromGroup", new RuntimeBeanReference(listeners)); } EventListenersUtil.parseEventListeners(parserContext, factory, element); // End of Additions for JIRA JBRULES-3076 Element ksessionConf = DomUtils.getChildElementByTagName(element, "configuration"); if (ksessionConf != null) { Element persistenceElm = DomUtils.getChildElementByTagName(ksessionConf, "jpa-persistence"); if (persistenceElm != null) { BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder .genericBeanDefinition(JpaConfiguration.class); String loadId = persistenceElm.getAttribute("load"); if (StringUtils.hasText(loadId)) { beanBuilder.addPropertyValue("id", Long.parseLong(loadId)); } Element tnxMng = DomUtils.getChildElementByTagName(persistenceElm, TX_MANAGER_ATTRIBUTE); String ref = tnxMng.getAttribute("ref"); beanBuilder.addPropertyReference("platformTransactionManager", ref); Element emf = DomUtils.getChildElementByTagName(persistenceElm, EMF_ATTRIBUTE); ref = emf.getAttribute("ref"); beanBuilder.addPropertyReference("entityManagerFactory", ref); Element variablePersisters = DomUtils.getChildElementByTagName(persistenceElm, "variable-persisters"); if (variablePersisters != null && variablePersisters.hasChildNodes()) { List<Element> childPersisterElems = DomUtils.getChildElementsByTagName(variablePersisters, "persister"); ManagedMap persistors = new ManagedMap(childPersisterElems.size()); for (Element persisterElem : childPersisterElems) { String forClass = persisterElem.getAttribute(FORCLASS_ATTRIBUTE); String implementation = persisterElem.getAttribute(IMPLEMENTATION_ATTRIBUTE); if (!StringUtils.hasText(forClass)) { throw new RuntimeException("persister element must have valid for-class attribute"); } if (!StringUtils.hasText(implementation)) { throw new RuntimeException( "persister element must have valid implementation attribute"); } persistors.put(forClass, implementation); } beanBuilder.addPropertyValue("variablePersisters", persistors); } factory.addPropertyValue("jpaConfiguration", beanBuilder.getBeanDefinition()); } BeanDefinitionBuilder rbaseConfBuilder = BeanDefinitionBuilder .rootBeanDefinition(SessionConfiguration.class); Element e = DomUtils.getChildElementByTagName(ksessionConf, KEEP_REFERENCE); if (e != null && StringUtils.hasText(e.getAttribute("enabled"))) { rbaseConfBuilder.addPropertyValue("keepReference", Boolean.parseBoolean(e.getAttribute("enabled"))); } e = DomUtils.getChildElementByTagName(ksessionConf, CLOCK_TYPE); if (e != null && StringUtils.hasText(e.getAttribute("type"))) { rbaseConfBuilder.addPropertyValue("clockType", ClockType.resolveClockType(e.getAttribute("type"))); } factory.addPropertyValue("conf", rbaseConfBuilder.getBeanDefinition()); e = DomUtils.getChildElementByTagName(ksessionConf, WORK_ITEMS); if (e != null) { List<Element> children = DomUtils.getChildElementsByTagName(e, WORK_ITEM); if (children != null && !children.isEmpty()) { ManagedMap workDefs = new ManagedMap(); for (Element child : children) { workDefs.put(child.getAttribute("name"), new RuntimeBeanReference(child.getAttribute("ref"))); } factory.addPropertyValue("workItems", workDefs); } } } Element batch = DomUtils.getChildElementByTagName(element, "batch"); if (batch == null) { // just temporary legacy suppport batch = DomUtils.getChildElementByTagName(element, "script"); } if (batch != null) { // we know there can only ever be one ManagedList children = new ManagedList(); for (int i = 0, length = batch.getChildNodes().getLength(); i < length; i++) { Node n = batch.getChildNodes().item(i); if (n instanceof Element) { Element e = (Element) n; BeanDefinitionBuilder beanBuilder = null; if ("insert-object".equals(e.getLocalName())) { String ref = e.getAttribute("ref"); Element nestedElm = getFirstElement(e.getChildNodes()); beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(InsertObjectCommand.class); if (StringUtils.hasText(ref)) { beanBuilder.addConstructorArgReference(ref); } else if (nestedElm != null) { beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement(nestedElm, null, null)); } else { throw new IllegalArgumentException( "insert-object must either specify a 'ref' attribute or have a nested bean"); } } else if ("set-global".equals(e.getLocalName())) { String ref = e.getAttribute("ref"); Element nestedElm = getFirstElement(e.getChildNodes()); beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(SetGlobalCommand.class); beanBuilder.addConstructorArgValue(e.getAttribute("identifier")); if (StringUtils.hasText(ref)) { beanBuilder.addConstructorArgReference(ref); } else if (nestedElm != null) { beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement(nestedElm, null, null)); } else { throw new IllegalArgumentException( "set-global must either specify a 'ref' attribute or have a nested bean"); } } else if ("fire-until-halt".equals(e.getLocalName())) { beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(FireUntilHaltCommand.class); } else if ("fire-all-rules".equals(e.getLocalName())) { beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(FireAllRulesCommand.class); String max = e.getAttribute("max"); if (StringUtils.hasText(max)) { beanBuilder.addPropertyValue("max", max); } } else if ("start-process".equals(e.getLocalName())) { beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(StartProcessCommand.class); String processId = e.getAttribute("process-id"); if (!StringUtils.hasText(processId)) { throw new IllegalArgumentException("start-process must specify a process-id"); } beanBuilder.addConstructorArgValue(processId); List<Element> params = DomUtils.getChildElementsByTagName(e, "parameter"); if (!params.isEmpty()) { ManagedMap map = new ManagedMap(); for (Element param : params) { String identifier = param.getAttribute("identifier"); if (!StringUtils.hasText(identifier)) { throw new IllegalArgumentException( "start-process paramaters must specify an identifier"); } String ref = param.getAttribute("ref"); Element nestedElm = getFirstElement(param.getChildNodes()); if (StringUtils.hasText(ref)) { map.put(identifier, new RuntimeBeanReference(ref)); } else if (nestedElm != null) { map.put(identifier, parserContext.getDelegate() .parsePropertySubElement(nestedElm, null, null)); } else { throw new IllegalArgumentException( "start-process parameters must either specify a 'ref' attribute or have a nested bean"); } } beanBuilder.addPropertyValue("parameters", map); } } else if ("signal-event".equals(e.getLocalName())) { beanBuilder = BeanDefinitionBuilder.genericBeanDefinition(SignalEventCommand.class); String processInstanceId = e.getAttribute("process-instance-id"); if (StringUtils.hasText(processInstanceId)) { beanBuilder.addConstructorArgValue(processInstanceId); } beanBuilder.addConstructorArgValue(e.getAttribute("event-type")); String ref = e.getAttribute("ref"); Element nestedElm = getFirstElement(e.getChildNodes()); if (StringUtils.hasText(ref)) { beanBuilder.addConstructorArgReference(ref); } else if (nestedElm != null) { beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement(nestedElm, null, null)); } else { throw new IllegalArgumentException( "signal-event must either specify a 'ref' attribute or have a nested bean"); } } if (beanBuilder == null) { throw new IllegalStateException("Unknow element: " + e.getLocalName()); } children.add(beanBuilder.getBeanDefinition()); } } factory.addPropertyValue("batch", children); } // find any kagent's for the current kbase and assign (only if this // is a stateless session) if (sessionType.equals("stateless")) { for (String beanName : parserContext.getRegistry().getBeanDefinitionNames()) { BeanDefinition def = parserContext.getRegistry().getBeanDefinition(beanName); if (KnowledgeAgentBeanFactory.class.getName().equals(def.getBeanClassName())) { PropertyValue pvalue = def.getPropertyValues().getPropertyValue("kbase"); RuntimeBeanReference tbf = (RuntimeBeanReference) pvalue.getValue(); if (kbase.equals(tbf.getBeanName())) { factory.addPropertyValue("knowledgeAgent", new RuntimeBeanReference(beanName)); } } } } return factory.getBeanDefinition(); }