protected void registerParser(String elementName, String className) { // logger.info("registerParser elementName:" + elementName + " className:" + className); BeanDefinitionParser parser; try { parser = getBeanDefinitionParser(elementName, className); // logger.info("registerParser elementName:" + elementName + " parser:" + parser); } catch (Exception e) { logger.error(e.getMessage(), e); return; } // try { // parser = (BeanDefinitionParser) Class.forName(className).newInstance(); // } // catch (Exception e) { // // throw new RuntimeException(e.getMessage(), e); // return; // } registerBeanDefinitionParser(elementName, parser); }
protected BeanDefinitionParser getBeanDefinitionParser(String elementName, String className) throws Exception { boolean useH2 = isUseH2(); if (!useH2) { return (BeanDefinitionParser) Class.forName(className).newInstance(); } String h2ClassName = className.replace("io.leopard.schema", "io.leopard.schema.h2"); Class<?> clazz; try { clazz = Class.forName(h2ClassName); } catch (ClassNotFoundException e) { clazz = Class.forName(className); } return (BeanDefinitionParser) clazz.newInstance(); }
private void parseListElement(Element ele, ParserContext parserContext) { BeanDefinitionParser parser = new BlueprintCollectionBeanDefinitionParser() { @Override protected CollectionType collectionType() { return CollectionType.LIST; } }; parser.parse(ele, parserContext); }
private void parseSetElement(Element ele, ParserContext parserContext) { BeanDefinitionParser parser = new BlueprintCollectionBeanDefinitionParser() { @Override protected CollectionType collectionType() { return CollectionType.SET; } }; parser.parse(ele, parserContext); }
private static void parseTestStepComponents(List<Element> childElements, BeanDefinition beanDef, ParserContext parserContext) { ManagedList<BeanDefinition> children = new ManagedList<BeanDefinition>(//NOPMD childElements.size()); for (Element element : childElements) { BeanDefinitionParser bep = XsdNameSpaceParserRegistry.getNameSpaceHandlerRegistry().get(element.getLocalName()); if (null == bep) throw GlobalUtils.createNotInitializedException("Name space handler not registered for this element: " + element.getTagName()); BeanDefinition tmpBDef = bep.parse(element, parserContext); tmpBDef.getPropertyValues().removePropertyValue(tmpBDef.getPropertyValues().getPropertyValue(XsdElementConstants.MEMBER_BASETESTSTEP_TESTCASE)); children.add(tmpBDef); // if (element.getTagName() == "ate:" //NOPMD // + XsdElementConstants.ELEMENT_HOMESTEP) { // HomeStepBeanDefinitionParser homeStep = new HomeStepBeanDefinitionParser(); // BeanDefinition tmpBDef = homeStep.parse(element, parserContext); // tmpBDef.getPropertyValues().removePropertyValue(tmpBDef.getPropertyValues().getPropertyValue(XsdElementConstants.MEMBER_BASETESTSTEP_TESTCASE)); // // children.add(tmpBDef); // } else if (element.getTagName() == "ate:" // + XsdElementConstants.ELEMENT_ELEMENTSTEP) { // ElementStepBeanDefinitionParser elementStep = new ElementStepBeanDefinitionParser(); // BeanDefinition tmpBDef = elementStep.parse(element, parserContext); // tmpBDef.getPropertyValues().removePropertyValue(tmpBDef.getPropertyValues().getPropertyValue(XsdElementConstants.MEMBER_BASETESTSTEP_TESTCASE)); // // children.add(tmpBDef); // } else if (element.getTagName() == "ate:" // + XsdElementConstants.ELEMENT_LASTSTEP) { // LastStepBeanDefinitionParser lastStep = new LastStepBeanDefinitionParser(); // BeanDefinition tmpBDef = lastStep.parse(element, parserContext); // tmpBDef.getPropertyValues().removePropertyValue(tmpBDef.getPropertyValues().getPropertyValue(XsdElementConstants.MEMBER_BASETESTSTEP_TESTCASE)); // // children.add(tmpBDef); // // } } beanDef.getPropertyValues().addPropertyValue( XsdElementConstants.MEMBER_STEPTYPESERVICE_STEPSET, children); }
private static void parseAsserterComponents(List<Element> childElements, BeanDefinition beanDef, ParserContext parserContext) { ManagedList<BeanDefinition> children = new ManagedList<BeanDefinition>(//NOPMD childElements.size()); for (Element element : childElements) { BeanDefinitionParser bep = XsdNameSpaceParserRegistry.getNameSpaceHandlerRegistry().get(element.getLocalName()); if (null == bep) throw GlobalUtils.createNotInitializedException("Name space handler not registered for this element: " + element.getTagName()); BeanDefinition tmpBDef = bep.parse(element, parserContext); children.add(tmpBDef); } beanDef.getPropertyValues().addPropertyValue( "expectedResultAsserter", children); }
/** * {@inheritDoc} */ @Override public void init() { Map<String, BeanDefinitionParser> userParsers = XsdNameSpaceParserRegistry.getNameSpaceHandlerRegistry(); for (Map.Entry<String, BeanDefinitionParser> parser : userParsers.entrySet()) { registerBeanDefinitionParser(parser.getKey(), parser.getValue()); } }
/** * {@inheritDoc} */ @Override public BeanDefinitionParser getParser() { final JavaCodedStepNameSpaceParser nameSpaceParser2 = nameSpaceParser; if (nameSpaceParser2 == null) { return new JavaCodedStepNameSpaceParser();// NOPMD } else { return nameSpaceParser2; } }
/** * Register bean definition parsers for supported boxed-primitive creation elements. * Use reflection to attach the correct parsers by naming conventions of both the * elements and parser classes * * @param boxedElementTypes * list of supported boxed-primitive types */ private void registerBoxedTypeElementParsers(final List<Class<?>> boxedElementTypes) { for (final Class<?> elementType : boxedElementTypes) { final String typeName = elementType.getSimpleName(); final String elementName = typeName.toLowerCase(); final Class<? extends BeanDefinitionParser> parserClass = loadParserClass( elementName, typeName + BOXED_BEAN_DEFINITION_PARSER_SUFFIX); final BeanDefinitionParser parserInstance = getParserInstance(parserClass); registerBeanDefinitionParser(elementName, parserInstance); } }
private void parseReferenceElement(Element ele, ParserContext parserContext) { BeanDefinitionParser parser = new BlueprintReferenceBeanDefinitionParser(); parser.parse(ele, parserContext); }
private void parseServiceElement(Element ele, ParserContext parserContext) { BeanDefinitionParser parser = new BlueprintServiceDefinitionParser(); parser.parse(ele, parserContext); }
protected BeanDefinitionParser getCacheProviderFacadeParser() { return cacheProviderFacadeParser; }
@Override public void init() { registerBeanDefinitionParser("config", (BeanDefinitionParser)new NatsConfigBeanDefinitionParser()); }
/** * @return the nameSpaceHandlerRegistry */ public static Map<String, BeanDefinitionParser> getNameSpaceHandlerRegistry() { return nameSpaceHandlerRegistry; }
private static void parseTestStepComponents(List<Element> childElements, BeanDefinitionBuilder factory, ParserContext parserContext) { if (!childElements.isEmpty()) { ManagedList<BeanDefinition> children = new ManagedList<BeanDefinition>(//NOPMD childElements.size()); for (Element element : childElements) { BeanDefinitionParser bep = XsdNameSpaceParserRegistry.getNameSpaceHandlerRegistry().get(element.getLocalName()); if (null == bep) throw GlobalUtils.createNotInitializedException("Name space handler not registered for this element: " + element.getTagName()); children.add(bep.parse(element, parserContext)); // if (element.getTagName().equalsIgnoreCase("ate:" // NOPMD // + XsdElementConstants.ELEMENT_HOMESTEP)) { // HomeStepBeanDefinitionParser homeStep = new HomeStepBeanDefinitionParser(); // children.add(homeStep.parse(element, parserContext)); // } else if (element.getTagName().equalsIgnoreCase("ate:" // + XsdElementConstants.ELEMENT_ELEMENTSTEP)) { // ElementStepBeanDefinitionParser elementStep = new ElementStepBeanDefinitionParser(); // children.add(elementStep.parse(element, parserContext)); // } else if (element.getTagName().equalsIgnoreCase("ate:" // + JavaCodedStep.XSD_ELEMENT_JAVACODEDSTEP)) { // BeanDefinitionParser javastep = new JavaCodedStep().getParser(); // children.add(javastep.parse(element, parserContext)); // } else if (element.getTagName().equalsIgnoreCase("ate:" // + XsdElementConstants.ELEMENT_REPEATSTEP)) { // RepeatStepBeanDefinitionParser repeatStep = new RepeatStepBeanDefinitionParser(); // children.add(repeatStep.parse(element, parserContext)); // } else if (element.getTagName().equalsIgnoreCase("ate:" // + XsdElementConstants.ELEMENT_LASTSTEP)) { // LastStepBeanDefinitionParser lastStep = new LastStepBeanDefinitionParser(); // children.add(lastStep.parse(element, parserContext)); // } else if (element.getTagName().equalsIgnoreCase("ate:" // + XsdElementConstants.ELEMENT_CASETYPESERVICE)) { // CaseTypeServiceBeanDefinitionParser caseService = new CaseTypeServiceBeanDefinitionParser(); // children.add(caseService.parse(element, parserContext)); // } else if (element // .getTagName() // .equalsIgnoreCase("ate:" // + XsdElementConstants.ELEMENT_STEPTYPESERVICEREFERENCE)) { // String stepServiceDefRef = element // .getAttribute(XsdElementConstants.ATTR_STEPTYPESERVICEREFERENCE_STEPTYPESERVICEDEFINITIONID); // if (StringUtils.isEmpty(stepServiceDefRef)) { // throw GlobalUtils // .createNotInitializedException("STEPTYPESERVICEDEFINITIONID"); // } else { // children.add(parserContext.getRegistry() // .getBeanDefinition(stepServiceDefRef)); // } // // } } factory.addPropertyValue( XsdElementConstants.PROP_TESTCASE_TESTSTEPLIST, children); } }
/** * Parses a <type-converters>. * * @param ele * @param parserContext */ protected void parseConvertersElement(Element ele, ParserContext parserContext) { BeanDefinitionParser parser = new TypeConverterBeanDefinitionParser(); parser.parse(ele, parserContext); }
/** * @return the parser for the XML elements with name "config" */ protected abstract BeanDefinitionParser getCacheProviderFacadeParser();
/** * Gets the parser. * * @return the parser */ BeanDefinitionParser getParser();
/** * Register name space handler. * * @param elementName the element name * @param parser the parser */ public static void registerNameSpaceHandler(String elementName, BeanDefinitionParser parser) { XsdNameSpaceParserRegistry.getNameSpaceHandlerRegistry().put( elementName, parser); }