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.event.system;
17  
18  import fulmine.IAddressable;
19  import fulmine.event.IEventManager;
20  import fulmine.event.IEventSource;
21  import fulmine.event.listener.IEventListener;
22  
23  /**
24   * A system event raised when an {@link IEventSource} has no more
25   * {@link IEventListener} instances observing it.
26   * <p>
27   * Application code can register an {@link ISystemEventListener} to receive
28   * these events in order to stop servicing the affected event source.
29   * 
30   * @see EventSourceObservedEvent
31   * @author Ramon Servadei
32   */
33  public final class EventSourceNotObservedEvent extends AbstractSystemEvent
34  {
35      /** the identity of the local context of the {@link IEventSource} */
36      private final String nativeContextIdentity;
37  
38      /**
39       * Standard constructor
40       * 
41       * @param nativeContextIdentity
42       *            the identity of the context the {@link IEventSource} is native
43       *            to; its local context
44       * @param context
45       *            the context the event is handled in
46       * @param id
47       *            the identifiable instance
48       */
49      public EventSourceNotObservedEvent(String nativeContextIdentity,
50          IEventManager context, IAddressable id)
51      {
52          super(context, id);
53          this.nativeContextIdentity = nativeContextIdentity;
54      }
55  
56      /**
57       * Get the identity of the context the {@link IEventSource} is native to;
58       * its local context
59       * 
60       * @return the identity of the context the event source is local to
61       */
62      public String getNativeContextIdentity()
63      {
64          return this.nativeContextIdentity;
65      }
66  
67      @Override
68      protected String getAdditionalToString()
69      {
70          return "nativeContext=" + getNativeContextIdentity();
71      }
72  }