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.event.IEventManager;
20  import fulmine.event.IEventSource;
21  import fulmine.event.system.AbstractSystemEvent;
22  import fulmine.event.system.ISystemEvent;
23  import fulmine.event.system.ISystemEventListener;
24  import fulmine.model.container.IContainer;
25  
26  /**
27   * Raised when a remote {@link IContainer} has been created. The container is
28   * created in this local context but represents a container in a remote context.
29   * <p>
30   * This is an {@link ISystemEvent} and listeners for these events need to be
31   * instances of {@link ISystemEventListener}. The listener should be registered
32   * against the {@link IEventSource} returned from
33   * {@link IEventManager#getSystemEventSource(Class)}.
34   * 
35   * @author Ramon Servadei
36   */
37  public final class RemoteContainerCreatedEvent extends AbstractSystemEvent
38  {
39      /** The container that has been created */
40      private final IContainer container;
41  
42      /** The identity of the remote context */
43      private final String remoteContextIdentity;
44  
45      /**
46       * Standard constructor
47       * 
48       * @param remoteContextIdentity
49       *            the identity of the remote context that the remote container
50       *            originates from
51       * @param context
52       *            the context for event operations
53       * @param container
54       *            the remote container that has been created
55       */
56      public RemoteContainerCreatedEvent(String remoteContextIdentity,
57          IEventManager context, IContainer container)
58      {
59          super(context, container);
60          nullCheck(remoteContextIdentity, "No remote context identity");
61          this.container = container;
62          this.remoteContextIdentity = remoteContextIdentity;
63      }
64  
65      /**
66       * Get the container that has been created
67       * 
68       * @return the {@link IContainer} that has been created
69       */
70      public IContainer getContainer()
71      {
72          return this.container;
73      }
74  
75      /**
76       * Get the identity of the remote context of the remote container that has
77       * been created
78       * 
79       * @return the identity of the remote context
80       */
81      public String getRemoteContextIdentity()
82      {
83          return remoteContextIdentity;
84      }
85  
86      @Override
87      protected String getAdditionalToString()
88      {
89          return super.getAdditionalToString() + ", remoteContext="
90              + this.remoteContextIdentity;
91      }
92  }