KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > asap > AsapInstanceBindingImpl


1 /*
2  * AsapInstanceBindingImpl.java
3  *
4  * This file was auto-generated from WSDL by the Apache Axis WSDL2Java emitter.
5  */

6
7 package org.enhydra.shark.asap;
8
9 import java.rmi.RemoteException JavaDoc;
10 import java.util.Map JavaDoc;
11
12 import javax.xml.rpc.holders.StringHolder JavaDoc;
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 /**
20  * ASAP instance service implementaion
21  *
22  * @author V.Puskas
23  * @version 0.11
24  */

25 public class AsapInstanceBindingImpl implements InstancePortType {
26
27    /**
28     * Method getProperties
29     *
30     * @param rqHead a Request
31     * @param rqBody an Object
32     * @param rsHead a ResponseHolder
33     * @param rsBody a GetPropertiesRsHolder
34     * @exception RemoteException
35     */

36    public void getProperties(Request rqHead,
37                              String JavaDoc rqBody,
38                              ResponseHolder rsHead,
39                              GetPropertiesRsHolder rsBody) throws RemoteException JavaDoc {
40
41       try {
42          URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead,
43                                                                 rsHead);
44          String JavaDoc 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 JavaDoc e) {
66          e.printStackTrace();
67          throw new RemoteException JavaDoc(e.getMessage());
68       }
69    }
70
71    /**
72     * Method setProperties
73     *
74     * @param rqHead a Request
75     * @param rqBody a SetPropertiesRq
76     * @param rsHead a ResponseHolder
77     * @param rsBody a SetPropertiesRsHolder
78     * @exception RemoteException
79     */

80    public void setProperties(Request rqHead,
81                              SetPropertiesRq rqBody,
82                              ResponseHolder rsHead,
83                              SetPropertiesRsHolder rsBody) throws RemoteException JavaDoc {
84       try {
85          URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead,
86                                                                 rsHead);
87          String JavaDoc procId = AsapBindingUtilitiesImpl.instanceURI2Id(rqReceiverKey);
88          WfProcess p = SharkServiceImpl.getExecAdmin().getProcess(procId);
89          Map JavaDoc 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 JavaDoc e) {}
114       // rsBody.value.set
115
}
116
117    /**
118     * Method subscribe
119     *
120     * @param rqHead a Request
121     * @param rqBody a SubscribeRq
122     * @param rsHead a ResponseHolder
123     * @param rsBody an ObjectHolder
124     * @exception RemoteException
125     */

126    public void subscribe(Request rqHead,
127                          SubscribeRq rqBody,
128                          ResponseHolder rsHead,
129                          StringHolder JavaDoc rsBody) throws RemoteException JavaDoc {
130       try {
131          URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead,
132                                                                 rsHead);
133          String JavaDoc 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 JavaDoc e) {
141          e.printStackTrace();
142          throw new RemoteException JavaDoc(e.getMessage());
143       }
144    }
145
146    /**
147     * Method unsubscribe
148     *
149     * @param rqHead a Request
150     * @param rqBody an UnsubscribeRq
151     * @param rsHead a ResponseHolder
152     * @param rsBody an ObjectHolder
153     * @exception RemoteException
154     */

155    public void unsubscribe(Request rqHead,
156                            UnsubscribeRq rqBody,
157                            ResponseHolder rsHead,
158                            StringHolder JavaDoc rsBody) throws RemoteException JavaDoc {
159       try {
160          URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead,
161                                                                 rsHead);
162          String JavaDoc 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 JavaDoc e) {
170          throw new RemoteException JavaDoc(e.getMessage());
171       }
172    }
173
174    /**
175     * Method changeState
176     *
177     * @param rqHead a Request
178     * @param rqBody a ChangeStateRq
179     * @param rsHead a ResponseHolder
180     * @param rsBody a ChangeStateRsHolder
181     * @exception RemoteException
182     */

183    public void changeState(Request rqHead,
184                            ChangeStateRq rqBody,
185                            ResponseHolder rsHead,
186                            ChangeStateRsHolder rsBody) throws RemoteException JavaDoc {
187       try {
188          URI rqReceiverKey = AsapBindingUtilitiesImpl.turnHeads(rqHead,
189                                                                 rsHead);
190          String JavaDoc 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 JavaDoc e) {
195          throw new RemoteException JavaDoc(e.getMessage());
196       }
197    }
198
199 }
Popular Tags