KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > benchmark > corba > latency > IORServer


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Christophe Demarey.
23 Contributor(s): Gael Harbonnier.
24
25 ====================================================================*/

26
27 package org.objectweb.benchmark.corba.latency;
28
29 // Package dependencies.
30
import java.io.InputStream JavaDoc;
31 import java.io.PrintStream JavaDoc;
32 import java.net.ServerSocket JavaDoc;
33 import java.net.Socket JavaDoc;
34 import java.util.Properties JavaDoc;
35
36
37 /**
38  * IORServer sends IOR to a CORBA client.
39  *
40  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
41  *
42  * @version 0.1
43  */

44 public class IORServer
45 {
46     // ==================================================================
47
//
48
// Internal states.
49
//
50
// ==================================================================
51

52     /**
53      * The IOR
54      */

55     private String JavaDoc ior;
56   
57
58     /**
59      * Port for the socket
60      */

61     private int port;
62
63     // ==================================================================
64
//
65
// Constructors.
66
//
67
// ==================================================================
68

69     /**
70      * The default constructor.
71      */

72     public IORServer(String JavaDoc ior)
73     throws Exception JavaDoc
74     {
75         this.ior=ior;
76
77         Properties JavaDoc props = new Properties JavaDoc();
78         InputStream JavaDoc propStream = getClass().getClassLoader().getResourceAsStream("build.properties");
79         props.load(propStream);
80
81         port = Integer.parseInt( props.getProperty("ior.port") );
82     }
83     
84     // ==================================================================
85
//
86
// Public methods.
87
//
88
// ==================================================================
89

90     /**
91      * Waits for client connection and publishes Server IOR.
92      */

93     public void listen()
94     throws Exception JavaDoc
95     {
96         ServerSocket JavaDoc ss = new ServerSocket JavaDoc(port);
97         Socket JavaDoc s = ss.accept();
98     
99         PrintStream JavaDoc out = new PrintStream JavaDoc(s.getOutputStream());
100
101         // Sends IOR
102
out.println(this.ior);
103
104         s.close();
105     }
106 }
107
Popular Tags