/** * Default method to get an instance of the WireParser * @return the static instance of WireParser */ public static synchronized WireParser getInstance() { if (instance==null) { instance = new WireParser(); } return instance; }
/** * Convenience method to parse a wiring xml. * @param xmlString the xml string to parse * @return the WireDefinition created by parsing the xml given in input. * @see #parseXmlString(String) */ public static WireDefinition parseXmlString(String xmlString) { return (WireDefinition) getInstance() .createParse() .setString(xmlString) .execute() .checkProblems("wire definition xml string") .getDocumentObject(); }
WireDefinition getApplicationWireDefinition(Element documentElement, Parse parse) { Element applicationElement = XmlUtil.element(documentElement, Context.CONTEXTNAME_ENVIRONMENT_FACTORY); if (applicationElement != null) { return (WireDefinition) environmentFactoryXmlParser.parseDocumentElement(applicationElement, parse); } return null; }
public Object parse(Element element, Parse parse, Parser parser) { ObjectDescriptor descriptor = new ObjectDescriptor(); if (!element.hasAttribute("class")) { parse.addProblem("element '" + XmlUtil.getTagLocalName(element) + " must have a 'class' attribute"); } String type = element.getAttribute("class"); descriptor.setClassName(type); List<Element> argElements = XmlUtil.elements(element, "arg"); List<ArgDescriptor> argDescriptors = ((WireParser) parser).parseArgs(argElements, parse); descriptor.setArgDescriptors(argDescriptors); return descriptor; }
public static ScriptManager createDefault() { WireDefinition wireDefinition = (WireDefinition) new WireParser().createParse() .setString( "<objects>" + " <script-manager default-expression-language='juel'" + " default-script-language='beanshell' " + " read-contexts='execution, environment, environment-factory' " + " write-context='execution'>" + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />" + " </script-manager>" + "</objects>" ) .execute() .getDocumentObject(); WireContext wireContext = new WireContext(wireDefinition); return wireContext.get(ScriptManager.class); }
public static synchronized PvmEnvironmentFactoryParser getInstance() { if (instance == null) { instance = new XpdlEnvironmentParser(); // Get bindings Bindings bindings = instance.getEnvironmentXmlParser().getBindings(); // Use the same bindings in block and application contexts instance.getEnvironmentFactoryXmlParser().setBindings(bindings); // Add bonita bindings bindings.addBinding(new HibernateXpdlPersistenceServiceBinding()); bindings.addBinding(new ImplementationBinding("repository")); bindings.addBinding(new ImplementationBinding("finished-instance-handler")); bindings.addBinding(new ImplementationBinding("undeployed-package-handler")); bindings.addBinding(new ImplementationBinding("recorder")); bindings.addBinding(new ImplementationBinding("journal")); bindings.addBinding(new ChainerBinding()); bindings.addBinding(new ImplementationBinding("history")); bindings.addBinding(new ImplementationBinding("archiver")); bindings.addBinding(new QuerierListAccessorBinding()); bindings.addBinding(new APIBinding()); } return instance; }
/** * Parses the list of arguments of a method. * This method creates a list of {@link ArgDescriptor} from the given list of DOM elements * @param argElements the list of argument DOM elements * @param parse Parse object that contains all information for the current parse operation. * @return the list of ArgDescriptor created from the DOM elements * @see ArgDescriptor */ public List<ArgDescriptor> parseArgs(List<Element> argElements, Parse parse) { List<ArgDescriptor> args = null; if (argElements!=null) { if (argElements.size()>0) { args = new ArrayList<ArgDescriptor>(argElements.size()); } for (Element argElement: argElements) { ArgDescriptor argDescriptor = new ArgDescriptor(); argDescriptor.setTypeName(XmlUtil.attribute(argElement, "type")); Element descriptorElement = XmlUtil.element(argElement); if (descriptorElement==null) { parse.addProblem("arg must contain exactly one descriptor element out of "+bindings.getTagNames(CATEGORY_DESCRIPTOR)+" as contents:"+XmlUtil.toString((Element) argElement.getParentNode())); } else { Descriptor descriptor = (Descriptor) parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR); argDescriptor.setDescriptor(descriptor); } args.add(argDescriptor); } } return args; }
public Object parse(Element element, Parse parse, Parser parser) { InvokeOperation invokeOperation = new InvokeOperation(); if (element.hasAttribute("method")) { invokeOperation.setMethodName(element.getAttribute("method")); } else { parse.addProblem("invoke must have method : "+XmlUtil.toString(element)); } List<Element> argElements = XmlUtil.elements(element, "arg"); WireParser wireParser = (WireParser) parser; List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse); invokeOperation.setArgDescriptors(argDescriptors); return invokeOperation; } }
/** * This method builds the WireDefinition from the DOM tree. * This methods parses all child nodes of the documentElement that correspond to a Descriptor definition. * @param documentElement the root element of the document * @param parse Parse object that contains all information for the current parse operation. * @return an instance of WireDefinition containing the resulting WireDefinition. * @see Parser#parseDocumentElement(Element, Parse) */ public Object parseDocumentElement(Element documentElement, Parse parse) { List<Element> elements = XmlUtil.elements(documentElement); WireDefinition wireDefinition = new WireDefinition(); wireDefinition.setClassLoader(classLoader); if (elements!=null) { parse.pushObject(wireDefinition); try { for (Element descriptorElement: elements) { parseElement(descriptorElement, parse, CATEGORY_DESCRIPTOR); } } finally { parse.popObject(); } } return wireDefinition; }
List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse); InvokeOperation invokeOperation = new InvokeOperation(); invokeOperation.setArgDescriptors(argDescriptors);
WireDefinition getBlockWireDefinition(Element documentElement, Parse parse) { Element blockElement = XmlUtil.element(documentElement, Context.CONTEXTNAME_ENVIRONMENT); if (blockElement != null) { return (WireDefinition) environmentXmlParser.parseDocumentElement(blockElement, parse); } return null; }
if (constructorElement!=null) { List<Element> argElements = XmlUtil.elements(constructorElement, "arg"); List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse); descriptor.setArgDescriptors(argDescriptors); List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse); descriptor.setArgDescriptors(argDescriptors); } else if (className == null) {
List<Element> argElements = XmlUtil.elements(element, "arg"); WireParser wireParser = (WireParser) parser; List<ArgDescriptor> argDescriptors = wireParser.parseArgs(argElements, parse); subscribeOperation.setArgDescriptors(argDescriptors);