KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > imr > ImRHostInfo


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

22
23 import org.omg.CORBA.ORB JavaDoc;
24
25 /**
26  * This class represents a host. It contains information about
27  * a server startup daemon residing on this host and provides
28  * a method for starting a server on that host.
29  *
30  * @author Nicolas Noffke
31  *
32  * @version $Id: ImRHostInfo.java,v 1.10 2004/05/06 12:39:59 nicolas Exp $
33  */

34
35 public class ImRHostInfo
36     implements java.io.Serializable JavaDoc
37 {
38     protected String JavaDoc host;
39
40     private ServerStartupDaemon ssd_ref;
41     private String JavaDoc object_string;
42
43     private boolean reconnect = false;
44     
45     /**
46      * The constructor of this class.
47      *
48      * @param host the HostInfo object to take the information from.
49      * @param orb needed for calling object_to_string().
50      */

51
52     public ImRHostInfo(HostInfo host)
53     {
54         this.host = host.name;
55         ssd_ref = host.ssd_ref;
56         object_string = host.ior_string;
57     }
58     
59     /**
60      * "Convert" this object to a HostInfo object
61      *
62      * @return a HostInfo instance
63      */

64
65     public HostInfo toHostInfo()
66     {
67         // setting ref explicitely to null since it might be stale.
68
return new HostInfo(host, null, object_string);
69     }
70
71     /**
72      * This method tries to start a server with the daemon for this host.
73      *
74      * @param command the startup command of the server
75      * @param orb needed for calling string_to_object().
76      * @exception ServerStartupFailed propagated up from the daemon if something
77      * went wrong. Likely to throw CORBA System Exceptions as well, especially
78      * if the daemon is down.
79      */

80
81     public void startServer(String JavaDoc command, ORB JavaDoc orb)
82         throws ServerStartupFailed
83     {
84         if (reconnect)
85             ssd_ref = ServerStartupDaemonHelper.narrow(orb.string_to_object(object_string));
86
87         ssd_ref.start_server(command);
88     }
89
90     /**
91      * Things to be done before serialization. Implemented from Serializable.
92      */

93
94     private void writeObject(java.io.ObjectOutputStream JavaDoc out)
95         throws java.io.IOException JavaDoc
96     {
97         reconnect = true; // all ssd_references are stale after deserialization
98
out.defaultWriteObject();
99     }
100 } // ImRHostInfo
101

102
103
Popular Tags