001: /* ----- BEGIN LICENSE BLOCK -----
002: * Version: MPL 1.1
003: *
004: * The contents of this file are subject to the Mozilla Public License Version
005: * 1.1 (the "License"); you may not use this file except in compliance with
006: * the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS" basis,
010: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011: * for the specific language governing rights and limitations under the
012: * License.
013: *
014: * The Original Code is the DataShare server.
015: *
016: * The Initial Developer of the Original Code is
017: * Ball Aerospace & Technologies Corp, Fairborn, Ohio
018: * Portions created by the Initial Developer are Copyright (C) 2001
019: * the Initial Developer. All Rights Reserved.
020: *
021: * Contributor(s): Charles Wood <cwood@ball.com>
022: *
023: * ----- END LICENSE BLOCK ----- */
024: /* RCS $Id: DataShareConnectionDescriptor.java,v 1.1.1.1 2001/10/23 13:37:20 lizellaman Exp $
025: * $Log: DataShareConnectionDescriptor.java,v $
026: * Revision 1.1.1.1 2001/10/23 13:37:20 lizellaman
027: * initial sourceforge release
028: *
029: */
030:
031: package org.datashare.objects;
032:
033: import java.net.InetAddress;
034: import java.net.Socket;
035:
036: /**
037: * This class is used to describe a DataShareConnection socket and is sent over the
038: * CommandStatus Channel. We do not actually use
039: * sockets in this class because they are not serializable. The information in
040: * an instance of this class allows a socket to be (re)created. This class is used by
041: * clients only to create a connection. The DataShareServer should not use this class
042: * to create connections. This object is sent inside another object.
043: */
044: public class DataShareConnectionDescriptor implements
045: java.io.Serializable {
046: /**
047: * this allows us to serialize this class without 'marshalling' errors.
048: *
049: */
050: static final long serialVersionUID = 9030593813711490503L;
051:
052: public InetAddress serverIP;
053: public int serverPort;
054: public InetAddress clientIP;
055: public int clientPort;
056: public String name;
057: public int type; // defined by ChannelDescription
058: public String clientKeyValue; // keyValue for the client of this connection
059: public String keyValue; // should always be unique for a VM
060: public ChannelDescription channelDescription;
061: public String sessionName;
062: public String tokenKey = ""; // the key that makes this Channel unique
063: public String databaseID; // the ADSKey string for this channel, needs to be set (if persist is true) before sending to clients
064:
065: public boolean constantPing = false;
066: public boolean completelySpecified = false;
067:
068: /**
069: * This constructor is used when the connection has already be established and activated
070: */
071: public DataShareConnectionDescriptor(String sessionName,
072: ChannelDescription channelDescription,
073: String clientKeyValue, InetAddress serverIP,
074: int serverPort, InetAddress clientIP, int clientPort) {
075: this .sessionName = sessionName;
076: this .channelDescription = channelDescription;
077: name = channelDescription.channelName;
078: this .clientKeyValue = clientKeyValue;
079: this .type = channelDescription.type;
080: this .serverIP = serverIP;
081: this .serverPort = serverPort;
082: this .clientIP = clientIP;
083: this .clientPort = clientPort;
084: keyValue = name + "-" + new Integer(type) + "-"
085: + serverIP.getHostAddress() + ":" + serverPort
086: + clientIP.getHostAddress() + ":" + clientPort;
087: tokenKey = sessionName + "." + channelDescription.channelName;
088: completelySpecified = true;
089: }
090:
091: /**
092: * This constructor is used to describe a connection, prior to establishing it
093: */
094: public DataShareConnectionDescriptor(String sessionName,
095: ChannelDescription channelDescription,
096: InetAddress serverIP, int serverPort) {
097: this .sessionName = sessionName;
098: this .channelDescription = channelDescription;
099: name = channelDescription.channelName;
100: this .type = channelDescription.type;
101: this .serverIP = serverIP;
102: this .serverPort = serverPort;
103: keyValue = name + "-" + new Integer(type) + "-"
104: + serverIP.getHostAddress() + ":" + serverPort;
105: tokenKey = sessionName + "." + channelDescription.channelName;
106: completelySpecified = false;
107: }
108:
109: // public void
110: // setTokenKey(String tokenKey)
111: // {
112: // this.tokenKey = tokenKey;
113: // }
114:
115: }
|