KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > carol > util > csiv2 > struct > TransportStruct


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004-2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: TransportStruct.java,v 1.7 2005/03/04 14:04:47 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.carol.util.csiv2.struct;
26
27 import java.io.Serializable JavaDoc;
28 import java.net.InetAddress JavaDoc;
29 import java.net.UnknownHostException JavaDoc;
30
31 import org.omg.CSIIOP.TransportAddress;
32
33 import org.objectweb.carol.util.configuration.CarolDefaultValues;
34 import org.objectweb.carol.util.configuration.TraceCarol;
35
36 /**
37  * @author Florent Benoit
38  */

39 public class TransportStruct implements Serializable JavaDoc {
40
41     /**
42      * Default localhost ip address
43      */

44     private static final String JavaDoc LOCAL_IP = "127.0.0.1";
45
46     /**
47      * TransportAddress
48      */

49     private TransportAddress[] transportAdresses = null;
50
51     /**
52      * Target supports for this mech
53      */

54     private short targetSupports = 0;
55
56     /**
57      * Target requires for this mech
58      */

59     private short targetRequires = 0;
60
61
62     /**
63      * Gets current SSL port
64      * @return the ssl port
65      */

66     public static int getSslPort() {
67         // Get system property :
68
String JavaDoc sslPortStr = System.getProperty("OASSLPort", String.valueOf(CarolDefaultValues.DEFAULT_SSL_PORT));
69         return Integer.parseInt(sslPortStr);
70     }
71
72     /**
73      * @return TransportAddress[] object for SSL connection
74      */

75     public TransportAddress[] getTransportAddress() {
76
77         int sslPort = getSslPort();
78
79         String JavaDoc ipAddr = null;
80
81         try {
82             InetAddress JavaDoc addr = InetAddress.getLocalHost();
83             ipAddr = addr.getHostAddress();
84         } catch (UnknownHostException JavaDoc uhe) {
85             TraceCarol.error("Cannot get current hostname", uhe);
86             ipAddr = LOCAL_IP;
87         }
88         transportAdresses = new TransportAddress[1];
89         transportAdresses[0] = new TransportAddress(ipAddr, (short) sslPort);
90         return transportAdresses;
91     }
92
93     /**
94      * @param targetRequires The targetRequires to set.
95      */

96     public void setTargetRequires(int targetRequires) {
97         this.targetRequires = (short) targetRequires;
98     }
99
100     /**
101      * @param targetSupports The targetSupports to set.
102      */

103     public void setTargetSupports(int targetSupports) {
104         this.targetSupports = (short) targetSupports;
105     }
106
107     /**
108      * @return Returns the targetRequires.
109      */

110     public short getTargetRequires() {
111         return targetRequires;
112     }
113
114     /**
115      * @return Returns the targetSupports.
116      */

117     public short getTargetSupports() {
118         return targetSupports;
119     }
120
121 }
Popular Tags