KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corba > poa > SharkCORBAServer


1 package org.enhydra.shark.corba.poa;
2
3 // Server will use the naming service.
4
// The package containing special exceptions thrown by the name service.
5

6 import java.util.Properties JavaDoc;
7
8 import org.enhydra.shark.Shark;
9 import org.enhydra.shark.api.client.wfbase.BaseException;
10 import org.enhydra.shark.corba.WorkflowService.*;
11 import org.enhydra.shark.corba.poa.*;
12 import org.omg.WorkflowModel.*;
13 import org.enhydra.shark.utilities.DeadlineChecker;
14 import org.enhydra.shark.utilities.LimitChecker;
15 import org.omg.CORBA.ORB JavaDoc;
16 import org.omg.CORBA.Policy JavaDoc;
17 //import org.omg.CORBA.ORBPackage.*;
18
import org.omg.CosNaming.*;
19 import org.omg.CosNaming.NamingContextPackage.*;
20 //import org.omg.CosNaming.NamingContextPackage.InvalidName;
21
import org.omg.WfBase.NameValueInfo;
22 import org.omg.PortableServer.POAPackage.*;
23 import org.omg.PortableServer.POAManagerPackage.AdapterInactive JavaDoc;
24 import org.omg.PortableServer.*;
25
26
27 /**
28  * The server class for engine. It is registered in 'CORBA' name server.
29  * The client applications has to get this object from the name server.
30  *
31  * @author Sasa Bojanic
32  * @author Vladimir Puskas
33  * @author Rich Robinson
34  * @author Andy Zeneski (jaz@ofbiz.org)
35  * @author David Forslund
36  */

37 public class SharkCORBAServer extends SharkInterfacePOA {
38
39     private org.enhydra.shark.Shark shark;
40
41     private ORB JavaDoc orb;
42
43     private String JavaDoc engineName;
44
45     private String JavaDoc nsHost;
46
47     private String JavaDoc nsPort;
48
49     boolean trackObjects;
50
51     private POA rootPOA;
52     private AdminMisc adminMisc = null;
53     private ExecutionAdministration executionAdmin = null;
54     private MappingAdministration mappingAdmin = null;
55     private PackageAdministration packageAdmin = null;
56     private UserGroupAdministration userGroupAdmin = null;
57     private CacheAdministration cacheAdmin = null;
58     private DeadlineAdministration deadlineAdmin = null;
59     private LimitAdministration limitAdmin = null;
60     private RepositoryMgr repositoryMgr = null;
61     private SharkConnection connect = null;
62     private ExpressionBuilderManager express = null;
63
64     public SharkCORBAServer(String JavaDoc engineName,
65                             String JavaDoc nsHost,
66                             String JavaDoc nsPort,
67                             Shark shark) {
68         // all parameters are required and cannot be null
69
if (engineName == null) throw new IllegalArgumentException JavaDoc("Engine name cannot be null");
70         if (nsHost == null) throw new IllegalArgumentException JavaDoc("Name server host cannot be null");
71         if (nsPort == null) throw new IllegalArgumentException JavaDoc("Name server port cannot be null");
72         if (shark == null) throw new IllegalArgumentException JavaDoc("Shark instance cannot be null");
73
74         this.engineName = engineName;
75         this.nsHost = nsHost;
76         this.nsPort = nsPort;
77         this.shark = shark;
78         this.trackObjects = Boolean.valueOf(shark.getProperties()
79                 .getProperty("CORBAServer.TrackAndDisconnect", "false")).booleanValue();
80         boolean ignoreProblematicRequester = new Boolean JavaDoc(shark.getProperties().getProperty("CORBAServer.ignoreProblematicRequester", "true")).booleanValue();
81         WfLinkingRequesterForCORBA.setIgnoreProblematicRequesterProcess(ignoreProblematicRequester);
82
83
84         // Register a shutdown hook that cleanly shuts down Shark
85
Runtime.getRuntime().addShutdownHook(new Thread JavaDoc() {
86             public void run() {
87                 shutdownORB();
88                 if (null != p) {
89                     p.destroy();
90                 }
91             }
92         });
93     }
94
95     public void startCORBAServer() throws BaseException {
96         // orb conf
97
String JavaDoc[] a1 = {
98             "-ORBInitialHost", nsHost, "-ORBInitialPort", nsPort
99         };
100         String JavaDoc[] a2 = {
101             "-ORBInitRef",
102             "NameService=corbaloc::"
103                 + nsHost + ":" + nsPort
104                 + "/NameService"
105         };
106
107         // create and initialize the ORB
108
String JavaDoc vers = System.getProperty("java.version");
109         System.out.println("java.version " + vers);
110         if (vers.compareTo("1.4") < 0) {
111             orb = ORB.init(a1, null);
112         } else {
113             orb = ORB.init(a2, null);
114         }
115         // org.omg.PortableServer.POA rootPOA = null;
116
try {
117             rootPOA = org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
118             /*
119             Policy[] tpolicy = new Policy[3];
120             tpolicy[0] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
121             tpolicy[1] = rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
122             tpolicy[2] = rootPOA.create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
123             childPOA = rootPOA.create_POA("childPOA",rootPOA.the_POAManager(), tpolicy);
124             */

125             // rootPOA.servant_to_reference(this);
126
} catch (org.omg.CORBA.ORBPackage.InvalidName JavaDoc invalidName) {
127             invalidName.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
128
} /*catch (InvalidPolicy invalidPolicy) {
129             invalidPolicy.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
130         } catch (AdapterAlreadyExists adapterAlreadyExists) {
131             adapterAlreadyExists.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
132         } /*catch (ServantNotActive servantNotActive) {
133             servantNotActive.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
134         } catch (WrongPolicy wrongPolicy) {
135             wrongPolicy.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
136         } */

137         // _this(orb);
138
// orb.connect(this._this_object());
139
// get the root naming context
140
org.omg.CORBA.Object JavaDoc objRef = null;
141         try {
142             objRef = orb.resolve_initial_references("NameService");
143         } catch (Exception JavaDoc ex) {
144             System.err.println("startCORBAServer: " + ex);
145             // The following code is included to enable Shark Server to be
146
// started
147
// from Shark project script that starts all project parts at
148
// ones
149
for (int i = 0; i < 2; i++) {
150
151                 try {
152                     Thread.sleep(2500);
153                     objRef = orb.resolve_initial_references("NameService");
154                 } catch (Exception JavaDoc ex2) {
155                     System.err.println("NameService failed " + ex2);
156                 }
157                 if (objRef != null) {
158                     break;
159                 }
160             }
161         }
162
163         // check the root
164
if (objRef == null) {
165             throw new BaseException("Unable to obtain initial reference from orb");
166         }
167
168         // get the naming context
169
NamingContext ncRef = NamingContextHelper.narrow(objRef);
170         if (ncRef == null) {
171             throw new BaseException("Null NamingContext");
172         } else System.out.println("NameService contacted");
173         // bind the object reference in naming
174
NameComponent nc = new NameComponent(engineName, "");
175         NameComponent path[] = {
176             nc
177         };
178         try {
179             rootPOA.the_POAManager().activate();
180             rootPOA.activate_object(this);
181             SharkCORBAUtilities.setPOA(rootPOA);
182             SharkCORBAUtilities.setORB(orb);
183             ncRef.rebind(path, this._this_object());
184
185             System.out.println("CORBA Server registered and activated");
186         } catch (NotFound e) {
187             throw new BaseException(e);
188         } catch (CannotProceed e) {
189             throw new BaseException(e);
190         } catch (InvalidName e) {
191             throw new BaseException(e);
192         } catch (AdapterInactive JavaDoc adapterInactive) {
193             adapterInactive.printStackTrace();
194         } catch (ServantAlreadyActive es) {
195             es.printStackTrace();
196         } catch (WrongPolicy wp) {
197             wp.printStackTrace();
198         }
199         // start the orb
200
orb.run(); // WARNING this blocks; objects calling this method
201
// should be threaded
202

203     }
204
205     public ORB JavaDoc getBoundORB() {
206         return orb;
207     }
208
209     public void shutdownORB() {
210         try {
211             orb.disconnect(this._this_object());
212             orb.shutdown(false);
213         } catch (Exception JavaDoc e) {
214             // maybe throw some log4j in here
215
}
216     }
217
218     void shutdown() {
219         shutdownORB();
220         System.exit(0);
221     }
222
223     public AdminMisc getAdminMisc() {
224       // if (adminMisc != null) return adminMisc;
225
AdminMiscCORBA adminMiscImpl = new AdminMiscCORBA(this, shark.getAdminInterface()
226                 .getAdminMisc());
227
228
229
230         try {
231             byte[] o = rootPOA.activate_object(adminMiscImpl);
232             adminMisc = AdminMiscHelper.narrow(rootPOA.id_to_reference(o));
233
234         } catch (ServantAlreadyActive servantAlreadyActive) {
235             servantAlreadyActive.printStackTrace();
236         } catch (WrongPolicy wrongPolicy) {
237             wrongPolicy.printStackTrace();
238         } catch (ObjectNotActive objectNotActive) {
239             objectNotActive.printStackTrace();
240         }
241
242         return adminMisc;
243     }
244
245     public ExecutionAdministration getExecutionAdministration() {
246
247      // if (executionAdmin != null) return executionAdmin;
248
ExecutionAdminCORBA executionAdminImpl = new ExecutionAdminCORBA(this, shark.getAdminInterface()
249                 .getExecutionAdministration());
250
251         try {
252             rootPOA.activate_object(executionAdminImpl);
253             executionAdmin = ExecutionAdministrationHelper.narrow(rootPOA.servant_to_reference(executionAdminImpl));
254
255         } catch (ServantAlreadyActive servantAlreadyActive) {
256             servantAlreadyActive.printStackTrace();
257         } catch (WrongPolicy wrongPolicy) {
258             wrongPolicy.printStackTrace();
259         } catch (ServantNotActive servantNotActive) {
260             servantNotActive.printStackTrace();
261         }
262
263         return executionAdmin;
264     }
265
266     public MappingAdministration getMappingAdministration() {
267
268    // if (mappingAdmin != null) return mappingAdmin;
269
MappingAdminCORBA mappingAdminImpl = new MappingAdminCORBA(this, shark.getAdminInterface()
270                 .getParticipantMappingAdministration(), shark.getAdminInterface()
271                 .getApplicationMappingAdministration());
272
273         try {
274             rootPOA.activate_object(mappingAdminImpl);
275             mappingAdmin = MappingAdministrationHelper.narrow(rootPOA.servant_to_reference(mappingAdminImpl));
276
277         } catch (ServantAlreadyActive servantAlreadyActive) {
278             servantAlreadyActive.printStackTrace();
279         } catch (WrongPolicy wrongPolicy) {
280             wrongPolicy.printStackTrace();
281         } catch (ServantNotActive servantNotActive) {
282             servantNotActive.printStackTrace();
283         }
284
285         return mappingAdmin;
286
287     }
288
289     public PackageAdministration getPackageAdministration() {
290       // if (packageAdmin != null) return packageAdmin;
291
PackageAdminCORBA packageAdminImpl = new PackageAdminCORBA(this, shark.getAdminInterface()
292                 .getPackageAdministration());
293
294         try {
295             rootPOA.activate_object(packageAdminImpl);
296             packageAdmin = PackageAdministrationHelper.narrow(rootPOA.servant_to_reference(packageAdminImpl));
297
298         } catch (ServantAlreadyActive servantAlreadyActive) {
299             servantAlreadyActive.printStackTrace();
300         } catch (WrongPolicy wrongPolicy) {
301             wrongPolicy.printStackTrace();
302         } catch (ServantNotActive servantNotActive) {
303             servantNotActive.printStackTrace();
304         }
305
306         return packageAdmin;
307
308     }
309
310     public UserGroupAdministration getUserGroupAdministration() {
311       // if (userGroupAdmin != null) return userGroupAdmin;
312
UserGroupAdminCORBA userGroupAdminImpl = new UserGroupAdminCORBA(this, shark.getAdminInterface()
313                 .getUserGroupAdministration());
314
315         try {
316             rootPOA.activate_object(userGroupAdminImpl);
317             userGroupAdmin = UserGroupAdministrationHelper.narrow(rootPOA.servant_to_reference(userGroupAdminImpl));
318
319         } catch (ServantAlreadyActive servantAlreadyActive) {
320             servantAlreadyActive.printStackTrace();
321         } catch (WrongPolicy wrongPolicy) {
322             wrongPolicy.printStackTrace();
323         } catch (ServantNotActive servantNotActive) {
324             servantNotActive.printStackTrace();
325         }
326
327         return userGroupAdmin;
328     }
329
330     public CacheAdministration getCacheAdministration() {
331
332      // if (cacheAdmin != null) return cacheAdmin;
333
CacheAdminCORBA cacheAdminImpl = new CacheAdminCORBA(this, shark.getAdminInterface()
334                 .getCacheAdministration());
335
336         try {
337             rootPOA.activate_object(cacheAdminImpl);
338             cacheAdmin = CacheAdministrationHelper.narrow(rootPOA.servant_to_reference(cacheAdminImpl));
339
340         } catch (ServantAlreadyActive servantAlreadyActive) {
341             servantAlreadyActive.printStackTrace();
342         } catch (WrongPolicy wrongPolicy) {
343             wrongPolicy.printStackTrace();
344         } catch (ServantNotActive servantNotActive) {
345             servantNotActive.printStackTrace();
346         }
347
348         return cacheAdmin;
349     }
350
351     public DeadlineAdministration getDeadlineAdministration() {
352
353       // if (deadlineAdmin != null) return deadlineAdmin;
354
DeadlineAdminCORBA deadlineAdminImpl = new DeadlineAdminCORBA(this, shark.getAdminInterface()
355                 .getDeadlineAdministration());
356
357         try {
358             rootPOA.activate_object(deadlineAdminImpl);
359             deadlineAdmin = DeadlineAdministrationHelper.narrow(rootPOA.servant_to_reference(deadlineAdminImpl));
360
361         } catch (ServantAlreadyActive servantAlreadyActive) {
362             servantAlreadyActive.printStackTrace();
363         } catch (WrongPolicy wrongPolicy) {
364             wrongPolicy.printStackTrace();
365         } catch (ServantNotActive servantNotActive) {
366             servantNotActive.printStackTrace();
367         }
368
369         return deadlineAdmin;
370     }
371
372     public LimitAdministration getLimitAdministration() {
373       // if (limitAdmin != null) return limitAdmin;
374
LimitAdminCORBA limitAdminImpl = new LimitAdminCORBA(this, shark.getAdminInterface()
375                 .getLimitAdministration());
376
377         try {
378             rootPOA.activate_object(limitAdminImpl);
379             limitAdmin = LimitAdministrationHelper.narrow(rootPOA.servant_to_reference(limitAdminImpl));
380
381         } catch (ServantAlreadyActive servantAlreadyActive) {
382             servantAlreadyActive.printStackTrace();
383         } catch (WrongPolicy wrongPolicy) {
384             wrongPolicy.printStackTrace();
385         } catch (ServantNotActive servantNotActive) {
386             servantNotActive.printStackTrace();
387         }
388
389         return limitAdmin;
390     }
391
392     public RepositoryMgr getRepositoryManager() {
393
394     // if (repositoryMgr != null) return repositoryMgr;
395
RepositoryManagerCORBA repositoryManagerImpl = new RepositoryManagerCORBA(this, shark.getRepositoryManager());
396
397         try {
398             rootPOA.activate_object(repositoryManagerImpl);
399             repositoryMgr = RepositoryMgrHelper.narrow(rootPOA.servant_to_reference(repositoryManagerImpl));
400
401         } catch (ServantAlreadyActive servantAlreadyActive) {
402             servantAlreadyActive.printStackTrace();
403         } catch (WrongPolicy wrongPolicy) {
404             wrongPolicy.printStackTrace();
405         } catch (ServantNotActive servantNotActive) {
406             servantNotActive.printStackTrace();
407         }
408
409         return repositoryMgr;
410     }
411
412     public SharkConnection getSharkConnection() {
413
414      // if (connect != null) return connect;
415
SharkConnectionCORBA connectImpl = new SharkConnectionCORBA(this, shark.getSharkConnection());
416         try {
417             rootPOA.activate_object(connectImpl);
418             connect = SharkConnectionHelper.narrow(rootPOA.servant_to_reference(connectImpl));
419
420         } catch (ServantAlreadyActive servantAlreadyActive) {
421             servantAlreadyActive.printStackTrace();
422         } catch (WrongPolicy wrongPolicy) {
423             wrongPolicy.printStackTrace();
424         } catch (ServantNotActive servantNotActive) {
425             servantNotActive.printStackTrace();
426         }
427
428         return connect;
429         // return new SharkConnectionCORBA(this, shark.getSharkConnection())._this();
430
}
431
432     public ExpressionBuilderManager getExpressionBuilderManager() {
433
434  // if (express != null) return express;
435
ExpressionBuilderMgrCORBA expressionBuilderMgrImpl = new ExpressionBuilderMgrCORBA(this, shark.getExpressionBuilderManager());
436
437         try {
438             rootPOA.activate_object(expressionBuilderMgrImpl);
439             express = ExpressionBuilderManagerHelper.narrow(rootPOA.servant_to_reference(expressionBuilderMgrImpl));
440             if (express == null) System.err.println("getExpressBuilderManager: " + express);
441         } catch (ServantAlreadyActive servantAlreadyActive) {
442             servantAlreadyActive.printStackTrace();
443         } catch (WrongPolicy wrongPolicy) {
444             wrongPolicy.printStackTrace();
445         } catch (ServantNotActive servantNotActive) {
446             servantNotActive.printStackTrace();
447         }
448
449         return express;
450     }
451
452     public NameValueInfo[] getProperties() {
453         return SharkCORBAUtilities.makeCORBANameValueInfoArray(shark.getProperties());
454     }
455
456     boolean validateUser(String JavaDoc username, String JavaDoc pwd) {
457         try {
458             return shark.validateUser(username, pwd);
459         } catch (Exception JavaDoc ex) {
460             return true;
461         }
462     }
463
464     private static Process JavaDoc p;
465
466     private static long nameserverRestart_ms = 0;
467
468     //private static Thread penelope;
469
// If exists, first argument is the path to Shark configuration file
470
public static void main(String JavaDoc args[]) {
471         try {
472             if (args != null && args.length > 0) {
473                 Shark.configure(args[0]);
474             } else {
475                 Shark.configure();
476             }
477
478             org.enhydra.shark.Shark shark = Shark.getInstance();
479
480             Properties JavaDoc properties = shark.getProperties();
481             String JavaDoc nameserverhost = properties.getProperty("nameserverhost",
482                     "localhost");
483             final String JavaDoc nameserverport = properties.getProperty("nameserverport",
484                     "10123");
485             String JavaDoc enginename = properties.getProperty("enginename", "Shark");
486             final String JavaDoc nameServerExecutable = properties.getProperty("nameserver.executable",
487                     null);
488             String JavaDoc nameserverRestart = properties.getProperty("nameserver.restarting_period_minutes",
489                     "0");
490
491             double nsrmin = 0;
492             try {
493                 nsrmin = Double.parseDouble(nameserverRestart);
494                 nameserverRestart_ms = (long) (nsrmin * 60 * 1000);
495             } catch (Exception JavaDoc ex) {
496             }
497             // create default user
498
try {
499                 org.enhydra.shark.api.client.wfservice.UserGroupAdministration uga = shark.getAdminInterface()
500                         .getUserGroupAdministration();
501                 String JavaDoc adminGroup = properties.getProperty("DEFAULT_ADMINISTRATOR_GROUP_NAME",
502                         "AdminGroup");
503                 String JavaDoc adminGroupDescripton = properties.getProperty("DEFAULT_ADMINISTRATOR_GROUP_DESCRIPTION",
504                         "Default Admin Group");
505                 String JavaDoc adminUsername = properties.getProperty("DEFAULT_ADMINISTRATOR_USERNAME",
506                         "admin");
507                 String JavaDoc adminPwd = properties.getProperty("DEFAULT_ADMINISTRATOR_PASSWORD",
508                         "enhydra");
509                 String JavaDoc adminFirstName = properties.getProperty("DEFAULT_ADMINISTRATOR_FIRST_NAME",
510                         "Administrator");
511                 String JavaDoc adminLastName = properties.getProperty("DEFAULT_ADMINISTRATOR_LAST_NAME",
512                         "Admin");
513                 String JavaDoc adminEmail = properties.getProperty("DEFAULT_ADMINISTRATOR_EMAIL",
514                         "admin@together.at");
515                 try {
516                     if (!uga.doesGroupExist(adminGroup)) {
517                         uga.createGroup(adminGroup, adminGroupDescripton);
518                     }
519                 } catch (Exception JavaDoc ex) {
520                 }
521                 if (!uga.doesUserExist(adminUsername)) {
522                     uga.createUser(adminGroup,
523                             adminUsername,
524                             adminPwd,
525                             adminFirstName,
526                             adminLastName,
527                             adminEmail);
528                 }
529             } catch (Exception JavaDoc ex) {
530             }
531
532             // initialize deadline timer
533
String JavaDoc delay = null;
534             if (args != null && args.length > 1) {
535                 delay = args[1];
536             } else {
537                 delay = properties.getProperty("Deadlines.pollingTime", "300000");
538             }
539             if (properties.getProperty("Deadlines.SERVER_SIDE_CHECKING", "false")
540                     .equals("true")) {
541                 new DeadlineChecker(shark.getAdminInterface()
542                         .getDeadlineAdministration(), Long.parseLong(delay));
543             }
544
545             // initialize limit timer
546
String JavaDoc ldelay = null;
547             String JavaDoc lacn = properties.getProperty("LimitAgentManagerClassName");
548             if (lacn != null) {
549                 if (args != null && args.length > 2) {
550                     ldelay = args[2];
551                 } else {
552                     ldelay = properties.getProperty("Limits.pollingTime", "60000");
553                 }
554                 if (properties.getProperty("Limits.SERVER_SIDE_CHECKING", "false")
555                         .equals("true")) {
556                     new LimitChecker(shark.getAdminInterface()
557                             .getLimitAdministration(), Long.parseLong(ldelay));
558                 }
559             }
560
561             // create/start the server
562
final SharkCORBAServer ws = new SharkCORBAServer(enginename,
563                     nameserverhost,
564                     nameserverport,
565                     shark);
566             if (null != nameServerExecutable) {
567                 if (nameserverRestart_ms > 0) {
568                     System.out.println("Nameserver will be restarted every "
569                             + nameserverRestart + " minutes!");
570                 }
571
572                 new Thread JavaDoc() {
573                     public void run() {
574                         while (true) {
575                             try {
576                                 p = Runtime.getRuntime().exec(nameServerExecutable
577                                         + " -ORBInitialPort "
578                                         + nameserverport);
579
580                                 System.out.println("Nameserver is (re)started!");
581                                 // (re)register with name server in a separate
582
// thread
583
new Thread JavaDoc() {
584                                     public void run() {
585                                         try {
586                                             ws.startCORBAServer();
587                                         } catch (Exception JavaDoc ex) {
588                                             ex.printStackTrace(System.out);
589                                             throw new Error JavaDoc();
590
591                                         }
592                                     }
593                                 }.start();
594                                 if (nameserverRestart_ms > 0) {
595                                     new Thread JavaDoc() {
596                                         public void run() {
597                                             try {
598                                                 Thread.sleep(nameserverRestart_ms);
599                                             } catch (Exception JavaDoc ex) {
600                                             } finally {
601                                                 p.destroy();
602                                             }
603                                         }
604                                     }.start();
605                                 }
606
607                             } catch (Throwable JavaDoc t) {
608                                 t.printStackTrace();
609                                 System.out.println("Didn't start the nameserver");
610                                 //throw new RootError("Didn't start the
611
// nameserver",t);
612
}
613
614                             while (true) {
615                                 try {
616                                     p.waitFor();
617                                 } catch (InterruptedException JavaDoc e) {
618                                     continue;
619                                 }
620
621                                 // Process is terminated
622
break;
623                             }
624                         }
625                     }
626                 }.start();
627             } else {
628                 ws.startCORBAServer();
629             }
630
631         } catch (Throwable JavaDoc e) {
632             e.printStackTrace(System.out);
633             throw new Error JavaDoc();
634         }
635     }
636
637     public void doneWith(org.omg.CORBA.Object JavaDoc toDisconnect) {
638         // get the servant associated with this CORBA object
639
Servant s = null;
640         try {
641             s = rootPOA.reference_to_servant(toDisconnect);
642         } catch (ObjectNotActive objectNotActive) {
643             objectNotActive.printStackTrace();
644         } catch (WrongPolicy wrongPolicy) {
645             wrongPolicy.printStackTrace();
646         } catch (WrongAdapter wrongAdapter) {
647             wrongAdapter.printStackTrace();
648         }
649
650         if (s instanceof Collective) {
651             ((Collective) s).__disband(orb);
652         } else {
653             try {
654                 if (toDisconnect instanceof WfCreateProcessEventAudit) {
655                     WfLinkingRequesterForCORBA.emptyCollective(((WfCreateProcessEventAudit) toDisconnect).process_key(), getBoundORB());
656                 }
657                 if (toDisconnect instanceof WfDataEventAudit) {
658                     WfLinkingRequesterForCORBA.emptyCollective(((WfDataEventAudit) toDisconnect).process_key(), getBoundORB());
659                 }
660                 if (toDisconnect instanceof WfStateEventAudit) {
661                     WfLinkingRequesterForCORBA.emptyCollective(((WfStateEventAudit) toDisconnect).process_key(), getBoundORB());
662                 }
663                 toDisconnect._release();;
664                // orb.disconnect(toDisconnect);
665
} catch (Exception JavaDoc ex) {
666                 System.err.println("exception in doneWith" +ex);
667             }
668         }
669     }
670 }
671
672
Popular Tags