List of usage examples for org.springframework.beans.factory.config RuntimeBeanReference RuntimeBeanReference
public RuntimeBeanReference(Class<?> beanType)
From source file:org.urbantower.j4s.spring.HandlerCollectionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(HandlerCollection.class); List<Element> handlerElms = DomUtils.getChildElements(element); List<Object> handlerDefs = new ManagedList<>(); for (Element elm : handlerElms) { if ("handler".equals(elm.getLocalName())) { RuntimeBeanReference reference = new RuntimeBeanReference(elm.getAttribute("ref")); handlerDefs.add(reference);/*from www .ja va 2 s . c o m*/ } else { BeanDefinition handlerDef = parserContext.getDelegate().parseCustomElement(elm, builder.getBeanDefinition()); handlerDefs.add(handlerDef); } } builder.addPropertyValue("handlers", handlerDefs); return builder.getBeanDefinition(); }
From source file:org.urbantower.j4s.spring.ServerParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringServer.class); //set port/*from ww w .j a va 2 s. com*/ String port = element.getAttribute("http-port"); builder.addPropertyValue("httpPort", Integer.parseInt(port)); //parse & set handlers ManagedList<BeanDefinition> handlers = new ManagedList<>(); if (element.hasAttribute("handler")) { String handlerRef = element.getAttribute("handler"); builder.addPropertyValue("handler", new RuntimeBeanReference(handlerRef)); } else { List<Element> childs = DomUtils.getChildElements(element); if (childs != null && childs.size() > 0) { BeanDefinition handlerDef = parserContext.getDelegate().parseCustomElement(childs.get(0), builder.getBeanDefinition()); builder.addPropertyValue("handler", handlerDef); } } //get id String id = parserContext.getReaderContext().generateBeanName(builder.getBeanDefinition()); if (element.hasAttribute("id")) { id = element.getAttribute("id"); } //get the thread-pool if (element.hasAttribute("thread-pool")) { builder.addConstructorArgValue(new RuntimeBeanReference(element.getAttribute("thread-pool"))); } //register server def. parserContext.getRegistry().registerBeanDefinition(id, builder.getBeanDefinition()); return builder.getBeanDefinition(); }
From source file:com.clican.pluto.dataprocess.spring.parser.ConditionProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { NodeList nodeList = element.getChildNodes(); ManagedMap processorMap = new ManagedMap(); ManagedMap exceptionMap = new ManagedMap(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); if ("cond".equals(localName)) { Element condElement = (Element) node; String expr = condElement.getAttribute("expr"); String nextDataProcessor = condElement.getAttribute("nextDataProcessor"); String exception = condElement.getAttribute("exception"); if (StringUtils.isNotEmpty(exception)) { exceptionMap.put(expr, exception); } else if (StringUtils.isNotEmpty(nextDataProcessor)) { processorMap.put(expr, new RuntimeBeanReference(nextDataProcessor)); } else { processorMap.put(expr, null); }// w w w . j a v a 2s . co m } } } beanDef.getPropertyValues().addPropertyValue("exceptionMap", exceptionMap); beanDef.getPropertyValues().addPropertyValue("dataProcessorMap", processorMap); }
From source file:com.github.xdcrafts.flower.spring.impl.xml.SyncFlowBeanDefinitionHandler.java
protected void doParse(Element element, BeanDefinitionBuilder bean) { final ManagedList<Object> actions = new ManagedList<>(); final NodeList actionNodes = element.getElementsByTagName("*"); if (actionNodes != null && actionNodes.getLength() != 0) { for (int i = 0; i < actionNodes.getLength(); i++) { final Node node = actionNodes.item(i); final String type = node.getLocalName(); if (type.equalsIgnoreCase("method")) { actions.add(node.getTextContent()); } else if (type.equalsIgnoreCase("action")) { actions.add(new RuntimeBeanReference(node.getTextContent())); } else { throw new IllegalArgumentException("Unknown element type: " + type); }//from w w w .j a va 2s . co m } } bean.addPropertyValue("actions", actions); }
From source file:com.github.xdcrafts.flower.spring.impl.xml.ExtensionBeanDefinitionHandler.java
protected void doParse(Element element, BeanDefinitionBuilder bean) { final Map<Object, Object> configuration = new ManagedMap<>(); final Node keywordValueNode = element .getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "keyword-value").item(0); final Node predicateNode = element .getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "predicate").item(0); if (keywordValueNode != null) { configuration.put("keyword-value", keywordValueNode.getTextContent()); }/*from w w w.j a va 2s . co m*/ if (predicateNode != null) { configuration.put("predicate", new RuntimeBeanReference(predicateNode.getTextContent())); } bean.addPropertyReference("action", element.getAttribute("action")).addPropertyValue("configuration", configuration); }
From source file:org.hummer.spring.ServicePaser.java
public BeanDefinition parse(Element ele, ParserContext context) { //?//from w w w.j a va2s . c om service = ele.getAttribute(ATTR_SERVICE); version = ele.getAttribute(ATTR_VERSION); ref = ele.getAttribute(ATTR_REF); RootBeanDefinition root = new RootBeanDefinition(ServiceBean.class); root.setLazyInit(false); root.getPropertyValues().add("service", service); root.getPropertyValues().add("version", version); root.getPropertyValues().add("ref", new RuntimeBeanReference(ref)); context.getRegistry() .registerBeanDefinition(beanNameGenerator.generateBeanName(root, context.getRegistry()), root); return null; }
From source file:com.github.xdcrafts.flower.spring.impl.xml.FeatureBeanDefinitionHandler.java
protected void doParse(Element element, BeanDefinitionBuilder bean) { final ManagedMap<Object, Object> extensions = new ManagedMap<>(); final NodeList bindingNodes = element.getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "binding"); if (bindingNodes != null && bindingNodes.getLength() != 0) { for (int i = 0; i < bindingNodes.getLength(); i++) { final Node bindingNode = bindingNodes.item(i); final String extension = bindingNode.getAttributes().getNamedItem("extension").getNodeValue(); final String selector = bindingNode.getAttributes().getNamedItem("selector").getNodeValue(); extensions.put(new RuntimeBeanReference(extension), new RuntimeBeanReference(selector)); }//from w ww .j a va2s. c o m } bean.addPropertyValue("extensions", extensions); }
From source file:org.springmodules.cache.config.AnnotationsParserTests.java
public void testConfigureCachingInterceptor() { MutablePropertyValues propertyValues = new MutablePropertyValues(); parser.configureCachingInterceptor(propertyValues, registry); Class targetClass = AnnotationCachingAttributeSource.class; String beanName = targetClass.getName(); AbstractBeanDefinition definition = (AbstractBeanDefinition) registry.getBeanDefinition(beanName); ConfigAssert.assertBeanDefinitionWrapsClass(definition, targetClass); PropertyValue expected = new PropertyValue("cachingAttributeSource", new RuntimeBeanReference(beanName)); ConfigAssert.assertPropertyIsPresent(propertyValues, expected); }
From source file:com.developmentsprint.spring.breaker.config.AnnotationDrivenBreakerBeanDefinitionParser.java
private static void parseCircuitManagerProperty(Element element, BeanDefinition def) { def.getPropertyValues().add("circuitManager", new RuntimeBeanReference(BreakerNamespaceHandler.extractCircuitManager(element))); }
From source file:com.clican.pluto.dataprocess.spring.parser.JGroupPartitionProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { ((RootBeanDefinition) beanDef).setInitMethodName("init"); String partition = element.getAttribute("partition"); if (StringUtils.isEmpty(partition)) { partition = "partition"; }// w w w . j a va2 s. c o m String partitionListName = element.getAttribute("partitionListName"); if (StringUtils.isNotEmpty(element.getAttribute("inputVarName"))) { String[] inputVarName = element.getAttribute("inputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("inputVarName", inputVarName); } if (StringUtils.isNotEmpty(element.getAttribute("outputVarName"))) { String[] outputVarName = element.getAttribute("outputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("outputVarName", outputVarName); } String serviceName = element.getAttribute("serviceName"); beanDef.getPropertyValues().addPropertyValue("partitionListName", partitionListName); beanDef.getPropertyValues().addPropertyValue("serviceName", serviceName); try { beanDef.getPropertyValues().addPropertyValue("partition", new RuntimeBeanReference(partition)); } catch (Throwable e) { } String[] partitionProcessors = element.getAttribute("partitionProcessors").split(","); List partitionProcessorList = new ManagedList(); for (String partitionProcessor : partitionProcessors) { partitionProcessorList.add(new RuntimeBeanReference(partitionProcessor.trim())); } beanDef.getPropertyValues().addPropertyValue("partitionProcessors", partitionProcessorList); }