Package org.milyn.container

Examples of org.milyn.container.ExecutionContext


  /* (non-Javadoc)
   * @see org.milyn.javabean.lifecycle.BeanContextLifecycleObserver#onBeanLifecycleEvent(org.milyn.javabean.lifecycle.BeanContextLifecycleEvent)
   */
  public void onBeanLifecycleEvent(BeanContextLifecycleEvent event) {
    if(event.getBeanId() == watchedBean && event.getLifecycle() == BeanLifecycle.CHANGE) {
      ExecutionContext executionContext = event.getExecutionContext();

      // Set the array on the object, via the populator...
      populator.setPropertyValue(property, event.getBean(), executionContext, event.getSource());
      // Remove this observer...
      executionContext.getBeanContext().removeObserver(this);
    }
  }
View Full Code Here


      Object bean = event.getBean();
      if(!isMatchingBean(bean, watchedBeanType, watchedBeanAnnotation)) {
        return;
      }
     
      ExecutionContext executionContext = event.getExecutionContext();
      populator.populateAndSetPropertyValue(bean, executionContext.getBeanContext(), watchingBeanId, executionContext, event.getSource());
    } else if(beanId == watchingBeanId && lifecycle == BeanLifecycle.REMOVE) {
      BeanContext beanContext = event.getExecutionContext().getBeanContext();
     
      beanContext.removeObserver(this);
      // Need to remove the watched bean from the bean context too because it's lifecycle is associated
View Full Code Here

        AssertArgument.isNotNull(toType, "toType");

        assertInitialized();

        JavaResult javaResult = new JavaResult();
        ExecutionContext executionContext = smooks.createExecutionContext();

        if (reportPath != null) {
            executionContext.setEventListener(new HtmlReportGenerator(reportPath));
        }

        smooks.filterSource(executionContext, inputSource, javaResult);

        return javaResult.getBean(toType);
View Full Code Here

    public <T> Model<T> readModel(Reader message, Class<T> modelRoot) throws SAXException, IOException {
        AssertArgument.isNotNull(message, "message");
        AssertArgument.isNotNull(modelRoot, "modelRoot");

    JavaResult result = new JavaResult();
    ExecutionContext executionContext = descriptor.getSmooks().createExecutionContext();
        Map<Class<?>, Map<String, BeanWriter>> beanWriters = descriptor.getBeanWriters();
    BeanTracker beanTracker = new BeanTracker(beanWriters);

        if(reportPath != null) {
            executionContext.setEventListener(new HtmlReportGenerator(reportPath));           
        }

    executionContext.getBeanContext().addObserver(beanTracker);
   
    if(validate && descriptor.getSchema() != null) {
      // Validate the message against the schemas...
      Document messageDoc = toDocument(message);
View Full Code Here

public class MILYN_642_Test extends TestCase {
  // Default escape char
    public void test_01() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("MILYN_642/test-01-config.xml"));

        ExecutionContext context = smooks.createExecutionContext();
        String result = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("MILYN_642/test-01-data.csv"), smooks);

        assertEquals(
            "<csv-set><csv-record number=\"1\"><name>Erika Mustermann</name><email>e.m@ex.org</email></csv-record><csv-record number=\"2\"><name>Max \"The Man\" Mustermann</name><email>m.m@ex.org</email></csv-record></csv-set>",
            result);
View Full Code Here

  // Custom escape char, xml config
    public void test_02() throws SmooksException, IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("MILYN_642/test-02-config.xml"));

        ExecutionContext context = smooks.createExecutionContext();
        String result = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("MILYN_642/test-02-data.csv"), smooks);

        assertEquals(
            "<csv-set><csv-record number=\"1\"><name>Erika Mustermann</name><email>e.m@ex.org</email></csv-record><csv-record number=\"2\"><name>Max \"The Man\" Mustermann</name><email>m.m@ex.org</email></csv-record></csv-set>",
            result);
View Full Code Here

   
        smooks.setReaderConfig(
            new CSVRecordParserConfigurator("name,email")
                .setEscapeChar('~'));

        ExecutionContext context = smooks.createExecutionContext();
        String result = SmooksUtil.filterAndSerialize(context, getClass().getResourceAsStream("MILYN_642/test-02-data.csv"), smooks);
   
        assertEquals(
            "<csv-set><csv-record number=\"1\"><name>Erika Mustermann</name><email>e.m@ex.org</email></csv-record><csv-record number=\"2\"><name>Max \"The Man\" Mustermann</name><email>m.m@ex.org</email></csv-record></csv-set>",
            result);
View Full Code Here

    }

    public void testFreeMarkerTrans_bind(FilterSettings filterSettings) throws SAXException, IOException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test-configs-ext-04.cdrl"));
        StringReader input;
        ExecutionContext context;

        smooks.setFilterSettings(filterSettings);

        context = smooks.createExecutionContext();
        input = new StringReader("<a><b><c x='xvalueonc2' /></b></a>");
        smooks.filterSource(context, new StreamSource(input));

        assertEquals("<mybean>xvalueonc2</mybean>", context.getBeanContext().getBean("mybeanTemplate"));

        context = smooks.createExecutionContext();
        input = new StringReader("<c x='xvalueonc1' />");
        smooks.filterSource(context, new StreamSource(input), null);
        assertEquals("<mybean>xvalueonc1</mybean>", context.getBeanContext().getBean("mybeanTemplate"));
    }
View Full Code Here

                         "<mybean>xvalueonc1</mybean>");
    }

    public void test_outputTo_Stream() throws IOException, SAXException {
        Smooks smooks = new Smooks(getClass().getResourceAsStream("test-configs-ext-outputToOutStream.cdrl"));
        ExecutionContext context = smooks.createExecutionContext();

        MockOutStreamResource.outputStream = new ByteArrayOutputStream();
        smooks.filterSource(context, new StringSource("<a/>"), null);

        assertEquals("data to outstream", MockOutStreamResource.outputStream.toString());
View Full Code Here

        smooks.filterSource(new StringSource("<doc/>"), result);
        assertTrue(result.toString().length() > 10);
    }

    private void test_ftl(Smooks smooks, String input, String expected) throws IOException, SAXException {
        ExecutionContext context = smooks.createExecutionContext();
        test_ftl(smooks, context, input, expected);
    }
View Full Code Here

TOP

Related Classes of org.milyn.container.ExecutionContext

Copyright © 2018 www.massapicom. 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.