KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > datashare > objects > DataShareConnectionDescriptor


1 /* ----- BEGIN LICENSE BLOCK -----
2  * Version: MPL 1.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is the DataShare server.
15  *
16  * The Initial Developer of the Original Code is
17  * Ball Aerospace & Technologies Corp, Fairborn, Ohio
18  * Portions created by the Initial Developer are Copyright (C) 2001
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s): Charles Wood <cwood@ball.com>
22  *
23  * ----- END LICENSE BLOCK ----- */

24 /* RCS $Id: DataShareConnectionDescriptor.java,v 1.1.1.1 2001/10/23 13:37:20 lizellaman Exp $
25  * $Log: DataShareConnectionDescriptor.java,v $
26  * Revision 1.1.1.1 2001/10/23 13:37:20 lizellaman
27  * initial sourceforge release
28  *
29  */

30
31 package org.datashare.objects;
32
33 import java.net.InetAddress JavaDoc;
34 import java.net.Socket JavaDoc;
35
36 /**
37  * This class is used to describe a DataShareConnection socket and is sent over the
38  * CommandStatus Channel. We do not actually use
39  * sockets in this class because they are not serializable. The information in
40  * an instance of this class allows a socket to be (re)created. This class is used by
41  * clients only to create a connection. The DataShareServer should not use this class
42  * to create connections. This object is sent inside another object.
43  */

44 public class DataShareConnectionDescriptor implements java.io.Serializable JavaDoc
45    {
46    /**
47     * this allows us to serialize this class without 'marshalling' errors.
48     *
49     */

50    static final long serialVersionUID = 9030593813711490503L;
51
52    public InetAddress JavaDoc serverIP;
53    public int serverPort;
54    public InetAddress JavaDoc clientIP;
55    public int clientPort;
56    public String JavaDoc name;
57    public int type; // defined by ChannelDescription
58
public String JavaDoc clientKeyValue; // keyValue for the client of this connection
59
public String JavaDoc keyValue; // should always be unique for a VM
60
public ChannelDescription channelDescription;
61    public String JavaDoc sessionName;
62    public String JavaDoc tokenKey = ""; // the key that makes this Channel unique
63
public String JavaDoc databaseID; // the ADSKey string for this channel, needs to be set (if persist is true) before sending to clients
64

65    public boolean constantPing = false;
66    public boolean completelySpecified = false;
67
68    /**
69     * This constructor is used when the connection has already be established and activated
70     */

71    public DataShareConnectionDescriptor(
72                               String JavaDoc sessionName,
73                               ChannelDescription channelDescription,
74                               String JavaDoc clientKeyValue,
75                               InetAddress JavaDoc serverIP,
76                               int serverPort,
77                               InetAddress JavaDoc clientIP,
78                               int clientPort)
79       {
80       this.sessionName = sessionName;
81       this.channelDescription = channelDescription;
82       name = channelDescription.channelName;
83       this.clientKeyValue = clientKeyValue;
84       this.type = channelDescription.type;
85       this.serverIP = serverIP;
86       this.serverPort = serverPort;
87       this.clientIP = clientIP;
88       this.clientPort = clientPort;
89       keyValue = name + "-" + new Integer JavaDoc(type) + "-" + serverIP.getHostAddress() + ":" + serverPort
90                                                       + clientIP.getHostAddress() + ":" + clientPort;
91       tokenKey = sessionName+"."+channelDescription.channelName;
92       completelySpecified = true;
93       }
94
95    /**
96     * This constructor is used to describe a connection, prior to establishing it
97     */

98    public DataShareConnectionDescriptor(
99                               String JavaDoc sessionName,
100                               ChannelDescription channelDescription,
101                               InetAddress JavaDoc serverIP,
102                               int serverPort)
103       {
104       this.sessionName = sessionName;
105       this.channelDescription = channelDescription;
106       name = channelDescription.channelName;
107       this.type = channelDescription.type;
108       this.serverIP = serverIP;
109       this.serverPort = serverPort;
110       keyValue = name + "-" + new Integer JavaDoc(type) + "-" + serverIP.getHostAddress() + ":" + serverPort;
111       tokenKey = sessionName+"."+channelDescription.channelName;
112       completelySpecified = false;
113       }
114
115 // public void
116
// setTokenKey(String tokenKey)
117
// {
118
// this.tokenKey = tokenKey;
119
// }
120

121
122    }
123
124
Popular Tags