View Javadoc

1   /*
2      Copyright 2007 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.distribution.events;
17  
18  import fulmine.context.IFrameworkContext;
19  import fulmine.distribution.connection.IConnection;
20  import fulmine.event.IEventManager;
21  import fulmine.event.system.AbstractSystemEvent;
22  
23  /**
24   * A system event raised by an {@link IConnection} implementation and represents
25   * that the connection has been destroyed. This is either due to the remote
26   * {@link IFrameworkContext} terminating the connection or the local context
27   * terminating the connection.
28   * 
29   * @author Ramon Servadei
30   */
31  public final class ConnectionDestroyedEvent extends AbstractSystemEvent
32  {
33      /**
34       * The identity of the remote {@link IFrameworkContext} that the destroyed
35       * connection was for.
36       */
37      private final String remoteContextIdentity;
38  
39      /**
40       * Standard constructor to encapsulate the identity of the remote
41       * {@link IFrameworkContext} that the destroyed connection was for
42       * 
43       * @param context
44       *            the context for event operations
45       * @param remoteContextIdentity
46       *            the identity of the remote context that the destroyed
47       *            connection was for
48       */
49      public ConnectionDestroyedEvent(IEventManager context,
50          String remoteRuntimeIdentity)
51      {
52          super(context);
53          this.remoteContextIdentity = remoteRuntimeIdentity;
54      }
55  
56      /**
57       * Get the identity of the remote {@link IFrameworkContext} that the
58       * destroyed connection was for
59       * 
60       * @return the identity of the remote context that the destroyed connection
61       *         was for
62       */
63      public String getRemoteContextIdentity()
64      {
65          return this.remoteContextIdentity;
66      }
67  
68      @Override
69      public String toDetailedString()
70      {
71          return toString();
72      }
73  
74      @Override
75      public String toIdentityString()
76      {
77          return toString();
78      }
79  
80      @Override
81      protected String getAdditionalToString()
82      {
83          return "remoteContext=" + getRemoteContextIdentity();
84      }
85  }