1 package org.enhydra.shark.corba.poa; 2 3 import org.enhydra.shark.corba.WorkflowService.*; 4 import org.enhydra.shark.corba.poa.Collective; 5 import org.omg.CORBA.ORB ; 6 import org.omg.WfBase.BaseException; 7 import org.omg.WorkflowModel.*; 8 import org.omg.PortableServer.POAPackage.ServantNotActive ; 9 import org.omg.PortableServer.POAPackage.WrongPolicy ; 10 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 11 12 19 public class SharkConnectionCORBA extends SharkConnectionPOA implements Collective { 20 21 org.enhydra.shark.api.client.wfservice.SharkConnection mySharkConn; 22 private SharkCORBAServer myServer; 23 24 SharkConnectionCORBA(SharkCORBAServer server, org.enhydra.shark.api.client.wfservice.SharkConnection sc) { 25 this.myServer = server; 26 this.mySharkConn = sc; 27 28 40 if (myServer.trackObjects) { 41 __collective = new Collective.CollectiveCORBA(); 42 } 43 } 44 45 public void connect(String userId, 46 String password, 47 String engineName, 48 String scope) throws BaseException, ConnectFailed { 49 try { 50 mySharkConn.connect(userId, password, engineName, scope); 51 } catch (org.enhydra.shark.api.client.wfservice.ConnectFailed cf) { 52 throw new ConnectFailed(); 53 } catch (Exception ex) { 54 throw new BaseException(); 55 } 56 } 57 58 public void disconnect() throws BaseException, NotConnected { 59 try { 60 mySharkConn.disconnect(); 61 } catch (org.enhydra.shark.api.client.wfservice.NotConnected nc) { 62 throw new NotConnected(nc.getMessage()); 63 } catch (Exception ex) { 64 throw new BaseException(); 65 } finally { 66 this.__disband(this._orb()); 67 } 68 } 69 70 public WfResource getResourceObject() throws BaseException, NotConnected { 71 try { 72 WfResource wfRes = SharkCORBAUtilities.makeWfResource( new WfResourceCORBA(myServer.getBoundORB(), this, 73 mySharkConn.getResourceObject())); 74 __recruit(wfRes); 75 return wfRes; 76 } catch (org.enhydra.shark.api.client.wfservice.NotConnected nc) { 77 throw new NotConnected(nc.getMessage()); 78 } catch (Exception ex) { 79 throw new BaseException(); 80 } 81 } 82 83 public WfProcess createProcess(String pkgId, String pDefId) throws BaseException, 84 NotConnected, 85 NotEnabled { 86 try { 87 WfProcess proc = SharkCORBAUtilities.makeWfProcess(new WfProcessCORBA(myServer.getBoundORB(),this, 88 mySharkConn.createProcess(pkgId, 89 pDefId))); 90 __recruit(proc); 91 return proc; 92 93 } catch (org.enhydra.shark.api.client.wfservice.NotConnected nc) { 94 throw new NotConnected(nc.getMessage()); 95 } catch (org.enhydra.shark.api.client.wfmodel.NotEnabled ne) { 96 throw new NotEnabled(ne.getMessage()); 97 } catch (Exception ex) { 98 throw new BaseException(); 99 } 100 } 101 102 public WfProcess createProcessWithRequester (WfRequester requester, 103 String pkgId, 104 String pDefId) throws BaseException, 105 NotConnected, 106 NotEnabled, 107 InvalidRequester, 108 RequesterRequired { 109 try { 110 WfLinkingRequesterForCORBA lr = new WfLinkingRequesterForCORBA(); 111 lr.setOrb(myServer._orb()); 112 org.enhydra.shark.api.client.wfmodel.WfProcess procInternal= 113 mySharkConn.createProcess(lr,pkgId,pDefId); 114 WfLinkingRequesterForCORBA.setCORBARequester(procInternal.key(), requester); 115 WfProcess proc = SharkCORBAUtilities.makeWfProcess(new WfProcessCORBA(myServer.getBoundORB(), this,procInternal)); 116 __recruit(proc); 117 return proc; 118 } catch (org.enhydra.shark.api.client.wfservice.NotConnected nc) { 119 throw new NotConnected(nc.getMessage()); 120 } catch (org.enhydra.shark.api.client.wfmodel.NotEnabled ne) { 121 throw new NotEnabled(ne.getMessage()); 122 } catch (org.enhydra.shark.api.client.wfmodel.InvalidRequester ir) { 123 throw new InvalidRequester(ir.getMessage()); 124 } catch (org.enhydra.shark.api.client.wfmodel.RequesterRequired rr) { 125 throw new RequesterRequired(rr.getMessage()); 126 } catch (Exception ex) { 127 throw new BaseException(); 128 } 129 130 } 131 Collective __collective; 132 133 public void __recruit(org.omg.CORBA.Object obj) { 134 if (myServer.trackObjects) 135 __collective.__recruit(obj); 136 } 137 138 public void __leave(org.omg.CORBA.Object obj) { 139 if (myServer.trackObjects) 140 __collective.__leave(obj); 141 } 142 143 public void __disband(ORB _orb) { 144 if (myServer.trackObjects) { 145 __collective.__disband(_orb); 146 _this()._release(); 147 155 } 156 } 157 158 public void doneWith(org.omg.CORBA.Object toDisconnect) { 159 myServer.doneWith(toDisconnect); 160 __leave(toDisconnect); 161 } 162 } | Popular Tags |