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.context;
17  
18  import fulmine.distribution.IHeartbeatMonitor;
19  import fulmine.distribution.channel.IChannel;
20  import fulmine.distribution.connection.IConnection;
21  import fulmine.distribution.connection.IConnectionBroker;
22  import fulmine.distribution.connection.IConnectionDiscoverer;
23  
24  /**
25   * A network groups all the necessary components for connecting an
26   * {@link IFulmineContext} to a specific network transport. The network allows
27   * the context to communicate with other remote contexts that connect to the
28   * same network transport.
29   * <p>
30   * A single implementation instance will be used by only a single context
31   * instance.
32   * 
33   * @author Ramon Servadei
34   */
35  public interface INetwork extends IHeartbeatMonitor
36  {
37      /**
38       * Set the context this network services
39       * 
40       * @param context
41       *            the context this network services
42       */
43      void setContext(IFrameworkContext context);
44  
45      /**
46       * Create a connection broker.
47       * 
48       * @return a connection broker
49       */
50      IConnectionBroker createBroker();
51  
52      /**
53       * Create a connection discoverer.
54       * 
55       * @return a connection discoverer
56       */
57      IConnectionDiscoverer createDiscoverer();
58  
59      /**
60       * Create a channel
61       * 
62       * @param connection
63       *            the connection for the channel
64       * @return a new channel wrapping the connection
65       */
66      IChannel createChannel(IConnection connection);
67  
68      /**
69       * Sets the {@link IConnectionDiscoverer} returned from
70       * {@link #createDiscoverer()} into listening-only mode. This effectively
71       * means that the discoverer will not send out pulses but will monitor the
72       * pulses from other contexts.
73       * <p>
74       * Calling this after the discoverer is created and started will also cause
75       * the discoverer to go into listening-only mode.
76       * 
77       * @param listeningOnlyMode
78       *            <code>true</code> if the discoverer should be in listening
79       *            only mode
80       * 
81       * @see IConnectionDiscoverer#disablePulsing()
82       */
83      void setListeningOnlyMode(boolean listeningOnlyMode);
84  
85      /**
86       * Get the value of the listening only mode
87       * 
88       * @return <code>true</code> if the discoverer is in listening only mode
89       */
90      boolean isListeningOnlyMode();
91  }