View Javadoc

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