KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > tools > RMIUtil


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.tools;
15
16 import java.rmi.*;
17 import java.rmi.registry.*;
18 import java.rmi.server.*;
19 import java.net.*;
20 import java.io.*;
21
22 /**
23  * Test/List RMI Registry
24  *
25  * @author Jorg Janke
26  * @version $Id: RMIUtil.java,v 1.2 2003/08/08 16:16:08 jjanke Exp $
27  */

28 public class RMIUtil
29 {
30     public RMIUtil()
31     {
32     // testPort();
33
try
34         {
35             System.out.println("Registry ------------------------------------");
36             Registry registry = LocateRegistry.getRegistry();
37             System.out.println("- " + registry);
38             String JavaDoc[] list = registry.list();
39             System.out.println("- size=" + list.length);
40             for (int i = 0; i < list.length; i++)
41             {
42                 System.out.println("-- " + list[i]);
43             }
44         }
45         catch (Exception JavaDoc ex)
46         {
47             ex.printStackTrace();
48         }
49
50         try
51         {
52             System.out.println("Server --------------------------------------");
53         // System.out.println("- " + RemoteServer.getClientHost());
54
String JavaDoc[] list = Naming.list ("rmi://localhost:1099");
55             System.out.println("- size=" + list.length);
56             for (int i = 0; i < list.length; i++)
57             {
58                 System.out.println("-- " + list[i]);
59             }
60         }
61         catch (Exception JavaDoc ex)
62         {
63             ex.printStackTrace();
64         }
65     } // RMIUtil
66

67     private void testPort()
68     {
69         try
70         {
71             System.out.println("Test Port -----------------------------------");
72             Socket socket = new Socket ("localhost", 1099);
73             System.out.println("- Socket=" + socket);
74             //
75
InputStream in = socket.getInputStream();
76             int i = 0;
77             while (i >= 0)
78             {
79                 i = in.read();
80                 if (i >= 0)
81                     System.out.println((char)i);
82             }
83         }
84         catch (IOException ex)
85         {
86             ex.printStackTrace();
87         }
88
89     }
90
91     /**
92      * Test
93      * @param args args
94      */

95     public static void main (String JavaDoc[] args)
96     {
97         new RMIUtil();
98     } // main
99

100 } // RMIUtil
101
Popular Tags