List of usage examples for org.springframework.beans.factory.support RootBeanDefinition RootBeanDefinition
public RootBeanDefinition()
From source file:com.clican.pluto.dataprocess.spring.parser.DeployParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionRegistry bdr = parserContext.getRegistry(); RootBeanDefinition beanDef = new RootBeanDefinition(); beanDef.setAbstract(false);// w ww . j av a2 s. c o m beanDef.setBeanClass(Deploy.class); beanDef.setLazyInit(false); beanDef.setAutowireMode(Autowire.BY_NAME.value()); String id = element.getAttribute("id"); if (StringUtils.isEmpty(id)) { id = "dplDeploy#" + element.hashCode(); } bdr.registerBeanDefinition(id, beanDef); this.setBeanDefinitionStringProperty("name", beanDef, element); this.setBeanDefinitionStringProperty("url", beanDef, element); this.setBeanDefinitionStringProperty("propertyResources", beanDef, element); return beanDef; }
From source file:org.apache.zeppelin.lens.LensBootstrap.java
public LensJLineShellComponent getLensJLineShellComponent() { GenericApplicationContext ctx = (GenericApplicationContext) getApplicationContext(); RootBeanDefinition rbd = new RootBeanDefinition(); rbd.setBeanClass(LensJLineShellComponent.class); DefaultListableBeanFactory bf = (DefaultListableBeanFactory) ctx.getBeanFactory(); bf.registerBeanDefinition(LensJLineShellComponent.class.getSimpleName(), rbd); return ctx.getBean(LensJLineShellComponent.class); }
From source file:com.codestd.spring.cxf.config.schema.AnnotationBeanDefinitionParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(beanClass); beanDefinition.setLazyInit(false);/*from ww w .jav a 2s . com*/ String id = element.getAttribute("id"); if (id == null || id.length() == 0) { String name = element.getAttribute("name"); if (!StringUtils.isEmpty(name)) id = name; else id = beanClass.getName(); } if (parserContext.getRegistry().containsBeanDefinition(id)) { throw new IllegalStateException("Duplicate spring bean id " + id); } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); String annotationPackage = element.getAttribute("package"); if (!StringUtils.isEmpty(annotationPackage)) beanDefinition.getPropertyValues().add("annotationPackage", annotationPackage); return beanDefinition; }
From source file:com.newlandframework.rpc.spring.NettyRpcServiceParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { String interfaceName = element.getAttribute("interfaceName"); String ref = element.getAttribute("ref"); RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(NettyRpcService.class); beanDefinition.setLazyInit(false);/*from w w w. j a va 2 s . c om*/ beanDefinition.getPropertyValues().addPropertyValue("interfaceName", interfaceName); beanDefinition.getPropertyValues().addPropertyValue("ref", ref); parserContext.getRegistry().registerBeanDefinition(interfaceName, beanDefinition); return beanDefinition; }
From source file:com.clican.pluto.dataprocess.spring.parser.AbstractProcessorParser.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionRegistry bdr = parserContext.getRegistry(); RootBeanDefinition beanDef = new RootBeanDefinition(); beanDef.setDestroyMethodName("destroy"); beanDef.setAbstract(false);// ww w . j a va2 s .c o m beanDef.setBeanClass(getDataProcessorClass()); beanDef.setLazyInit(false); beanDef.setAutowireMode(Autowire.BY_NAME.value()); String id = element.getAttribute("id"); if (bdr.containsBeanDefinition(id)) { throw new RuntimeException("id[" + id + "]??"); } bdr.registerBeanDefinition(id, beanDef); beanDef.getPropertyValues().addPropertyValue("id", id); String startProcessor = element.getAttribute("startProcessor"); boolean sp = false; if (StringUtils.isNotEmpty(startProcessor)) { sp = Boolean.parseBoolean(startProcessor); } beanDef.getPropertyValues().addPropertyValue("startProcessor", sp); String transaction = element.getAttribute("transaction"); if (StringUtils.isNotEmpty(transaction)) { beanDef.getPropertyValues().addPropertyValue("transaction", transaction); } else if (sp) { beanDef.getPropertyValues().addPropertyValue("transaction", TransactionMode.BEGIN.getMode()); } String cloneContext = element.getAttribute("cloneContext"); if (StringUtils.isNotEmpty(cloneContext)) { beanDef.getPropertyValues().addPropertyValue("cloneContext", Boolean.parseBoolean(cloneContext)); } String propagations = element.getAttribute("propagations"); if (StringUtils.isNotEmpty(propagations)) { List<String> propataionList = new ArrayList<String>(); for (String propagation : propagations.split(",")) { propataionList.add(propagation); } beanDef.getPropertyValues().addPropertyValue("propagations", propataionList); } String nextDataProcessors = element.getAttribute("nextDataProcessors"); if (StringUtils.isNotEmpty(nextDataProcessors)) { List nextDataProcessList = new ManagedList(); for (String nextDataProcess : nextDataProcessors.split(",")) { nextDataProcess = nextDataProcess.trim(); nextDataProcessList.add(new RuntimeBeanReference(nextDataProcess)); } beanDef.getPropertyValues().addPropertyValue("nextDataProcessors", nextDataProcessList); } customiseBeanDefinition(beanDef, element, parserContext); return beanDef; }
From source file:com.newlandframework.rpc.spring.NettyRpcRegisteryParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { String id = element.getAttribute("id"); String ipAddr = element.getAttribute("ipAddr"); String protocolType = element.getAttribute("protocol"); RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(NettyRpcRegistery.class); beanDefinition.getPropertyValues().addPropertyValue("ipAddr", ipAddr); beanDefinition.getPropertyValues().addPropertyValue("protocol", protocolType); parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:com.newlandframework.rpc.spring.NettyRpcReferenceParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { String interfaceName = element.getAttribute("interfaceName"); String id = element.getAttribute("id"); String ipAddr = element.getAttribute("ipAddr"); String protocolType = element.getAttribute("protocol"); RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(NettyRpcReference.class); beanDefinition.setLazyInit(false);/*from ww w .j ava 2s . com*/ beanDefinition.getPropertyValues().addPropertyValue("interfaceName", interfaceName); beanDefinition.getPropertyValues().addPropertyValue("ipAddr", ipAddr); beanDefinition.getPropertyValues().addPropertyValue("protocol", protocolType); parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:com.clican.pluto.dataprocess.spring.parser.ParamProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { List paramBeanList = new ManagedList(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); if ("param".equals(localName)) { RootBeanDefinition bean = new RootBeanDefinition(); bean.setAbstract(false); bean.setBeanClass(ParamBean.class); bean.setLazyInit(false); bean.setAutowireMode(Autowire.BY_NAME.value()); Element paramElement = (Element) node; String paramName = paramElement.getAttribute("paramName"); String paramValue = paramElement.getAttribute("paramValue"); String type = paramElement.getAttribute("type"); String override = paramElement.getAttribute("override"); String pattern = paramElement.getAttribute("pattern"); bean.getPropertyValues().addPropertyValue("paramName", paramName); bean.getPropertyValues().addPropertyValue("paramValue", paramValue); bean.getPropertyValues().addPropertyValue("type", type); bean.getPropertyValues().addPropertyValue("pattern", pattern); if (StringUtils.isNotEmpty(override)) { RootBeanDefinition over = new RootBeanDefinition(); over.setAbstract(false); over.setBeanClass(Boolean.class); over.setLazyInit(false); over.getConstructorArgumentValues().addIndexedArgumentValue(0, override); bean.getPropertyValues().addPropertyValue("override", over); }//from w w w . j a v a 2 s . co m paramBeanList.add(bean); } } } beanDef.getPropertyValues().addPropertyValue("paramBeanList", paramBeanList); }
From source file:com.clican.pluto.fsm.spring.parser.AbstractStateParser.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinitionRegistry bdr = parserContext.getRegistry(); RootBeanDefinition beanDef = new RootBeanDefinition(); beanDef.setDestroyMethodName("destroy"); beanDef.setAbstract(false);/*from w w w . j ava 2 s . com*/ beanDef.setBeanClass(getStateClass(element)); beanDef.setLazyInit(false); beanDef.setAutowireMode(Autowire.BY_NAME.value()); String name = element.getAttribute("name"); if (bdr.containsBeanDefinition(name)) { throw new RuntimeException("name[" + name + "]is defined duplicated"); } bdr.registerBeanDefinition(name, beanDef); beanDef.getPropertyValues().addPropertyValue("name", name); String value = element.getAttribute("value"); beanDef.getPropertyValues().addPropertyValue("value", value); String propagation = element.getAttribute("propagation"); beanDef.getPropertyValues().addPropertyValue("propagation", propagation); String nextStates = element.getAttribute("nextStates"); if (StringUtils.isNotEmpty(nextStates)) { List nextStateList = new ManagedList(); for (String nextState : nextStates.split(",")) { nextStateList.add(new RuntimeBeanReference(nextState.trim())); } beanDef.getPropertyValues().addPropertyValue("nextStates", nextStateList); } String previousStates = element.getAttribute("previousStates"); if (StringUtils.isNotEmpty(previousStates)) { List previousStateList = new ManagedList(); for (String previousState : previousStates.split(",")) { previousStateList.add(new RuntimeBeanReference(previousState.trim())); } beanDef.getPropertyValues().addPropertyValue("previousStates", previousStateList); } NodeList nodeList = element.getChildNodes(); Map nextCondStates = new ManagedMap(); Map params = new ManagedMap(); List stateListeners = new ManagedList(); List taskListeners = new ManagedList(); Map timeoutListeners = 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(); Element e = (Element) node; if ("nextCondStates".equals(localName)) { String expr = e.getAttribute("expr"); nextStates = e.getAttribute("nextStates"); List nextStateList = new ManagedList(); if (StringUtils.isNotEmpty(nextStates)) { for (String nextState : nextStates.split(",")) { nextStateList.add(new RuntimeBeanReference(nextState.trim())); } } nextCondStates.put(expr, nextStateList); } else if ("param".equals(localName)) { String paramName = e.getAttribute("name"); String paramValue = e.getAttribute("value"); params.put(paramName, paramValue); } else if ("stateListener".equals(localName) || "timeoutListener".equals(localName) || "taskListener".equals(localName)) { String clazz = e.getAttribute("clazz"); String listener = e.getAttribute("listener"); Object obj; if (StringUtils.isNotEmpty(clazz)) { try { RootBeanDefinition bean = new RootBeanDefinition(); bean.setAbstract(false); bean.setBeanClass(Class.forName(clazz)); bean.setLazyInit(false); bean.setAutowireMode(Autowire.BY_NAME.value()); if ("timeoutListener".equals(localName)) { String timeoutName = e.getAttribute("name"); String startTime = e.getAttribute("startTime"); String dueTime = e.getAttribute("dueTime"); String repeatTime = e.getAttribute("repeatTime"); String repeatDuration = e.getAttribute("repeatDuration"); String businessCalendarName = e.getAttribute("businessCalendarName"); bean.getPropertyValues().addPropertyValue("name", timeoutName); bean.getPropertyValues().addPropertyValue("startTime", startTime); bean.getPropertyValues().addPropertyValue("dueTime", dueTime); bean.getPropertyValues().addPropertyValue("repeatTime", repeatTime); bean.getPropertyValues().addPropertyValue("repeatDuration", repeatDuration); bean.getPropertyValues().addPropertyValue("businessCalendarName", businessCalendarName); } NodeList nodeList2 = element.getChildNodes(); Map params2 = new ManagedMap(); for (int j = 0; j < nodeList2.getLength(); j++) { Node node2 = nodeList2.item(j); if (node2.getNodeType() == Node.ELEMENT_NODE) { String localName2 = node2.getLocalName(); if ("param".equals(localName2)) { String paramName = ((Element) node2).getAttribute("name"); String paramValue = ((Element) node2).getAttribute("value"); params2.put(paramName, paramValue); } } } obj = bean; } catch (Exception ex) { throw new RuntimeException(ex); } } else if (StringUtils.isNotEmpty(listener)) { obj = new RuntimeBeanReference(listener.trim()); } else { throw new RuntimeException("There must be clazz or listener parameter setting"); } if ("stateListener".equals(localName)) { stateListeners.add(obj); } else if ("taskListeners".equals(localName)) { taskListeners.add(obj); } else { String timeoutName = e.getAttribute("name"); timeoutListeners.put(timeoutName, obj); } } } } beanDef.getPropertyValues().addPropertyValue("nextCondStates", nextCondStates); beanDef.getPropertyValues().addPropertyValue("params", params); beanDef.getPropertyValues().addPropertyValue("stateListeners", stateListeners); if (element.getNodeName().equals("task")) { beanDef.getPropertyValues().addPropertyValue("taskListeners", taskListeners); } beanDef.getPropertyValues().addPropertyValue("timeoutListeners", timeoutListeners); customiseBeanDefinition(beanDef, element, parserContext); return beanDef; }
From source file:com.clican.pluto.dataprocess.spring.parser.ExcelProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { List excelBeanList = new ManagedList(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String localName = node.getLocalName(); if ("write".equals(localName) || "read".equals(localName)) { RootBeanDefinition bean = new RootBeanDefinition(); bean.setAbstract(false); bean.setBeanClass(ExcelExecBean.class); bean.setLazyInit(false); bean.setAutowireMode(Autowire.BY_NAME.value()); Element paramElement = (Element) node; String paramName = paramElement.getAttribute("paramName"); String resultName = paramElement.getAttribute("resultName"); String resource = paramElement.getAttribute("resource"); String sheetName = paramElement.getAttribute("sheetName"); String columns = paramElement.getAttribute("columns"); String columnsVarName = paramElement.getAttribute("columnsVarName"); String sheetVarName = paramElement.getAttribute("sheetVarName"); String typeMapStr = paramElement.getAttribute("typeMap"); String resourceVarName = paramElement.getAttribute("resourceVarName"); Map<String, String> typeMap = new HashMap<String, String>(); if ("read".equals(localName)) { for (String type : typeMapStr.split(";")) { typeMap.put(type.split("=>")[0], type.split("=>")[1]); }/*w w w.j av a 2s . co m*/ } bean.getPropertyValues().addPropertyValue("paramName", paramName); bean.getPropertyValues().addPropertyValue("resultName", resultName); bean.getPropertyValues().addPropertyValue("sheetName", sheetName); if (StringUtils.isNotEmpty(columns)) { bean.getPropertyValues().addPropertyValue("columns", columns.split(",")); } bean.getPropertyValues().addPropertyValue("resource", resource); bean.getPropertyValues().addPropertyValue("typeMap", typeMap); bean.getPropertyValues().addPropertyValue("columnsVarName", columnsVarName); bean.getPropertyValues().addPropertyValue("sheetVarName", sheetVarName); bean.getPropertyValues().addPropertyValue("resourceVarName", resourceVarName); if ("write".equals(localName)) { bean.getPropertyValues().addPropertyValue("read", false); } excelBeanList.add(bean); } } } beanDef.getPropertyValues().addPropertyValue("excelExecBeanList", excelBeanList); }