Examples of JavaResult


Examples of org.milyn.payload.JavaResult

      System.out.println("Parsing [" + fileName + "]");
      Smooks smooks = new Smooks("config-samples/ec2-demo/smooks-config.xml");

      FileInputStream inputStream = null;
      try {
         JavaResult result = new JavaResult();
         inputStream = new FileInputStream(fileName.trim());
         smooks.filterSource(new StreamSource(inputStream), result);
         return (List<Nucleotide_Protein_Element>) result.getBean("customerList");
      } finally {
         smooks.close();
         Util.close(inputStream);
      }
   }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    public void receive(Object object,
                       PipelineContext context) {
        this.smooks.setClassLoader( context.getClassLoader() );
        Object result = null;
        try {
            JavaResult javaResult = new JavaResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            Source source = null;
            if ( object instanceof Source ) {
                source = ( Source ) object;
            } else if ( object instanceof InputStream ) {
                source =  new StreamSource( ( InputStream ) object );
            } else if ( object instanceof Reader ) {
                source =  new StreamSource( ( Reader ) object );
            } else if ( object instanceof Resource ) {
                source =  new StreamSource( ( ( Resource ) object).getReader() );
            } else if ( object instanceof String ) {
                source =  new StringSource( (String) object);
            } else {
                throw new IllegalArgumentException( "signal object must be instance of Source, InputStream, Reader, Resource or String" );
            }
           
            this.smooks.filter( source,
                                javaResult,
                                executionContext );
           
            result = javaResult.getBean( this.configuration.getRootId() );
        } catch ( Exception e ) {
            handleException( this,
                             object,
                             e );
        }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    public void receive(Object object,
                       PipelineContext context) {
        this.smooks.setClassLoader( context.getClassLoader() );
        Object result = null;
        try {
            JavaResult javaResult = new JavaResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            Source source = null;
            if ( object instanceof Source ) {
                source = ( Source ) object;
            } else if ( object instanceof InputStream ) {               
                source =  new StreamSource( ( InputStream ) object );
            } else if ( object instanceof Reader ) {               
                source =  new StreamSource( ( Reader ) object );
            } else if ( object instanceof Resource ) {               
                source =  new StreamSource( ( ( Resource ) object).getReader() );
            } else if ( object instanceof String ) {                
                source =  new StringSource( (String) object);
            } else {
                throw new IllegalArgumentException( "signal object must be instance of Source, InputStream, Reader, Resource or String" );
            }
           
            this.smooks.filter( source,
                                javaResult,
                                executionContext );           
           
            result = javaResult.getBean( this.configuration.getRootId() );
        } catch ( Exception e ) {
            handleException( this,
                             object,
                             e );
        }
View Full Code Here

Examples of org.milyn.payload.JavaResult

      System.out.println("Parsing [" + fileName + "]");
      Smooks smooks = new Smooks("config-samples/ec2-demo/smooks-config.xml");

      FileInputStream inputStream = null;
      try {
         JavaResult result = new JavaResult();
         inputStream = new FileInputStream(fileName.trim());
         smooks.filterSource(new StreamSource(inputStream), result);
         return (List<Nucleotide_Protein_Element>) result.getBean("customerList");
      } finally {
         smooks.close();
         Util.close(inputStream);
      }
   }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    public void receive(Object object,
                       PipelineContext context) {
        this.smooks.setClassLoader( context.getClassLoader() );
        Object result = null;
        try {
            JavaResult javaResult = new JavaResult();
            ExecutionContext executionContext = this.smooks.createExecutionContext();

            Source source = null;
            if ( object instanceof Source ) {
                source = ( Source ) object;
            } else if ( object instanceof InputStream ) {               
                source =  new StreamSource( ( InputStream ) object );
            } else if ( object instanceof Reader ) {               
                source =  new StreamSource( ( Reader ) object );
            } else if ( object instanceof Resource ) {               
                source =  new StreamSource( ( ( Resource ) object).getReader() );
            } else if ( object instanceof String ) {                
                source =  new StringSource( (String) object);
            } else {
                throw new IllegalArgumentException( "signal object must be instance of Source, InputStream, Reader, Resource or String" );
            }
           
            this.smooks.filter( source,
                                javaResult,
                                executionContext );           
           
            result = javaResult.getBean( this.configuration.getRootId() );
        } catch ( Exception e ) {
            handleException( this,
                             object,
                             e );
        }
View Full Code Here

Examples of org.milyn.payload.JavaResult

   public List<Nucleotide_Protein_Element> parseFile(String fileName) throws IOException, SAXException {
      System.out.println("Parsing [" + fileName + "]");
      Smooks smooks = new Smooks("config-samples/ec2-demo/smooks-config.xml");

      try {
         JavaResult result = new JavaResult();
         smooks.filterSource(new StreamSource(new FileInputStream(fileName.trim())), result);
         return (List<Nucleotide_Protein_Element>) result.getBean("customerList");
      } finally {
         smooks.close();
      }
   }
View Full Code Here

Examples of org.milyn.payload.JavaResult

                      messageFilter.doFilter();
                    } finally {
                        try {
                            // We want to make sure that all the beans from the BeanContext are available in the
                            // JavaResult, if one is supplied by the user...
                            JavaResult javaResult = (JavaResult) FilterResult.getResult(executionContext, JavaResult.class);
                            if(javaResult != null) {
                                javaResult.getResultMap().putAll(executionContext.getBeanContext().getBeanMap());
                            }

                            // Remove the pre-installed beans...
                            beanContext.removeBean(Time.BEAN_ID, null);
                            beanContext.removeBean(UniqueID.BEAN_ID, null);
View Full Code Here

Examples of org.milyn.payload.JavaResult

public class NestedExecutionVisitorTest extends TestCase {

    public void test() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("config-01.xml"));
        StringResult result = new StringResult();
        JavaResult beans = new JavaResult();
        final List<String> orderItems = new ArrayList<String>();

        smooks.getApplicationContext().addBeanContextLifecycleObserver(new BeanContextLifecycleObserver() {
            public void onBeanLifecycleEvent(BeanContextLifecycleEvent event) {
                if(event.getLifecycle() == BeanLifecycle.REMOVE && event.getBeanId().getName().equals("orderItem")) {
                    orderItems.add((String) event.getBean());
                }
            }
        });

        smooks.filterSource(new StreamSource(getClass().getResourceAsStream("order-message.xml")), result, beans);

        XMLUnit.setIgnoreWhitespace(true);
        XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream("order-message.xml")), new StringReader(result.toString()));

        assertEquals("header", beans.getBean("header"));
        assertEquals("trailer", beans.getBean("trailer"));
        assertEquals(2, orderItems.size());
    }
View Full Code Here

Examples of org.milyn.payload.JavaResult

    Result result = FilterResult.getResult(executionContext, JavaResult.class);
    Source source = FilterSource.getSource(executionContext);
    Map<String, Object> beanMap = null;

    if(result != null) {
        JavaResult javaResult = (JavaResult) result;
        beanMap = javaResult.getResultMap();
    }

    if(source instanceof JavaSource) {
        JavaSource javaSource = (JavaSource) source;
        Map<String, Object> sourceBeans = javaSource.getBeans();
View Full Code Here

Examples of org.milyn.payload.JavaResult

  public void test() {

    ExecutionContext context = new MockExecutionContext();

    JavaResult dummyResult = new JavaResult(true);

    FilterResult.setResults(context, dummyResult);

    context.getBeanContext().addBean("string", "blaat", null);
    context.getBeanContext().addBean("emptyMap", Collections.emptyMap(), null);
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.