View Javadoc

1   /*
2    * $Id: LifecycleObject.java 11530 2008-04-08 12:49:14Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.lifecycle;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.context.notification.ServerNotification;
14  import org.mule.util.ClassUtils;
15  
16  public class LifecycleObject
17  {
18      
19      private Class type;
20      private ServerNotification preNotification;
21      private ServerNotification postNotification;
22  
23      public LifecycleObject(Class type)
24      {
25          this.type = type;
26      }
27  
28      public ServerNotification getPostNotification()
29      {
30          return postNotification;
31      }
32  
33      public void setPostNotification(ServerNotification postNotification)
34      {
35          this.postNotification = postNotification;
36      }
37  
38      public ServerNotification getPreNotification()
39      {
40          return preNotification;
41      }
42  
43      public void setPreNotification(ServerNotification preNotification)
44      {
45          this.preNotification = preNotification;
46      }
47  
48      public Class getType()
49      {
50          return type;
51      }
52  
53      public void setType(Class type)
54      {
55          this.type = type;
56      }
57  
58      public void firePreNotification(MuleContext context)
59      {
60          if(preNotification!=null)
61          {
62              context.fireNotification(preNotification);
63          }
64      }
65  
66      public void firePostNotification(MuleContext context)
67      {
68          if(postNotification!=null)
69          {
70              context.fireNotification(postNotification);
71          }
72      }
73  
74      // @Override
75      public String toString()
76      {
77          return super.toString() + " (" + ClassUtils.getSimpleName(type) + ")";
78      }
79          
80  }