Examples of SmooksResourceConfiguration


Examples of org.milyn.cdr.SmooksResourceConfiguration

  }

  public void test_caching() throws IOException, SAXException {
    byte[] input = StreamUtils.readStream(getClass().getResourceAsStream("edi-input.txt"));
    Smooks smooks = new Smooks();
    SmooksResourceConfiguration config = null;

    // Create and initialise the Smooks config for the parser...
    config = new SmooksResourceConfiguration();
        config.setResource(EDIReader.class.getName());
    // Set the mapping config on the resource config...
        config.setParameter(EDIReader.MODEL_CONFIG_KEY, TEST_XML_MAPPING_XML_URI);

    DOMParser parser;

    // Create 1st parser using the config, and run a parse through it...
    parser = new DOMParser(smooks.createExecutionContext(), config);
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    private void test_import(String mapping) throws IOException, SAXException {
    InputStream input = new ByteArrayInputStream(StreamUtils.readStream(getClass().getResourceAsStream("definitionTest/edi-input.txt")));
    String expected = new String(StreamUtils.readStream(getClass().getResourceAsStream("definitionTest/expected.xml")));
    Smooks smooks = new Smooks();
    SmooksResourceConfiguration config = null;

    // Create and initialise the Smooks config for the parser...
        config = new SmooksResourceConfiguration();
        config.setResource(EDIReader.class.getName());
    // Set the mapping config on the resource config...
    if(mapping != null) {
      config.setParameter(EDIReader.MODEL_CONFIG_KEY, mapping);
    }

    DOMParser parser = new DOMParser(smooks.createExecutionContext(), config);
    Document doc = parser.parse(new StreamSource(input));
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    private void test_cyclic_dependency(String mapping) throws IOException, SAXException {
    InputStream input = new ByteArrayInputStream(StreamUtils.readStream(getClass().getResourceAsStream("cyclicDependencyTest/edi-input.txt")));

    Smooks smooks = new Smooks();
    SmooksResourceConfiguration config = null;

    // Create and initialise the Smooks config for the parser...
        config = new SmooksResourceConfiguration();
        config.setResource(EDIReader.class.getName());
    // Set the mapping config on the resource config...
    if(mapping != null) {
      config.setParameter(EDIReader.MODEL_CONFIG_KEY, mapping);
    }

    DOMParser parser = new DOMParser(smooks.createExecutionContext(), config);
        try {
            parser.parse(new StreamSource(input));
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

  public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
    String initValExpression = DomUtils.getAttributeValue(element, initValAttrib);
   
    if(initValExpression != null) {
          ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext);
          SmooksResourceConfiguration creatorConfig = extensionContext.getResourceByName(BeanInstanceCreator.class.getName());
      String propertyName = DomUtils.getAttributeValue(element, "property");
         
      creatorConfig.setParameter(BeanInstanceCreator.INIT_VAL_EXPRESSION, "this." + propertyName + " = (" + initValExpression + ");");
    }
  }
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    test_goodscript_by_URI("/org/milyn/smooks/scripting/groovy/MyGroovyScript.groovy");
  }

  public void test_goodscript_by_Inlining() throws InstantiationException, IllegalArgumentException, IOException, SAXException {
    String script = new String(StreamUtils.readStream(getClass().getResourceAsStream("MyGroovyScript.groovy")));
    SmooksResourceConfiguration config = new SmooksResourceConfiguration("x", null);
   
    config.setParameter("resdata", script);
    test_goodscript(config);
  }
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    config.setParameter("resdata", script);
    test_goodscript(config);
  }
 
  private void test_goodscript_by_URI(String path) throws InstantiationException, IllegalArgumentException, IOException, SAXException {
    test_goodscript(new SmooksResourceConfiguration("x", path));
  }
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    @ConfigParam
    private String selectorAttrName;

    public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
        ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext);
        SmooksResourceConfiguration config = extensionContext.getResourceStack().peek();

        if(config.getSelector() == null || config.getSelector().equals("none")) {
            Parameter beanIdParam = config.getParameter("beanId");
            String beanId = beanIdParam.getValue();

            SmooksResourceConfiguration beanCreatorConfig = findBeanCreatorConfig(beanId, extensionContext);

            if(beanCreatorConfig == null) {
                throw new SmooksConfigurationException("No <jb:wiring> configurations is found yet for beanId '" + beanId + "'. " +
                        "This can mean that no <jb:wiring> is present that wires the bean with the bean id or that it is configured after the <" + element.getNodeName() + ">. " +
                         "In this case you must set the selector in the '" + selectorAttrName + "' attribute.");
            } else {
                config.setSelector(beanCreatorConfig.getSelector());
            }
        }
    }
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    @ConfigParam
    private String selectorAttrName;

    public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
        ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext);
        SmooksResourceConfiguration config = extensionContext.getResourceStack().peek();

        if(config.getSelector() == null || config.getSelector().equals("none")) {
            Parameter beanIdParam = config.getParameter("beanId");
            String beanId = beanIdParam.getValue();

            SmooksResourceConfiguration beanCreatorConfig = findBeanCreatorConfig(beanId, extensionContext);

            if(beanCreatorConfig == null) {
                throw new SmooksConfigurationException("No <jb:bean> configurations is found yet for beanId '" + beanId + "'. " +
                        "This can mean that no <jb:bean> is present that creates the bean with the bean id or that it is configured after the <" + element.getNodeName() + ">. " +
                         "In this case you must set the selector in the '" + selectorAttrName + "' attribute.");
            } else {
                config.setSelector(beanCreatorConfig.getSelector());
            }
        }
    }
View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

  /* (non-Javadoc)
   * @see org.milyn.delivery.dom.DOMVisitBefore#visitBefore(org.w3c.dom.Element, org.milyn.container.ExecutionContext)
   */
  public void visitBefore(Element element, ExecutionContext executionContextthrows SmooksException {

    SmooksResourceConfiguration config = ExtensionContext.getExtensionContext(executionContext).getResourceStack().peek();

    Integer index = (Integer) executionContext.getAttribute(ParameterIndexInitializer.PARAMETER_INDEX);

    ResourceConfigUtil.setProperty(config, "index", Integer.toString(index), executionContext);

View Full Code Here

Examples of org.milyn.cdr.SmooksResourceConfiguration

    public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
        NodeList decodeParams = element.getElementsByTagNameNS(Constants.PERSISTENCE_NAMESPACE, "decodeParam");

        if(decodeParams.getLength() > 0) {
            ExtensionContext extensionContext = ExtensionContext.getExtensionContext(executionContext);
            SmooksResourceConfiguration populatorConfig = extensionContext.getResourceStack().peek();
            SmooksResourceConfiguration decoderConfig = new SmooksResourceConfiguration();

            extensionContext.addResource(decoderConfig);
            try {
                String type = populatorConfig.getStringParameter("type");
                DataDecoder decoder = DataDecoder.Factory.create(type);
                String reType = UUID.randomUUID().toString();

                // Need to retype the populator configuration so as to get the
                // value binding BeanInstancePopulator to lookup the new decoder
                // config that we're creating here...
                populatorConfig.removeParameter("type"); // Need to remove because we only want 1
                populatorConfig.setParameter("type", reType);

                // Configure the new decoder config...
                decoderConfig.setSelector("decoder:" + reType);
                decoderConfig.setTargetProfile(extensionContext.getDefaultProfile());
                decoderConfig.setResource(decoder.getClass().getName());
                for(int i = 0; i < decodeParams.getLength(); i++) {
                    Element decoderParam = (Element) decodeParams.item(i);
                    decoderConfig.setParameter(decoderParam.getAttribute("name"), DomUtils.getAllText(decoderParam, true));
                }
            } finally {
                extensionContext.getResourceStack().pop();
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.