KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class AssemblyFactoryMain extends org.objectweb.openccm.corba.ApplicationServer
30 {
31     
32     // ==================================================================
33
//
34
// Internal state.
35
//
36
// ==================================================================
37

38     /**
39      ** To store the component server name.
40      **/

41     protected String JavaDoc name_ ="AssemblyFactory";
42     
43     // ==================================================================
44
//
45
// Constructor.
46
//
47
// ==================================================================
48

49     /**
50      ** The constructor.
51      **/

52     public
53     AssemblyFactoryMain()
54     {
55         // Set EntityResolver for CCM DTDs
56
org.objectweb.ccm.descriptor.EntityResolver.setCCMResolver();
57     }
58     
59     // ==================================================================
60
//
61
// Internal methods.
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     AssemblyFactoryMain server = new AssemblyFactoryMain();
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
AssemblyFactoryImpl afi = new AssemblyFactoryImpl();
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.AssemblyFactory serverRef =
111         org.omg.Components.Deployment.AssemblyFactoryHelper.narrow(ref);
112     
113     /* args [0] non du fichier a ecrier*/
114     
115     // Obtain the Name Service.
116
org.objectweb.openccm.corba.NamingContext ns =
117         org.objectweb.openccm.corba.TheNameService.getNamingContext();
118     
119     // Bind the server object in the name service.
120
ns.rebind(name_, serverRef);
121     
122     // Output the IOR of the ComponentServer.
123
org.objectweb.openccm.corba.TheORB.save_IOR(serverRef, args[0]);
124     
125     // Return OK.
126

127     System.out.println("The OpenCCM Assembly Factory is ready.");
128     return 0;
129     }
130     
131     /**
132      ** After running the CORBA::ORB.
133      **/

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