KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Deployment > ComponentInstallationMain


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 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): Briclet Frederic
23 Contributor(s): ___________________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Deployment;
28 /**
29  * ComponentInstallation boot class.
30  *
31  * @author <a HREF="mailto:frederic.briclet@lifl.fr">Briclet Frederic</a>
32  *
33  * @version 0.1
34  */

35
36 public class ComponentInstallationMain extends org.objectweb.openccm.corba.ApplicationServer
37 {
38     
39     // ==================================================================
40
//
41
// Internal state.
42
//
43
// ==================================================================
44

45     /**
46      ** To store the component server name.
47      **/

48     protected String JavaDoc name_ ="ComponentInstallation";
49     
50     // ==================================================================
51
//
52
// Constructor.
53
//
54
// ==================================================================
55

56     /**
57      ** The constructor.
58      **/

59     public
60     ComponentInstallationMain()
61     {
62     }
63     
64     
65     // ==================================================================
66
//
67
// Public methods.
68
//
69
// ==================================================================
70

71     /**
72      ** The bootstrap main method.
73      **
74      ** @param args The command-line arguments.
75      **/

76     public static void
77     main(String JavaDoc args[])
78     {
79     ComponentInstallationMain server = new ComponentInstallationMain();
80     int status = server.start(args);
81     System.exit(status);
82     }
83     
84     // ==================================================================
85
//
86
// Methods for the org.objectweb.openccm.corba.ApplicationServer.
87
//
88
// ==================================================================
89

90     /**
91      ** Before running the CORBA::ORB.
92      **
93      ** @param args The command line arguments.
94      **
95      ** @return The status.
96      **/

97     public int
98     before_run(String JavaDoc[] args)
99     {
100     // Init the OpenCCM Components runtime.
101
org.objectweb.openccm.Components.Runtime.init();
102     
103     // Create the server servant.
104
ComponentInstallationImpl afi = new ComponentInstallationImpl(args[0]+name_+args[1]);
105     
106     // Activate it.
107
org.omg.CORBA.Object JavaDoc ref =
108             afi._this_object(org.objectweb.openccm.corba.TheORB.getORB());
109     
110     org.omg.Components.Deployment.ComponentInstallation serverRef =
111         org.omg.Components.Deployment.ComponentInstallationHelper.narrow(ref);
112     
113     /* args [0] non du fichier a ecrire
114      * args[1] nom de la machine locale
115      */

116     // Obtain the Name Service.
117
org.objectweb.openccm.corba.NamingContext ns =
118         org.objectweb.openccm.corba.TheNameService.getNamingContext();
119     
120     // Bind the server object in the name service.
121
ns.rebind(name_+args[1], serverRef);
122     
123     // Output the IOR of the ServerActivator.
124
//org.objectweb.openccm.corba.TheORB.save_IOR(serverRef,name_);
125

126     // Return OK.
127
TheComponentInstallation.setComponentInstallation(serverRef);
128     System.out.println("The OpenCCM Component Instantiation is ready.");
129     return 0;
130     }
131     
132     /**
133      ** After running the CORBA::ORB.
134      **/

135     public void
136     after_run()
137     {
138     // Obtain the Name Service.
139
org.objectweb.openccm.corba.NamingContext ns =
140         org.objectweb.openccm.corba.TheNameService.getNamingContext();
141
142     // Unbind the server object from the name service.
143
ns.unbind(name_);
144     }
145     
146 }
147
Popular Tags