1 6 7 package org.enhydra.shark.asap; 8 9 import java.rmi.RemoteException ; 10 import java.util.Map ; 11 12 import javax.xml.rpc.holders.StringHolder ; 13 14 import org.apache.axis.types.URI; 15 import org.enhydra.shark.api.client.wfmodel.WfProcess; 16 import org.enhydra.shark.asap.types.*; 17 import org.enhydra.shark.asap.types.holders.*; 18 19 25 public class AsapInstanceBindingImpl implements InstancePortType { 26 27 36 public void getProperties(Request rqHead, 37 String rqBody, 38 ResponseHolder rsHead, 39 GetPropertiesRsHolder rsBody) throws RemoteException { 40 41 try { 42 URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead, 43 rsHead); 44 String procId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey); 45 WfProcess p = SharkServiceImpl.getExecAdmin().getProcess(procId); 46 RequesterImpl rr = (RequesterImpl) p.requester(); 47 Observers os = AsapBindingUtilitiesImpl.createObservers(rr.getObservers(rqReceiverKey)); 48 HistoryType ht = new HistoryType(AsapBindingUtilitiesImpl.extractEvents(p)); 49 InstancePropertiesGroup iProps = new InstancePropertiesGroup(); 50 iProps.setContextData(new ContextData(AsapBindingUtilitiesImpl.extractData(p.process_context(), 51 p.key()))); 52 iProps.setDescription(p.description()); 53 iProps.setFactoryKey(AsapBindingUtilitiesImpl.createFactoryKey(p.manager() 54 .name())); 55 iProps.setHistory(ht); 56 iProps.setKey(rqReceiverKey); 57 iProps.setName(p.name()); 58 iProps.setObservers(os); 59 iProps.setResultData(new ResultData(AsapBindingUtilitiesImpl.extractData(p.result(), 60 p.key()))); 61 iProps.setState(AsapBindingUtilitiesImpl.parseState(p.state())); 62 iProps.setSubject(""); 63 64 rsBody.value = new GetPropertiesRs(iProps, null, null); 65 } catch (Exception e) { 66 e.printStackTrace(); 67 throw new RemoteException (e.getMessage()); 68 } 69 } 70 71 80 public void setProperties(Request rqHead, 81 SetPropertiesRq rqBody, 82 ResponseHolder rsHead, 83 SetPropertiesRsHolder rsBody) throws RemoteException { 84 try { 85 URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead, 86 rsHead); 87 String procId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey); 88 WfProcess p = SharkServiceImpl.getExecAdmin().getProcess(procId); 89 Map context = AsapBindingUtilitiesImpl.parseContext(rqBody.getData(), 90 p); 91 if (null != context) { 92 p.set_process_context(context); 93 } 94 RequesterImpl rr = (RequesterImpl) p.requester(); 95 Observers os = AsapBindingUtilitiesImpl.createObservers(rr.getObservers(rqReceiverKey)); 96 HistoryType ht = new HistoryType(AsapBindingUtilitiesImpl.extractEvents(p)); 97 InstancePropertiesGroup iProps = new InstancePropertiesGroup(); 98 iProps.setContextData(new ContextData(AsapBindingUtilitiesImpl.extractData(p.process_context(), 99 p.key()))); 100 iProps.setDescription(p.description()); 101 iProps.setFactoryKey(AsapBindingUtilitiesImpl.createFactoryKey(p.manager() 102 .name())); 103 iProps.setHistory(ht); 104 iProps.setKey(rqReceiverKey); 105 iProps.setName(p.name()); 106 iProps.setObservers(os); 107 iProps.setResultData(new ResultData(AsapBindingUtilitiesImpl.extractData(p.result(), 108 p.key()))); 109 iProps.setState(AsapBindingUtilitiesImpl.parseState(p.state())); 110 iProps.setSubject(""); 111 112 rsBody.value = new SetPropertiesRs(iProps, null, null); 113 } catch (Exception e) {} 114 } 116 117 126 public void subscribe(Request rqHead, 127 SubscribeRq rqBody, 128 ResponseHolder rsHead, 129 StringHolder rsBody) throws RemoteException { 130 try { 131 URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead, 132 rsHead); 133 String instanceId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey); 134 WfProcess proc = SharkServiceImpl.getExecAdmin() 135 .getProcess(instanceId); 136 RequesterImpl r = (RequesterImpl) proc.requester(); 137 r.addObserver(rqReceiverKey, rqBody.getObserverKey()); 138 proc.set_requester(r); 139 rsBody.value = ""; 140 } catch (Exception e) { 141 e.printStackTrace(); 142 throw new RemoteException (e.getMessage()); 143 } 144 } 145 146 155 public void unsubscribe(Request rqHead, 156 UnsubscribeRq rqBody, 157 ResponseHolder rsHead, 158 StringHolder rsBody) throws RemoteException { 159 try { 160 URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead, 161 rsHead); 162 String instanceId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey); 163 WfProcess proc = SharkServiceImpl.getExecAdmin() 164 .getProcess(instanceId); 165 RequesterImpl r = (RequesterImpl) proc.requester(); 166 r.removeObserver(rqReceiverKey, rqBody.getObserverKey()); 167 proc.set_requester(r); 168 rsBody.value = ""; 169 } catch (Exception e) { 170 throw new RemoteException (e.getMessage()); 171 } 172 } 173 174 183 public void changeState(Request rqHead, 184 ChangeStateRq rqBody, 185 ResponseHolder rsHead, 186 ChangeStateRsHolder rsBody) throws RemoteException { 187 try { 188 URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead, 189 rsHead); 190 String instanceId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey); 191 WfProcess p = SharkServiceImpl.getExecAdmin().getProcess(instanceId); 192 p.change_state(AsapBindingUtilitiesImpl.parseState(rqBody.getState())); 193 rsBody.value = new ChangeStateRs(AsapBindingUtilitiesImpl.parseState(p.state())); 194 } catch (Exception e) { 195 throw new RemoteException (e.getMessage()); 196 } 197 } 198 199 } | Popular Tags |