KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > simple > Install


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
5 Contact: openccm-team@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): Philippe Merle.
23 Contributor(s): .
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.simple;
28
29 /**
30  * Various invalid home installation.
31  */

32 public class Install
33 {
34   /**
35    * The bootstrap of the application.
36    */

37   public static void
38   main(String JavaDoc[] args)
39     throws Exception JavaDoc
40   {
41       // Init the ORB.
42
System.out.println("INSTALL: Initializing the ORB...");
43     
44       // TODO: Need to report this ORB.init() problem to OpenORB developers!
45
// Due to an OpenORB problem, the following line:
46
// org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
47
// are replaced by the next line.
48

49       // Init the ORB.
50
args = org.objectweb.ccm.CORBA.TheORB.initialize(args);
51
52       // Init the OpenCCM runtime.
53
org.objectweb.ccm.Components.Runtime.init();
54
55       // Obtain the ORB.
56
org.omg.CORBA.ORB JavaDoc orb = org.objectweb.ccm.CORBA.TheORB.getORB();
57
58       // Obtain the Name Service.
59
System.out.println("INSTALL: Obtaining the Name Service...");
60       org.omg.CORBA.Object JavaDoc obj = orb.resolve_initial_references("NameService");
61       org.omg.CosNaming.NamingContext JavaDoc nc = org.omg.CosNaming.NamingContextHelper.narrow(obj);
62
63       // Obtain the component servers.
64
System.out.println("INSTALL: Obtaining the Component Server...");
65       org.omg.CosNaming.NameComponent JavaDoc[] ncomp = new org.omg.CosNaming.NameComponent JavaDoc[1];
66       ncomp[0] = new org.omg.CosNaming.NameComponent JavaDoc("ComponentServer", "");
67       obj = nc.resolve(ncomp);
68       org.objectweb.ccm.Deployment.Server server = org.objectweb.ccm.Deployment.ServerHelper.narrow(obj);
69
70       // Obtain the container homes and archive installators.
71
org.omg.Components.Deployment.ComponentServer server_cs = server.provide_component_server();
72       org.omg.Components.Deployment.ComponentInstallation server_inst = server.provide_install();
73
74       // Install archives.
75
System.out.println("INSTALL: Installing the archive...");
76       // get the current directory and store it as a String
77
String JavaDoc demoPath = null;
78       try
79       {
80           demoPath = new java.io.File JavaDoc(".").getCanonicalPath()+ java.io.File.separator ;
81       }
82       catch(Exception JavaDoc e)
83       {
84           e.printStackTrace();
85       }
86
87       server_inst.install("simple", demoPath + "./archives/simple.jar");
88
89       // instantiate a container on each server.
90
System.out.println("INSTALL: Creating a container...");
91       org.omg.Components.Deployment.Container server_cont =
92         server_cs.create_container(new org.omg.Components.ConfigValue[0]);
93
94       // Install homes.
95
System.out.println("INSTALL: Instantiating the home...");
96       org.omg.Components.CCMHome h = null;
97
98       org.omg.Components.ConfigValue[] config = new org.omg.Components.ConfigValue[0];
99
100       try
101       {
102           System.out.println("INSTALL: Call install_home with a correct home executor entry point...");
103           h = server_cont.install_home("simple",
104                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home",
105                                        config);
106           System.out.println("INSTALL: Home installed correctly.");
107       }
108       catch (Exception JavaDoc exc)
109       {
110           System.out.println("INSTALL: ERROR: " + exc.getMessage() + " was thrown!!!");
111           System.exit(-1);
112       }
113
114       try
115       {
116           System.out.println("\nINSTALL: Call install_home with an unknown implementation id...\n");
117
118           h = server_cont.install_home("unknown_uuid",
119                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home",
120                                        config);
121
122           System.out.println("\nINSTALL: ERROR: Components::Deployment::UnknownImplId must be thrown!!!");
123           System.exit(-1);
124       }
125       catch (org.omg.Components.Deployment.UnknownImplId exc)
126       {
127           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
128       }
129
130       try
131       {
132           System.out.println("\nINSTALL: Call install_home with an unknown home executor entry point...\n");
133
134           h = server_cont.install_home("simple",
135                                        "UnknownClass.create_home",
136                                        config);
137
138           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
139           System.exit(-1);
140       }
141       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
142       {
143           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
144       }
145
146       try
147       {
148           System.out.println("\nINSTALL: Call install_home with an unknown home executor entry point...\n");
149
150           h = server_cont.install_home("simple",
151                                        "org.objectweb.ccm.simple.ServerHomeImpl.unknown_method",
152                                        config);
153
154           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
155           System.exit(-1);
156       }
157       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
158       {
159           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
160       }
161
162       try
163       {
164           System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n");
165
166           h = server_cont.install_home("simple",
167                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home_private",
168                                        config);
169
170           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
171           System.exit(-1);
172       }
173       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
174       {
175           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
176       }
177
178       try
179       {
180           System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n");
181
182           h = server_cont.install_home("simple",
183                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home_not_static",
184                                        config);
185
186           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
187           System.exit(-1);
188       }
189       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
190       {
191           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
192       }
193
194       try
195       {
196           System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n");
197
198           h = server_cont.install_home("simple",
199                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home_with_invalid_return_type",
200                                        config);
201
202           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
203           System.exit(-1);
204       }
205       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
206       {
207           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
208       }
209
210       try
211       {
212           System.out.println("\nINSTALL: Call install_home with an existing home executor entry point but invalid signature...\n");
213
214           h = server_cont.install_home("simple",
215                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home_with_parameter",
216                                        config);
217
218           System.out.println("\nINSTALL: ERROR: Components::Deployment::ImplEntryPointNotFound must be thrown!!!");
219           System.exit(-1);
220       }
221       catch (org.omg.Components.Deployment.ImplEntryPointNotFound exc)
222       {
223           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
224       }
225
226       try
227       {
228           System.out.println("\nINSTALL: Call install_home with an existing home executor entry point function but thrown an exception...\n");
229
230           h = server_cont.install_home("simple",
231                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home_thrown_an_exception",
232                                        config);
233
234           System.out.println("\nINSTALL: ERROR: Components::Deployment::Installation must be thrown!!!");
235           System.exit(-1);
236       }
237       catch (org.omg.Components.Deployment.InstallationFailure exc)
238       {
239           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
240       }
241
242       config = new org.omg.Components.ConfigValue[1];
243       config[0] = new org.objectweb.ccm.Components.ConfigValueImpl();
244       config[0].name = "home_script";
245       config[0].value = orb.create_any();
246
247       try
248       {
249           System.out.println("\nINSTALL: Call install_home with an empty 'home_script' configuration value...");
250           config[0].value.insert_string("");
251           h = server_cont.install_home("simple",
252                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home",
253                                        config);
254           System.out.println("\nINSTALL: ERROR: Components::Deployment::InstallationFailure must be thrown!!!");
255           System.exit(-1);
256       }
257       catch (org.omg.Components.Deployment.InstallationFailure exc)
258       {
259           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
260       }
261
262       try
263       {
264           System.out.println("\nINSTALL: Call install_home with an invalid type for the 'home_script' configuration value...");
265           config[0].value.insert_long(10);
266           h = server_cont.install_home("simple",
267                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home",
268                                        config);
269           System.out.println("\nINSTALL: ERROR: Components::Deployment::InvalidConfiguration must be thrown!!!");
270           System.exit(-1);
271       }
272       catch (org.omg.Components.Deployment.InvalidConfiguration exc)
273       {
274           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
275       }
276
277       try
278       {
279           System.out.println("\nINSTALL: Call install_home with an invalid value for the 'home_script' configuration value...");
280           config[0].value.insert_string("invalid script");
281           h = server_cont.install_home("simple",
282                                        "org.objectweb.ccm.simple.ServerHomeImpl.create_home",
283                                        config);
284           System.out.println("\nINSTALL: ERROR: Components::Deployment::InvalidConfiguration must be thrown!!!");
285           System.exit(-1);
286       }
287       catch (org.omg.Components.Deployment.InvalidConfiguration exc)
288       {
289           System.out.println("\nINSTALL: OK " + exc.getMessage() + " was thrown.");
290       }
291
292       System.out.println("\nINSTALL: All install_home tests were OK.");
293       System.exit(0);
294   }
295 }
296
297
298
299
300
301
302
Popular Tags