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.connection; 17 18 import fulmine.context.IFrameworkContext; 19 20 /** 21 * Encapsulates the parameters required to create an {@link IConnection}. The 22 * parameters are used as the argument for the 23 * {@link IConnectionBroker#connect(IConnection)} method. 24 * <p> 25 * Implementations <b>must</b> define the {@link #equals(Object)} method to 26 * compare connection parameters with another instance. 27 * 28 * @author Ramon Servadei 29 * 30 */ 31 public interface IConnectionParameters 32 { 33 /** 34 * Get the identity of the {@link IFrameworkContext} at the remote end of 35 * the connection 36 * 37 * @return the String identity of the remote context 38 */ 39 String getRemoteContextIdentity(); 40 41 /** 42 * Get a unique integer for the remote context. This must be constant for 43 * any connection to the same remote context. This must be completely unique 44 * for a remote context instance, regardless of the context identity. 45 * 46 * @return a unique integer for the remote context 47 */ 48 int getRemoteContextHashCode(); 49 50 /** 51 * Checks the connection parameters for equality. The implementation should 52 * not make any class match checks in this method because an 53 * {@link IConnection} instance extends this. 54 * <p> 55 * It is a requirement that, if a connection is outbound ( 56 * {@link IConnection#isOutbound()}) and based on these parameters, 57 * <code>parameters.isEqual(connection)</code> is true. 58 * 59 * <code><pre> 60 * IConnectionParameters parameters = ... 61 * broker.connect(parameters); 62 * IConnection connection = ... // connection created by the broker 63 * // this will be true 64 * parameters.isEqual(connection); 65 * </pre></code> 66 * 67 * @param connectionParameters 68 * the other set of connection parameters to compare with this 69 * @return <code>true</code> if the two parameters represent the same 70 * connection attributes 71 */ 72 boolean isEqual(IConnectionParameters connectionParameters); 73 }