/** * Create a {@link Properties} instance from this supplied {@link org.milyn.cdr.SmooksResourceConfiguration} * @return The resource parameters as a {@link Properties} instance. */ public Properties toProperties() { Properties properties = new Properties(); Set<String> names = parameters.keySet(); for(String name : names) { properties.setProperty(name, getStringParameter(name)); } return properties; }
/** * Create a {@link Properties} instance from this supplied {@link org.milyn.cdr.SmooksResourceConfiguration} * @return The resource parameters as a {@link Properties} instance. */ public Properties toProperties() { Properties properties = new Properties(); Set<String> names = parameters.keySet(); for(String name : names) { properties.setProperty(name, getStringParameter(name)); } return properties; }
/** * Create a {@link Properties} instance from this supplied {@link org.milyn.cdr.SmooksResourceConfiguration} * @return The resource parameters as a {@link Properties} instance. */ public Properties toProperties() { Properties properties = new Properties(); Set<String> names = parameters.keySet(); for(String name : names) { properties.setProperty(name, getStringParameter(name)); } return properties; }
/** * Create a {@link Properties} instance from this supplied {@link org.milyn.cdr.SmooksResourceConfiguration} * @return The resource parameters as a {@link Properties} instance. */ public Properties toProperties() { Properties properties = new Properties(); Set<String> names = parameters.keySet(); for(String name : names) { properties.setProperty(name, getStringParameter(name)); } return properties; }
/** * Public constructor. * @param resourceConfig Configuration. */ public void setConfiguration(SmooksResourceConfiguration resourceConfig) { delims = resourceConfig.getStringParameter("delims", ","); returnDelims = resourceConfig.getBoolParameter("returnDelims", false); trimTokens = resourceConfig.getBoolParameter("trimTokens", true); String paramType = resourceConfig.getStringParameter(Parameter.PARAM_TYPE_PREFIX, "string-list"); if(paramType.equals("string-list")) { returnType = Vector.class; } else if(paramType.equals("string-hashset")) { returnType = LinkedHashSet.class; } else { throw new ParameterDecodeException("Unsupported decoded return type [" + paramType + "]"); } }
/** * Public constructor. * @param resourceConfig Configuration. */ public void setConfiguration(SmooksResourceConfiguration resourceConfig) { delims = resourceConfig.getStringParameter("delims", ","); returnDelims = resourceConfig.getBoolParameter("returnDelims", false); trimTokens = resourceConfig.getBoolParameter("trimTokens", true); String paramType = resourceConfig.getStringParameter(Parameter.PARAM_TYPE_PREFIX, "string-list"); if(paramType.equals("string-list")) { returnType = Vector.class; } else if(paramType.equals("string-hashset")) { returnType = LinkedHashSet.class; } else { throw new ParameterDecodeException("Unsupported decoded return type [" + paramType + "]"); } }
/** * Public constructor. * @param resourceConfig Configuration. */ public void setConfiguration(SmooksResourceConfiguration resourceConfig) { delims = resourceConfig.getStringParameter("delims", ","); returnDelims = resourceConfig.getBoolParameter("returnDelims", false); trimTokens = resourceConfig.getBoolParameter("trimTokens", true); String paramType = resourceConfig.getStringParameter(Parameter.PARAM_TYPE_PREFIX, "string-list"); if(paramType.equals("string-list")) { returnType = Vector.class; } else if(paramType.equals("string-hashset")) { returnType = LinkedHashSet.class; } else { throw new ParameterDecodeException("Unsupported decoded return type [" + paramType + "]"); } }
/** * Public constructor. * @param resourceConfig Configuration. */ public void setConfiguration(SmooksResourceConfiguration resourceConfig) { delims = resourceConfig.getStringParameter("delims", ","); returnDelims = resourceConfig.getBoolParameter("returnDelims", false); trimTokens = resourceConfig.getBoolParameter("trimTokens", true); String paramType = resourceConfig.getStringParameter(Parameter.PARAM_TYPE_PREFIX, "string-list"); if(paramType.equals("string-list")) { returnType = Vector.class; } else if(paramType.equals("string-hashset")) { returnType = LinkedHashSet.class; } else { throw new ParameterDecodeException("Unsupported decoded return type [" + paramType + "]"); } }
public static DocumentTypeData getDocType(ExecutionContext executionContext) { List<SmooksResourceConfiguration> docTypeUDs = executionContext.getDeliveryConfig().getSmooksResourceConfigurations("doctype"); SmooksResourceConfiguration docTypeSmooksResourceConfiguration = null; if(docTypeUDs != null && docTypeUDs.size() > 0) { docTypeSmooksResourceConfiguration = docTypeUDs.get(0); } // Only use the cdrdef if the override flag is set. The override flag will // cause this DOCTYPE to override any DOCYTPE decl from the source doc. if(docTypeSmooksResourceConfiguration != null && docTypeSmooksResourceConfiguration.getBoolParameter("override", true)) { String name = docTypeSmooksResourceConfiguration.getStringParameter("name", "!!DOCTYPE name undefined - fix smooks-resource!!"); String publicId = docTypeSmooksResourceConfiguration.getStringParameter("publicId", "!!DOCTYPE publicId undefined - fix smooks-resource!!"); String systemId = docTypeSmooksResourceConfiguration.getStringParameter("systemId", "!!DOCTYPE systemId undefined - fix smooks-resource!!"); String xmlns = docTypeSmooksResourceConfiguration.getStringParameter("xmlns"); boolean omit = docTypeSmooksResourceConfiguration.getBoolParameter("omit", false); return new DocumentTypeData(name, publicId, systemId, xmlns, omit); } return (DocumentTypeData) executionContext.getAttribute(DOCTYPE_KEY); }
public static DocumentTypeData getDocType(ExecutionContext executionContext) { List<SmooksResourceConfiguration> docTypeUDs = executionContext.getDeliveryConfig().getSmooksResourceConfigurations("doctype"); SmooksResourceConfiguration docTypeSmooksResourceConfiguration = null; if(docTypeUDs != null && docTypeUDs.size() > 0) { docTypeSmooksResourceConfiguration = docTypeUDs.get(0); } // Only use the cdrdef if the override flag is set. The override flag will // cause this DOCTYPE to override any DOCYTPE decl from the source doc. if(docTypeSmooksResourceConfiguration != null && docTypeSmooksResourceConfiguration.getBoolParameter("override", true)) { String name = docTypeSmooksResourceConfiguration.getStringParameter("name", "!!DOCTYPE name undefined - fix smooks-resource!!"); String publicId = docTypeSmooksResourceConfiguration.getStringParameter("publicId", "!!DOCTYPE publicId undefined - fix smooks-resource!!"); String systemId = docTypeSmooksResourceConfiguration.getStringParameter("systemId", "!!DOCTYPE systemId undefined - fix smooks-resource!!"); String xmlns = docTypeSmooksResourceConfiguration.getStringParameter("xmlns"); boolean omit = docTypeSmooksResourceConfiguration.getBoolParameter("omit", false); return new DocumentTypeData(name, publicId, systemId, xmlns, omit); } return (DocumentTypeData) executionContext.getAttribute(DOCTYPE_KEY); }
public static DocumentTypeData getDocType(ExecutionContext executionContext) { List<SmooksResourceConfiguration> docTypeUDs = executionContext.getDeliveryConfig().getSmooksResourceConfigurations("doctype"); SmooksResourceConfiguration docTypeSmooksResourceConfiguration = null; if(docTypeUDs != null && docTypeUDs.size() > 0) { docTypeSmooksResourceConfiguration = docTypeUDs.get(0); } // Only use the cdrdef if the override flag is set. The override flag will // cause this DOCTYPE to override any DOCYTPE decl from the source doc. if(docTypeSmooksResourceConfiguration != null && docTypeSmooksResourceConfiguration.getBoolParameter("override", true)) { String name = docTypeSmooksResourceConfiguration.getStringParameter("name", "!!DOCTYPE name undefined - fix smooks-resource!!"); String publicId = docTypeSmooksResourceConfiguration.getStringParameter("publicId", "!!DOCTYPE publicId undefined - fix smooks-resource!!"); String systemId = docTypeSmooksResourceConfiguration.getStringParameter("systemId", "!!DOCTYPE systemId undefined - fix smooks-resource!!"); String xmlns = docTypeSmooksResourceConfiguration.getStringParameter("xmlns"); boolean omit = docTypeSmooksResourceConfiguration.getBoolParameter("omit", false); return new DocumentTypeData(name, publicId, systemId, xmlns, omit); } return (DocumentTypeData) executionContext.getAttribute(DOCTYPE_KEY); }
public static DocumentTypeData getDocType(ExecutionContext executionContext) { List<SmooksResourceConfiguration> docTypeUDs = executionContext.getDeliveryConfig().getSmooksResourceConfigurations("doctype"); SmooksResourceConfiguration docTypeSmooksResourceConfiguration = null; if(docTypeUDs != null && docTypeUDs.size() > 0) { docTypeSmooksResourceConfiguration = docTypeUDs.get(0); } // Only use the cdrdef if the override flag is set. The override flag will // cause this DOCTYPE to override any DOCYTPE decl from the source doc. if(docTypeSmooksResourceConfiguration != null && docTypeSmooksResourceConfiguration.getBoolParameter("override", true)) { String name = docTypeSmooksResourceConfiguration.getStringParameter("name", "!!DOCTYPE name undefined - fix smooks-resource!!"); String publicId = docTypeSmooksResourceConfiguration.getStringParameter("publicId", "!!DOCTYPE publicId undefined - fix smooks-resource!!"); String systemId = docTypeSmooksResourceConfiguration.getStringParameter("systemId", "!!DOCTYPE systemId undefined - fix smooks-resource!!"); String xmlns = docTypeSmooksResourceConfiguration.getStringParameter("xmlns"); boolean omit = docTypeSmooksResourceConfiguration.getBoolParameter("omit", false); return new DocumentTypeData(name, publicId, systemId, xmlns, omit); } return (DocumentTypeData) executionContext.getAttribute(DOCTYPE_KEY); }
public String getResourceType() { String restype; if (isJavaResource()) { return "class"; } restype = getStringParameter(PARAM_RESTYPE); if (restype != null && !restype.trim().equals("")) { // Ala DTD v1.0, where we weren't able to specify the type in any other way. if (getParameter(PARAM_RESDATA) == null) { logger.debug("Resource configuration defined with '" + PARAM_RESTYPE + "' parameter but no '" + PARAM_RESDATA + "' parameter."); } } else if (resourceType != null) { // Ala DTD v2.0, where the type is set through the "type" attribute on the <resource> element. restype = resourceType; } else { restype = getExtension(getResource()); } return restype; }
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { // The current config on the stack must be <dmb:writer>... ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); SmooksResourceConfiguration dmbWriterConfig = extensionContext.getResourceStack().peek(); if(dmbWriterConfig.getStringParameter("beanClass") == null) { String beanId = dmbWriterConfig.getStringParameter("beanId"); if(beanId == null) { throw new SmooksConfigurationException("One of the 'beanClass' or 'beanId' attributes must be configured on the <dmb:writer> configuration."); } SmooksResourceConfiguration beanCreatorConfig = BeanConfigUtil.findBeanCreatorConfig(beanId, executionContext); if(beanCreatorConfig == null) { throw new SmooksConfigurationException("Cannot find <jb:bean> configuration for beanId '" + beanId + "' for <dmb:writer>. Reordered <dmb:writer> after <jb:bean> config."); } String beanClass = beanCreatorConfig.getStringParameter(BeanConfigUtil.BEAN_CLASS_CONFIG); if(beanClass == null) { throw new SmooksConfigurationException("Cannot create find BeanWriter for beanId '" + beanId + "'. The associated <jb:bean> configuration does not define a bean Class name."); } dmbWriterConfig.setParameter(BeanConfigUtil.BEAN_CLASS_CONFIG, beanClass); } } }
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); // The current config on the stack must be a <jb:bean>... SmooksResourceConfiguration beanConfig = (SmooksResourceConfiguration) extensionContext.getResourceStack().peek(); String retain = beanConfig.getStringParameter("retain"); // If the "retain" attribute is not configured we configure it. If // this is the first bean config, we set it to "true" (i.e. retain it), // otherwise set it to "false" (i.e. do not retain it)... if(retain == null) { List<SmooksResourceConfiguration> creatorConfigs = extensionContext.lookupResource(new ConfigSearch().resource(BeanInstanceCreator.class.getName())); if(!creatorConfigs.isEmpty()) { // This is not the first bean config... set retain to "false" beanConfig.setParameter("retain", "false"); } } } }
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); // The current config on the stack must be a <jb:bean>... SmooksResourceConfiguration beanConfig = (SmooksResourceConfiguration) extensionContext.getResourceStack().peek(); String retain = beanConfig.getStringParameter("retain"); // If the "retain" attribute is not configured we configure it. If // this is the first bean config, we set it to "true" (i.e. retain it), // otherwise set it to "false" (i.e. do not retain it)... if(retain == null) { List<SmooksResourceConfiguration> creatorConfigs = extensionContext.lookupResource(new ConfigSearch().resource(BeanInstanceCreator.class.getName())); if(!creatorConfigs.isEmpty()) { // This is not the first bean config... set retain to "false" beanConfig.setParameter("retain", "false"); } } } }
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext); // The current config on the stack must be a <jb:bean>... SmooksResourceConfiguration beanConfig = (SmooksResourceConfiguration) extensionContext.getResourceStack().peek(); String retain = beanConfig.getStringParameter("retain"); // If the "retain" attribute is not configured we configure it. If // this is the first bean config, we set it to "true" (i.e. retain it), // otherwise set it to "false" (i.e. do not retain it)... if(retain == null) { List<SmooksResourceConfiguration> creatorConfigs = extensionContext.lookupResource(new ConfigSearch().resource(BeanInstanceCreator.class.getName())); if(!creatorConfigs.isEmpty()) { // This is not the first bean config... set retain to "false" beanConfig.setParameter("retain", "false"); } } } }
/** * Used by Smooks to retrieve the visitor configuration of this Value Configuration */ public void addVisitors(VisitorConfigMap visitorMap) { ValueBinder binder = new ValueBinder(getBeanId()); SmooksResourceConfiguration populatorConfig = new SmooksResourceConfiguration(dataSelector); SelectorPropertyResolver.resolveSelectorTokens(populatorConfig); binder.setDecoder(decoder); binder.setDefaultValue(defaultValue); binder.setValueAttributeName(populatorConfig.getStringParameter(BeanInstancePopulator.VALUE_ATTRIBUTE_NAME)); visitorMap.addVisitor(binder, populatorConfig.getSelector(), targetNamespace, true); }
/** * Used by Smooks to retrieve the visitor configuration of this Value Configuration */ public void addVisitors(VisitorConfigMap visitorMap) { ValueBinder binder = new ValueBinder(getBeanId()); SmooksResourceConfiguration populatorConfig = new SmooksResourceConfiguration(dataSelector); SelectorPropertyResolver.resolveSelectorTokens(populatorConfig); binder.setDecoder(decoder); binder.setDefaultValue(defaultValue); binder.setValueAttributeName(populatorConfig.getStringParameter(BeanInstancePopulator.VALUE_ATTRIBUTE_NAME)); visitorMap.addVisitor(binder, populatorConfig.getSelector(), targetNamespace, true); }
/** * Used by Smooks to retrieve the visitor configuration of this Value Configuration */ public void addVisitors(VisitorConfigMap visitorMap) { ValueBinder binder = new ValueBinder(getBeanId()); SmooksResourceConfiguration populatorConfig = new SmooksResourceConfiguration(dataSelector); SelectorPropertyResolver.resolveSelectorTokens(populatorConfig); binder.setDecoder(decoder); binder.setDefaultValue(defaultValue); binder.setValueAttributeName(populatorConfig.getStringParameter(BeanInstancePopulator.VALUE_ATTRIBUTE_NAME)); visitorMap.addVisitor(binder, populatorConfig.getSelector(), targetNamespace, true); }