View Javadoc

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