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