KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.corba.poa;
2
3 import org.enhydra.shark.corba.ExpressionBuilders.*;
4 import org.enhydra.shark.corba.WorkflowService.ConnectFailed;
5 import org.enhydra.shark.corba.WorkflowService.NotConnected;
6 import org.enhydra.shark.corba.WorkflowService.ExpressionBuilderManagerPOA;
7 import org.enhydra.shark.corba.poa.ActivityIteratorExpressionBuilderCORBA;
8 import org.enhydra.shark.corba.poa.AssignmentIteratorExpressionBuilderCORBA;
9 import org.enhydra.shark.corba.poa.Collective;
10 import org.omg.CORBA.ORB JavaDoc;
11 import org.omg.CORBA.ORBPackage.InvalidName JavaDoc;
12 import org.omg.WfBase.BaseException;
13 import org.omg.PortableServer.POAPackage.ServantAlreadyActive JavaDoc;
14 import org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc;
15 import org.omg.PortableServer.POAPackage.ServantNotActive JavaDoc;
16 import org.omg.PortableServer.POAPackage.ObjectNotActive JavaDoc;
17 import org.omg.PortableServer.POA JavaDoc;
18 import org.omg.PortableServer.POAHelper JavaDoc;
19 import org.omg.PortableServer.POAManagerPackage.AdapterInactive JavaDoc;
20
21 /**
22  * The client interface through which client gets engine's
23  * iterator expression builders.
24  * @author David Forslund
25  */

26 public class ExpressionBuilderMgrCORBA extends ExpressionBuilderManagerPOA implements Collective{
27
28    org.enhydra.shark.api.client.wfservice.ExpressionBuilderManager myEBM;
29    private SharkCORBAServer myServer;
30    private Collective __collective;
31    private AssignmentIteratorExpressionBuilder assignmentIteratorExpressionBuilder = null;
32    private ActivityIteratorExpressionBuilder activityIteratorExpressionBuilder = null;
33    private ProcessIteratorExpressionBuilder processIteratorExpressionBuilder = null;
34    private ProcessMgrIteratorExpressionBuilder processMgrIteratorExpressionBuilder = null;
35     private ResourceIteratorExpressionBuilder resourceIteratorExpressionBuilder = null;
36
37    public ExpressionBuilderMgrCORBA (SharkCORBAServer server, org.enhydra.shark.api.client.wfservice.ExpressionBuilderManager ebm) {
38       this.myEBM=ebm;
39       this.myServer = server;
40
41       if (myServer.trackObjects) {
42          __collective = new Collective.CollectiveCORBA();
43       }
44    }
45
46    public void connect(String JavaDoc userId, String JavaDoc password, String JavaDoc engineName, String JavaDoc scope) throws BaseException, ConnectFailed {
47       try {
48          if (!myServer.validateUser(userId,password)) {
49             throw new ConnectFailed("Connection failed, invalid username or password");
50          }
51       } catch (ConnectFailed cf) {
52          throw cf;
53       } catch (Exception JavaDoc ex) {
54          throw new BaseException();
55       }
56    }
57
58    public void disconnect() throws BaseException, NotConnected {
59       this.__disband(this._orb());
60    }
61
62    public ActivityIteratorExpressionBuilder getActivityIteratorExpressionBuilder () {
63      // if (activityIteratorExpressionBuilder != null) return activityIteratorExpressionBuilder;
64
ActivityIteratorExpressionBuilderCORBA impl = new ActivityIteratorExpressionBuilderCORBA( myEBM.getActivityIteratorExpressionBuilder());
65       try {
66           // POA rootPOA = POAHelper.narrow(myServer._orb().resolve_initial_references("RootPOA"));
67
POA rootPOA = SharkCORBAUtilities.getPOA();
68             byte[] o = rootPOA.activate_object(impl);
69            activityIteratorExpressionBuilder = ActivityIteratorExpressionBuilderHelper.narrow(rootPOA.id_to_reference(o));
70
71        } catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
72            servantAlreadyActive.printStackTrace();
73        } catch (WrongPolicy JavaDoc wrongPolicy) {
74            wrongPolicy.printStackTrace();
75        }catch (ObjectNotActive JavaDoc objectNotActive) {
76                objectNotActive.printStackTrace();
77       // } catch (InvalidName in ) {
78
// in.printStackTrace();
79
}
80
81       this.__recruit(activityIteratorExpressionBuilder);
82       return activityIteratorExpressionBuilder;
83    }
84
85    public AssignmentIteratorExpressionBuilder getAssignmentIteratorExpressionBuilder () {
86     // if (assignmentIteratorExpressionBuilder != null) return assignmentIteratorExpressionBuilder;
87
AssignmentIteratorExpressionBuilderCORBA impl = new AssignmentIteratorExpressionBuilderCORBA( myEBM.getAssignmentIteratorExpressionBuilder());
88
89        try {
90           // POA rootPOA = POAHelper.narrow(myServer._orb().resolve_initial_references("RootPOA"));
91
POA rootPOA = SharkCORBAUtilities.getPOA();
92            byte[] o = rootPOA.activate_object(impl);
93            assignmentIteratorExpressionBuilder = AssignmentIteratorExpressionBuilderHelper.narrow(rootPOA.id_to_reference(o));
94
95        } catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
96            servantAlreadyActive.printStackTrace();
97        } catch (WrongPolicy JavaDoc wrongPolicy) {
98            wrongPolicy.printStackTrace();
99       } catch (ObjectNotActive JavaDoc objectNotActive) {
100                objectNotActive.printStackTrace();
101      // } catch (InvalidName in ) {
102
// in.printStackTrace();
103
}
104
105       this.__recruit(assignmentIteratorExpressionBuilder);
106       return assignmentIteratorExpressionBuilder;
107    }
108
109    public EventAuditIteratorExpressionBuilder getEventAuditIteratorExpressionBuilder () {
110       throw new RuntimeException JavaDoc("Currently not implemented !");
111       //ret = new EventAuditIteratorExpressionBuilderCORBA(myEBM.getEventAuditIteratorExpressionBuilder());
112
}
113
114    public ProcessIteratorExpressionBuilder getProcessIteratorExpressionBuilder () {
115     // if( processIteratorExpressionBuilder !=null) return processIteratorExpressionBuilder;
116
ProcessIteratorExpressionBuilderCORBA impl = new ProcessIteratorExpressionBuilderCORBA(myEBM.getProcessIteratorExpressionBuilder());
117        try {
118            // POA rootPOA = POAHelper.narrow(myServer._orb().resolve_initial_references("RootPOA"));
119
POA rootPOA = SharkCORBAUtilities.getPOA();
120             byte[] o = rootPOA.activate_object(impl);
121             processIteratorExpressionBuilder = ProcessIteratorExpressionBuilderHelper.narrow(rootPOA.id_to_reference(o));
122          // ret = impl._this();
123

124         } catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
125             servantAlreadyActive.printStackTrace();
126         } catch (WrongPolicy JavaDoc wrongPolicy) {
127             wrongPolicy.printStackTrace();
128         } catch (ObjectNotActive JavaDoc objectNotActive) {
129               objectNotActive.printStackTrace();
130       // } catch (InvalidName in) {
131
// in.printStackTrace();
132
}
133
134       this.__recruit(processIteratorExpressionBuilder);
135       return processIteratorExpressionBuilder;
136    }
137
138    public ProcessMgrIteratorExpressionBuilder getProcessMgrIteratorExpressionBuilder () {
139      // if (processMgrIteratorExpressionBuilder != null) return processMgrIteratorExpressionBuilder;
140
ProcessMgrIteratorExpressionBuilderCORBA impl = new ProcessMgrIteratorExpressionBuilderCORBA( myEBM.getProcessMgrIteratorExpressionBuilder());
141        try {
142         // POA rootPOA = POAHelper.narrow(myServer._orb().resolve_initial_references("RootPOA"));
143
// rootPOA.the_POAManager().activate();
144
POA rootPOA = SharkCORBAUtilities.getPOA();
145            byte[] o = rootPOA.activate_object(impl);
146           // ret = impl._this();
147
processMgrIteratorExpressionBuilder = ProcessMgrIteratorExpressionBuilderHelper.narrow(rootPOA.id_to_reference(o));
148
149         } catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
150             //servantAlreadyActive.printStackTrace();
151
} catch (WrongPolicy JavaDoc wrongPolicy) {
152             wrongPolicy.printStackTrace();
153      } catch (ObjectNotActive JavaDoc inActive) {
154                inActive.printStackTrace();
155      // } catch (InvalidName in) {
156
// in.printStackTrace();
157
}
158       this.__recruit(processMgrIteratorExpressionBuilder);
159       return processMgrIteratorExpressionBuilder;
160    }
161
162    public ResourceIteratorExpressionBuilder getResourceIteratorExpressionBuilder () {
163      // if(resourceIteratorExpressionBuilder != null) return resourceIteratorExpressionBuilder;
164
ResourceIteratorExpressionBuilderCORBA impl = new ResourceIteratorExpressionBuilderCORBA(myEBM.getResourceIteratorExpressionBuilder());
165        try {
166          // POA rootPOA = POAHelper.narrow(myServer._orb().resolve_initial_references("RootPOA"));
167
POA rootPOA = SharkCORBAUtilities.getPOA();
168            byte[] o = rootPOA.activate_object(impl);
169            resourceIteratorExpressionBuilder = ResourceIteratorExpressionBuilderHelper.narrow(rootPOA.id_to_reference(o));
170           // ret = impl._this();
171
} catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
172             servantAlreadyActive.printStackTrace();
173         } catch (WrongPolicy JavaDoc wrongPolicy) {
174             wrongPolicy.printStackTrace();
175    // } catch (ServantNotActive notActive) {
176
// notActive.printStackTrace();
177
} catch (ObjectNotActive JavaDoc objectNotActive) {
178            objectNotActive.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
179
}
180       this.__recruit(resourceIteratorExpressionBuilder);
181       return resourceIteratorExpressionBuilder;
182    }
183
184    public void __recruit(org.omg.CORBA.Object JavaDoc obj) {
185       if (myServer.trackObjects)
186          __collective.__recruit(obj);
187    }
188
189    public void __leave(org.omg.CORBA.Object JavaDoc obj) {
190       if (myServer.trackObjects)
191          __collective.__leave(obj);
192    }
193
194    public void __disband(ORB JavaDoc _orb) {
195       if (myServer.trackObjects) {
196          __collective.__disband(_orb);
197       }
198    // try {
199
_this()._release();
200    // } catch (BaseException e) {
201
// e.printStackTrace();
202
// } catch (NotConnected notConnected) {
203
// notConnected.printStackTrace();
204
// }
205
}
206 }
207
Popular Tags