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.distribution.channel;
17  
18  import java.util.Map;
19  
20  import fulmine.ILifeCycle;
21  import fulmine.context.IFrameworkContext;
22  import fulmine.distribution.connection.IConnection;
23  import fulmine.event.listener.ILifeCycleEventListener;
24  import fulmine.event.subscription.ISubscriptionManager;
25  import fulmine.model.container.subscription.remote.RxSubscription;
26  import fulmine.model.container.subscription.remote.TxSubscription;
27  import fulmine.model.field.LongField;
28  
29  /**
30   * Interface for the shared state object of a {@link Channel}
31   * 
32   * @author Ramon Servadei
33   */
34  public interface IChannelState extends ILifeCycle
35  {
36  
37      /**
38       * Holds the RxEvent listener token against the application subscription
39       * token.
40       * 
41       * @return a map of application listener subscription token against the
42       *         RxEvent subscription token
43       */
44      Map<Integer, Integer> getTokenMap();
45  
46      /**
47       * Helper to process events received from the peer channel and from the
48       * local context.
49       */
50      ILifeCycleEventListener getEventHandler();
51  
52      /**
53       * Initialise the state
54       * 
55       * @param channel
56       *            the channel
57       * @param channelOps
58       *            the channel operations
59       */
60      void init(IChannel channel, IChannelOperations channelOps);
61  
62      void setConnectionSyn();
63  
64      /** The local context */
65      IFrameworkContext getContext();
66  
67      /**
68       * The subscription manager for {@link TxSubscription} instances. This
69       * manager handles subscriptions for transmitting local containers to the
70       * remote context; these are subscriptions from the remote context for local
71       * containers.
72       */
73      ISubscriptionManager getTxSubscriptionManager();
74  
75      /**
76       * The subscription manager for {@link RxSubscription} instances. This
77       * manager handles subscriptions for receiving remote containers from remote
78       * contexts; these are subscriptions from the local context for remote
79       * containers.
80       */
81      ISubscriptionManager getRxSubscriptionManager();
82  
83      /**
84       * Indicates if the connection to the peer {@link IChannel} has been
85       * synchronised. The peer channels in the peer contexts will be created at
86       * different times, so they must synchronise with each other to ensure no
87       * missed registrations occur.
88       */
89      boolean isConnectionSyn();
90  
91      /** The connection to use */
92      IConnection getConnection();
93  
94      LongField getTxCount();
95  
96      LongField getRxCount();
97  }