View Javadoc

1   /*
2    * $Id: LifecycleTrackerTransformer.java 20320 2010-11-24 15:03:31Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.test.integration.transformer;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.MuleException;
14  import org.mule.api.context.MuleContextAware;
15  import org.mule.api.lifecycle.InitialisationException;
16  import org.mule.api.lifecycle.Lifecycle;
17  import org.mule.api.transformer.TransformerException;
18  import org.mule.transformer.AbstractTransformer;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  public class LifecycleTrackerTransformer extends AbstractTransformer implements Lifecycle, MuleContextAware
24  {
25  
26      private final List<String> tracker = new ArrayList<String>();
27  
28      public List<String> getTracker()
29      {
30          return tracker;
31      }
32  
33      public void setProperty(final String value)
34      {
35          tracker.add("setProperty");
36      }
37  
38      public void setMuleContext(final MuleContext context)
39      {
40          tracker.add("setMuleContext");
41      }
42  
43  
44      @Override
45      public void initialise() throws InitialisationException
46      {
47          tracker.add("initialise");
48      }
49  
50      public void start() throws MuleException
51      {
52          tracker.add("start");
53      }
54  
55      public void stop() throws MuleException
56      {
57          tracker.add("stop");
58      }
59  
60      public void dispose()
61      {
62          tracker.add("dispose");
63      }
64  
65      @Override
66      protected Object doTransform(final Object src, final String encoding)
67              throws TransformerException
68      {
69  
70          // dirty trick to get the transformer instance that was used for the
71          // request
72          return this;
73      }
74  
75  }
76