KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.corba.poa;
2
3 import org.omg.WfBase.BaseException;
4 import org.omg.WfBase.NameValueInfo;
5 import org.omg.WorkflowModel.*;
6 import org.omg.CORBA.ORB JavaDoc;
7 import org.omg.PortableServer.POA JavaDoc;
8 import org.omg.PortableServer.POAHelper JavaDoc;
9 import org.omg.PortableServer.POAPackage.ServantAlreadyActive JavaDoc;
10 import org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc;
11 import org.omg.PortableServer.POAPackage.ServantNotActive JavaDoc;
12 import org.enhydra.shark.corba.poa.*;
13
14 /**
15  * WfProcessMgrImpl - Workflow Process Manager implementation
16  */

17
18 public class WfProcessMgrCORBA extends WfProcessMgrPOA {
19
20     org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr;
21
22     private Collective __collective;
23     private ORB JavaDoc orb;
24
25     /**
26      * Creates new WfProcessMgrImpl
27      *
28      * @param sharkProcMgr a WfProcessMgr
29      */

30     protected WfProcessMgrCORBA(ORB JavaDoc orb, Collective toJoin,
31                                 org.enhydra.shark.api.client.wfmodel.WfProcessMgr sharkProcMgr) {
32         __collective = toJoin;
33         this.orb = orb;
34
35       // toJoin.__recruit(this);
36
this.sharkProcMgr = sharkProcMgr;
37     }
38
39     public int how_many_process() throws BaseException {
40         try {
41             return sharkProcMgr.how_many_process();
42         } catch (Exception JavaDoc ex) {
43             throw new BaseException();
44         }
45     }
46
47     public WfProcessIterator get_iterator_process() throws BaseException {
48         try {
49             WfProcessIterator iter = SharkCORBAUtilities.makeWfProcessIterator(new WfProcessIteratorCORBA(orb, __collective,
50                     sharkProcMgr.get_iterator_process()));
51             __collective.__recruit(iter);
52             return iter;
53         } catch (Exception JavaDoc ex) {
54             throw new BaseException();
55         }
56
57     }
58
59     public WfProcess[] get_sequence_process(int max_number) throws BaseException {
60         try {
61             return SharkCORBAUtilities.makeCORBAProcesses(__collective,
62                     sharkProcMgr.get_sequence_process(max_number));
63         } catch (Exception JavaDoc ex) {
64             throw new BaseException();
65         }
66     }
67
68     public boolean is_member_of_process(WfProcess member) throws BaseException {
69         try {
70             WfProcess[] procs = get_sequence_process(0);
71             boolean ret = false;
72             if (procs != null) {
73                 for (int i = 0; i < procs.length; i++) {
74                     if (procs[i].key().equals(member.key())) {
75                         ret = true;
76                         break;
77                     }
78                 }
79             }
80             return ret;
81         } catch (Exception JavaDoc ex) {
82             throw new BaseException();
83         }
84     }
85
86     public process_mgr_stateType process_mgr_state() throws BaseException {
87         try {
88             return process_mgr_stateType.from_int(sharkProcMgr.process_mgr_state()
89                     .value());
90         } catch (Exception JavaDoc ex) {
91             throw new BaseException();
92         }
93     }
94
95     public void set_process_mgr_state(process_mgr_stateType new_state) throws BaseException,
96             TransitionNotAllowed {
97         try {
98             sharkProcMgr.set_process_mgr_state(org.enhydra.shark.api.client.wfmodel.process_mgr_stateType.from_int(new_state.value()));
99         } catch (org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed tna) {
100             throw new TransitionNotAllowed();
101         } catch (Exception JavaDoc ex) {
102             throw new BaseException();
103         }
104     }
105
106     public String JavaDoc name() throws BaseException {
107         try {
108             return sharkProcMgr.name();
109         } catch (Exception JavaDoc ex) {
110             throw new BaseException();
111         }
112     }
113
114     public String JavaDoc description() throws BaseException {
115         try {
116             return sharkProcMgr.description();
117         } catch (Exception JavaDoc ex) {
118             throw new BaseException();
119         }
120     }
121
122     public String JavaDoc category() throws BaseException {
123         try {
124             return sharkProcMgr.category();
125         } catch (Exception JavaDoc ex) {
126             throw new BaseException();
127         }
128     }
129
130     public String JavaDoc version() throws BaseException {
131         try {
132             return sharkProcMgr.version();
133         } catch (Exception JavaDoc ex) {
134             throw new BaseException();
135         }
136     }
137
138     public NameValueInfo[] context_signature() throws BaseException {
139         try {
140             return SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.context_signature());
141         } catch (Exception JavaDoc ex) {
142             throw new BaseException();
143         }
144     }
145
146     public NameValueInfo[] result_signature() throws BaseException {
147         try {
148             return SharkCORBAUtilities.makeCORBANameValueInfoArray(sharkProcMgr.result_signature());
149         } catch (Exception JavaDoc ex) {
150             throw new BaseException();
151         }
152     }
153
154     /**
155      * Create a WfProcess object
156      */

157     public WfProcess create_process(WfRequester requester) throws BaseException,
158             NotEnabled,
159             InvalidRequester,
160             RequesterRequired {
161
162         if (requester == null) throw new RequesterRequired();
163
164         if (requester instanceof WfActivity) {
165             throw new BaseException();
166         }
167         WfProcess pr = null;
168
169         try {
170
171             WfLinkingRequesterForCORBA lr = new WfLinkingRequesterForCORBA();
172             lr.setOrb(orb);
173             org.enhydra.shark.api.client.wfmodel.WfProcess procInternal =
174                     sharkProcMgr.create_process(lr);
175             WfLinkingRequesterForCORBA.setCORBARequester(procInternal.key(), requester);
176
177
178             WfProcessCORBA impl = new WfProcessCORBA(orb, __collective, procInternal);
179            // POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
180
POA JavaDoc rootPOA = SharkCORBAUtilities.getPOA();
181             byte[] o = rootPOA.activate_object(impl);
182             pr = WfProcessHelper.narrow(rootPOA.id_to_reference(o));
183             __collective.__recruit(pr);
184         } catch (ServantAlreadyActive JavaDoc servantAlreadyActive) {
185             servantAlreadyActive.printStackTrace();
186         } catch (WrongPolicy JavaDoc wrongPolicy) {
187             wrongPolicy.printStackTrace();
188      // } catch (ServantNotActive servantNotActive) {
189
// servantNotActive.printStackTrace();
190

191
192         } catch (org.enhydra.shark.api.client.wfmodel.NotEnabled ne) {
193             throw new NotEnabled();
194         } catch (org.enhydra.shark.api.client.wfmodel.InvalidRequester ir) {
195             throw new InvalidRequester();
196         } catch (org.enhydra.shark.api.client.wfmodel.RequesterRequired rr) {
197             throw new RequesterRequired();
198         } catch (Exception JavaDoc ex) {
199             throw new BaseException();
200         }
201         return pr;
202     }
203
204     /**
205      * It is assumed that there can't be two or more processes mgrs
206      * having the same name.
207      */

208     public boolean equals(Object JavaDoc obj) {
209         if (!(obj instanceof WfProcessMgr)) return false;
210         WfProcessMgr mgr = (WfProcessMgr) obj;
211         try {
212             return mgr.name().equals(name());
213         } catch (Exception JavaDoc ex) {
214             return false;
215         }
216     }
217
218     public String JavaDoc toString() {
219         return sharkProcMgr.toString();
220     }
221
222 }
223
224
Popular Tags