KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > orb > iiop > ServerIIOPConnection


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) 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  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 package org.jacorb.orb.iiop;
22
23 import java.io.*;
24 import java.net.*;
25
26 import org.apache.avalon.framework.configuration.*;
27
28 import org.jacorb.orb.IIOPAddress;
29
30 /**
31  * ServerIIOPConnection.java
32  *
33  *
34  * Created: Sun Aug 12 20:56:32 2002
35  *
36  * @author Nicolas Noffke / Andre Spiegel
37  * @version $Id: ServerIIOPConnection.java,v 1.4 2004/08/25 09:31:41 simon.mcqueen Exp $
38  */

39
40 public class ServerIIOPConnection
41     extends IIOPConnection
42 {
43
44     public ServerIIOPConnection( Socket socket,
45                                  boolean is_ssl )
46         throws IOException
47     {
48         super();
49
50         this.socket = socket;
51         // socket.setTcpNoDelay( true );
52
this.use_ssl = is_ssl;
53
54         in_stream = socket.getInputStream();
55         out_stream = new BufferedOutputStream(socket.getOutputStream());
56
57     }
58
59
60     public void configure(Configuration configuration)
61         throws ConfigurationException
62     {
63         super.configure(configuration);
64
65         IIOPAddress address = new IIOPAddress
66         (
67             socket.getInetAddress().getHostAddress(),
68             socket.getPort()
69         );
70         
71         profile = new IIOPProfile(address, null);
72         profile.configure(configuration);
73
74         connection_info = address.toString();
75         connected = true;
76
77         if (logger.isInfoEnabled())
78             logger.info("Opened new server-side TCP/IP transport to " +
79                         connection_info );
80     }
81
82
83     public Socket getSocket()
84     {
85         return socket;
86     }
87
88     public synchronized void close()
89     {
90         if( socket != null )
91         {
92             try
93             {
94                 socket.close();
95
96                 //this will cause exceptions when trying to read from
97
//the streams. Better than "nulling" them.
98
if( in_stream != null )
99                 {
100                     in_stream.close();
101                 }
102
103                 if( out_stream != null )
104                 {
105                     out_stream.close();
106                 }
107             }
108             catch (IOException ex)
109             {
110                 throw to_COMM_FAILURE (ex);
111             }
112             
113             socket = null;
114             connected = false;
115
116             if (logger.isInfoEnabled())
117                 logger.info("Closed server-side transport to " +
118                             connection_info );
119         }
120     }
121
122     public void connect (org.omg.ETF.Profile server_profile, long time_out)
123     {
124         //can't reconnect
125
}
126 }
127
Popular Tags