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.lifecycle;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.MuleEventContext;
11  import org.mule.api.MuleException;
12  import org.mule.api.context.MuleContextAware;
13  import org.mule.api.lifecycle.Callable;
14  import org.mule.api.lifecycle.Startable;
15  import org.mule.api.lifecycle.Stoppable;
16  import org.mule.api.service.Service;
17  import org.mule.api.service.ServiceAware;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import javax.annotation.PostConstruct;
23  import javax.annotation.PreDestroy;
24  
25  public class JSR250LifecycleTrackerComponent implements Startable, Stoppable, MuleContextAware, ServiceAware, Callable
26  {
27  
28      private final List<String> tracker = new ArrayList<String>();
29  
30      public List<String> getTracker() {
31          return tracker;
32      }
33  
34      public void setProperty(final String value) {
35          tracker.add("setProperty");
36      }
37  
38      public void setMuleContext(final MuleContext context) {
39          tracker.add("setMuleContext");
40      }
41  
42      @PostConstruct
43      public void initialise() {
44          tracker.add("jsr250 initialise");
45      }
46  
47      @PreDestroy
48      public void dispose() {
49          tracker.add("jsr250 dispose");
50      }
51  
52      public void start() throws MuleException {
53          tracker.add("start");
54      }
55  
56      public void stop() throws MuleException {
57          tracker.add("stop");
58      }
59  
60      public void setService(final Service service)
61      {
62          getTracker().add("setService");
63      }
64  
65      public Object onCall(final MuleEventContext eventContext) throws Exception {
66          // dirty trick to get the component instance that was used for the
67          // request
68          return this;
69      }
70  }