View Javadoc

1   /*
2      Copyright 2008 Ramon Servadei
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of the License at
7   
8          http://www.apache.org/licenses/LICENSE-2.0
9   
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15   */
16  package fulmine.model.container.events;
17  
18  import static fulmine.util.Utils.nullCheck;
19  import fulmine.IAddressable;
20  import fulmine.event.IEventManager;
21  import fulmine.event.IEventSource;
22  import fulmine.event.system.AbstractSystemEvent;
23  import fulmine.event.system.ISystemEvent;
24  import fulmine.event.system.ISystemEventListener;
25  import fulmine.model.container.IContainer;
26  
27  /**
28   * Raised when a remote {@link IContainer} has been destroyed. This generally
29   * occurs when the container in the remote context is destroyed.
30   * <p>
31   * This is an {@link ISystemEvent} and listeners for these events need to be
32   * instances of {@link ISystemEventListener}. The listener should be registered
33   * against the {@link IEventSource} returned from
34   * {@link IEventManager#getSystemEventSource(Class)}.
35   * 
36   * @author Ramon Servadei
37   */
38  public final class RemoteContainerDestroyedEvent extends AbstractSystemEvent
39  {
40      /** The identity of the remote context */
41      private final String remoteContextIdentity;
42  
43      /**
44       * Standard constructor
45       * 
46       * @param remoteContextIdentity
47       *            the identity of the remote context where the remote container
48       *            was originally created
49       * @param context
50       *            the context the event is handled in
51       * @param id
52       *            the identifiable instance
53       */
54      public RemoteContainerDestroyedEvent(String remoteContextIdentity,
55          IEventManager context, IAddressable id)
56      {
57          super(context, id);
58          nullCheck(remoteContextIdentity, "No remote context identity");
59          this.remoteContextIdentity = remoteContextIdentity;
60      }
61  
62      /**
63       * Get the identity of the remote context of the remote container that was
64       * destroyed
65       * 
66       * @return the identity of the remote context
67       */
68      public String getRemoteContextIdentity()
69      {
70          return remoteContextIdentity;
71      }
72  
73      @Override
74      protected String getAdditionalToString()
75      {
76          return super.getAdditionalToString() + ", remoteContext="
77              + this.remoteContextIdentity;
78      }
79  }