View Javadoc

1   /*
2    * $Id: MuleApplicationEvent.java 7963 2007-08-21 08:53:15Z 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  
11  package org.mule.extras.spring.events;
12  
13  import org.mule.umo.UMOEventContext;
14  import org.mule.umo.endpoint.MalformedEndpointException;
15  
16  import java.util.Collections;
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import org.springframework.context.ApplicationContext;
21  import org.springframework.context.ApplicationEvent;
22  
23  /**
24   * <code>MuleApplicationEvent</code> is an Spring ApplicationEvent used to wrap a
25   * MuleEvent
26   */
27  
28  public class MuleApplicationEvent extends ApplicationEvent
29  {
30      /**
31       * Serial version
32       */
33      private static final long serialVersionUID = 5297176859050194632L;
34  
35      private final UMOEventContext context;
36      private final String endpoint;
37      private final ApplicationContext applicationContext;
38      private final Map properties = Collections.synchronizedMap(new HashMap());
39  
40      public MuleApplicationEvent(Object message, String endpoint)
41      {
42          super(message);
43          this.endpoint = endpoint;
44          this.applicationContext = null;
45          this.context = null;
46      }
47  
48      MuleApplicationEvent(Object message, UMOEventContext context, ApplicationContext appContext)
49          throws MalformedEndpointException
50      {
51          super(message);
52          this.context = context;
53          this.endpoint = context.getEndpointURI().toString();
54          this.applicationContext = appContext;
55      }
56  
57      public UMOEventContext getMuleEventContext()
58      {
59          return context;
60      }
61  
62      public String getEndpoint()
63      {
64          return endpoint;
65      }
66  
67      public ApplicationContext getApplicationContext()
68      {
69          return applicationContext;
70      }
71  
72      public Map getProperties()
73      {
74          return properties;
75      }
76  
77      public void setProperty(Object key, Object value)
78      {
79          this.properties.put(key, value);
80      }
81  
82      public Object getProperty(Object key)
83      {
84          return properties.get(key);
85      }
86  
87  }