001: /* WfProcessSSBean.java */
002: package org.enhydra.shark.ejb;
003:
004: import java.rmi.RemoteException;
005: import java.util.Map;
006:
007: import javax.ejb.EJBException;
008: import javax.ejb.EJBObject;
009: import javax.ejb.SessionBean;
010: import javax.ejb.SessionContext;
011: import javax.naming.Context;
012: import javax.naming.InitialContext;
013: import javax.rmi.PortableRemoteObject;
014:
015: import org.enhydra.shark.api.client.timebase.UtcT;
016: import org.enhydra.shark.api.client.wfmodel.AlreadyRunning;
017: import org.enhydra.shark.api.client.wfmodel.AlreadySuspended;
018: import org.enhydra.shark.api.client.wfmodel.CannotChangeRequester;
019: import org.enhydra.shark.api.client.wfmodel.CannotResume;
020: import org.enhydra.shark.api.client.wfmodel.CannotStart;
021: import org.enhydra.shark.api.client.wfmodel.CannotStop;
022: import org.enhydra.shark.api.client.wfmodel.CannotSuspend;
023: import org.enhydra.shark.api.client.wfmodel.HistoryNotAvailable;
024: import org.enhydra.shark.api.client.wfmodel.InvalidData;
025: import org.enhydra.shark.api.client.wfmodel.InvalidState;
026: import org.enhydra.shark.api.client.wfmodel.NotRunning;
027: import org.enhydra.shark.api.client.wfmodel.NotSuspended;
028: import org.enhydra.shark.api.client.wfmodel.ResultNotAvailable;
029: import org.enhydra.shark.api.client.wfmodel.TransitionNotAllowed;
030: import org.enhydra.shark.api.client.wfmodel.UpdateNotAllowed;
031: import org.enhydra.shark.api.client.wfmodel.WfActivity;
032: import org.enhydra.shark.api.client.wfmodel.WfActivityIterator;
033: import org.enhydra.shark.api.client.wfmodel.WfEventAudit;
034: import org.enhydra.shark.api.client.wfmodel.WfEventAuditIterator;
035: import org.enhydra.shark.api.client.wfmodel.WfExecutionObject;
036: import org.enhydra.shark.api.client.wfmodel.WfProcess;
037: import org.enhydra.shark.api.client.wfmodel.WfProcessMgr;
038: import org.enhydra.shark.api.client.wfmodel.WfRequester;
039: import org.enhydra.shark.api.client.wfmodel.how_closedType;
040: import org.enhydra.shark.api.client.wfmodel.while_openType;
041: import org.enhydra.shark.api.client.wfmodel.why_not_runningType;
042: import org.enhydra.shark.api.client.wfmodel.workflow_stateType;
043:
044: /**
045: * @ejb.bean
046: * name="WfProcessSS"
047: * type="Stateful"
048: * display-name="WfProcess"
049: * jndi-name="org/enhydra/shark/ejb/WfProcessSS"
050: * local-jndi-name="org/enhydra/shark/ejb/WfProcessSSLocal"
051: * transaction-type="Container"
052: * view-type="both"
053: * local-business-interface="org.enhydra.shark.api.client.wfmodel.WfProcess"
054: *
055: * @ejb.ejb-ref ejb-name="WfEventAuditIteratorSS"
056: * view-type="both"
057: * ref-name="org/enhydra/shark/ejb/WfEventAuditIteratorSS"
058: * @ejb.ejb-ref ejb-name="WfAssignmentEventAuditSS"
059: * view-type="both"
060: * ref-name="org/enhydra/shark/ejb/WfAssignmentEventAuditSS"
061: * @ejb.ejb-ref ejb-name="WfCreateProcessEventAuditSS"
062: * view-type="both"
063: * ref-name="org/enhydra/shark/ejb/WfCreateProcessEventAuditSS"
064: * @ejb.ejb-ref ejb-name="WfDataEventAuditSS"
065: * view-type="both"
066: * ref-name="org/enhydra/shark/ejb/WfDataEventAuditSS"
067: * @ejb.ejb-ref ejb-name="WfPackageEventAuditSS"
068: * view-type="both"
069: * ref-name="org/enhydra/shark/ejb/WfPackageEventAuditSS"
070: * @ejb.ejb-ref ejb-name="WfStateEventAuditSS"
071: * view-type="both"
072: * ref-name="org/enhydra/shark/ejb/WfStateEventAuditSS"
073: * @ejb.ejb-ref ejb-name="WfRequesterSS"
074: * view-type="both"
075: * ref-name="org/enhydra/shark/ejb/WfRequesterSS"
076: * @ejb.ejb-ref ejb-name="WfActivitySS"
077: * view-type="both"
078: * ref-name="org/enhydra/shark/ejb/WfActivitySS"
079: * @ejb.ejb-ref ejb-name="WfActivityIteratorSS"
080: * view-type="both"
081: * ref-name="org/enhydra/shark/ejb/WfActivityIteratorSS"
082: * @ejb.ejb-ref ejb-name="WfProcessMgrSS"
083: * view-type="both"
084: * ref-name="org/enhydra/shark/ejb/WfProcessMgrSS"
085: *
086: * @ejb:interface
087: * extends="org.enhydra.shark.api.client.wfmodel.WfProcess,javax.ejb.EJBObject"
088: *
089: * @ejb:transaction
090: * type="Required"
091: *
092: * @jonas:bean
093: * ejb-name="WfProcessSS"
094: * jndi-name="org/enhydra/shark/ejb/WfProcessSS"
095: *
096: * OMG definition: A WfProcess is the performer of a workflow request. All workflow
097: * objects that perform work implement this interface. This interface allows work to
098: * proceed asynchronously while being monitored and controlled. The WfProcess interface
099: * specializes WfExecutionObject interface by adding an operation to start the execution
100: * of the process, an operation to obtain the result produced by the process and
101: * relationships with WfRequester and WfActivity.
102: * <p>
103: * We extended OMG's interface by duplicating methods, and adding additional parameter
104: * that represents transaction. If you use methods without SharkTransaction parameter, the
105: * transaction will be implicitly created, and if you use it with SharkTransaction
106: * parameter you must obey to some rules explained in HowTo documentation.
107: *
108: * @author V.Puskas
109: * @author S.Bojanic
110: * @author T.Jovanovic
111: * @version 0.1
112: */
113: public abstract class WfProcessSSBean implements WfProcess, SessionBean {
114:
115: private SessionContext context;
116: private org.enhydra.shark.api.client.wfmodel.WfProcess sharkObj;
117:
118: /**
119: * @ejb:interface-method
120: * view-type="both"
121: * Returns the basic state of execution object: open or closed.
122: */
123: public workflow_stateType workflow_state() throws Exception {
124: return sharkObj.workflow_state();
125: }
126:
127: /**
128: * @ejb:interface-method
129: * view-type="both"
130: * Returns the sub-state of execution object that is in open state: running or not
131: * running.
132: */
133: public while_openType while_open() throws Exception {
134: return sharkObj.while_open();
135: }
136:
137: /**
138: * @ejb:interface-method
139: * view-type="both"
140: * Returns the sub-state of execution object that is in open.not_running state: not
141: * started or suspended.
142: */
143: public why_not_runningType why_not_running() throws Exception {
144: return sharkObj.why_not_running();
145: }
146:
147: /**
148: * @ejb:interface-method
149: * view-type="both"
150: * Returns the sub-state of execution object that is in closed state: completed,
151: * aborted or terminated.
152: */
153: public how_closedType how_closed() throws Exception {
154: return sharkObj.how_closed();
155: }
156:
157: /**
158: * @ejb:interface-method
159: * view-type="both"
160: * The following operations support access to a potentially extended set of states; a
161: * state is represented by a dot-notation representing hierarchical states (e.g.,
162: * open.running).
163: * <p>
164: * Returns a list of all the valid states that can be reached from the current state.
165: * For example, open.running and closed.terminated would be in the list of valid states
166: * if the current state was open.not_running.not_started - open.not_running.suspended
167: * probably would not be in that list.
168: */
169: public String[] valid_states() throws Exception {
170: return sharkObj.valid_states();
171: }
172:
173: /**
174: * @ejb:interface-method
175: * view-type="both"
176: * Gets the current state of the object.
177: */
178: public String state() throws Exception {
179: return sharkObj.state();
180: }
181:
182: /**
183: * @ejb:interface-method
184: * view-type="both"
185: * Updates the current state of the execution object. As a result the state of
186: * execution objects associated with this execution object might be updated, too.
187: *
188: * @throws InvalidState raised when the new_state is not a valid state for the
189: * execution object
190: * @throws TransitionNotAllowed raised when the transition from the current state to
191: * new_state is not allowed.
192: * @throws Exception
193: */
194: public void change_state(String new_state) throws Exception,
195: InvalidState, TransitionNotAllowed {
196: sharkObj.change_state(new_state);
197: }
198:
199: /**
200: * @ejb:interface-method
201: * view-type="both"
202: * Returns human readable, descriptive identifier of the execution object.
203: */
204: public String name() throws Exception {
205: return sharkObj.name();
206: }
207:
208: /**
209: * @ejb:interface-method
210: * view-type="both"
211: * Sets the human readable, descriptive identifier of the execution object.
212: */
213: public void set_name(String new_value) throws Exception {
214: sharkObj.set_name(new_value);
215: }
216:
217: /**
218: * @ejb:interface-method
219: * view-type="both"
220: * Gets the identifier of the execution object. The key of a WfProcess is unique among
221: * the set of all WfProcesses created by a particular WfProcessMgr; the key of a
222: * WfActivity is unique within the set of all WfActivities contained in a particular
223: * WfProcess. A key is assigned to the execution object by its WfProcessMgr when it is
224: * created.
225: * <p>
226: * The key of a workflow object should not be confused with an object identifier. It is
227: * used for reference to the process or activity independently of the lifetime of the
228: * execution object.
229: */
230: public String key() throws Exception {
231: return sharkObj.key();
232: }
233:
234: /**
235: * @ejb:interface-method
236: * view-type="both"
237: * Returns description of the execution object.
238: */
239: public String description() throws Exception {
240: return sharkObj.description();
241: }
242:
243: /**
244: * @ejb:interface-method
245: * view-type="both"
246: * Sets description of the execution object.
247: */
248: public void set_description(String new_value) throws Exception {
249: sharkObj.set_description(new_value);
250: }
251:
252: /**
253: * @ejb:interface-method
254: * view-type="both"
255: * The process context is described by a set of named properties; the following
256: * operation support access to the context of an execution object. The Map structure
257: * identifies a set of property names and values matching the signature of the
258: * execution object. The signature of a WfProcess can be obtained using the
259: * get_context_signature operation provided by the WfProcessMgr of the process.
260: */
261: public Map process_context() throws Exception {
262: return sharkObj.process_context();
263: }
264:
265: /**
266: * @ejb:interface-method
267: * view-type="both"
268: * Sets the process relevant data that define the context of the execution object. The
269: * process context is described by a set of named properties. The Map structure
270: * identifies a set of property names and values matching the signature of the
271: * execution object. The signature of a WfProcess can be obtained using the
272: * get_context_signature operation provided by the WfProcessMgr of the process.
273: * <p>
274: * When this method has been called, only those name-value pairs in the parameter will
275: * be set. Several set_process_context() calls could be used to set the entire context.
276: *
277: * @param new_value a Map
278: * @throws Exception
279: * @throws InvalidData raised when an update request does not match this signature.
280: * @throws UpdateNotAllowed raised when the implementation of the WfM Facility or the
281: * specific workflow process does not allow an update of the context.
282: */
283: public void set_process_context(Map new_value) throws Exception,
284: InvalidData, UpdateNotAllowed {
285: sharkObj.set_process_context(new_value);
286: }
287:
288: /**
289: * @ejb:interface-method
290: * view-type="both"
291: * Returns relative priority of the execution element in the set of all execution
292: * objects of a given type.
293: * <p>
294: * Valid values are numbers between one and five, with three being 'normal' and one as
295: * the 'highest' priority.
296: */
297: public short priority() throws Exception {
298: return sharkObj.priority();
299: }
300:
301: /**
302: * @ejb:interface-method
303: * view-type="both"
304: * Sets the relative priority of the execution element in the set of all execution
305: * objects of a given type.
306: * <p>
307: * Valid values are numbers between one and five, with three being 'normal' and one as
308: * the 'highest' priority.
309: * <p>
310: * A request for update of the priority will raise an exception when the specified
311: * priority is out of range, or when the priority cannot be updated.
312: */
313: public void set_priority(short new_value) throws Exception {
314: sharkObj.set_priority(new_value);
315: }
316:
317: /**
318: * @ejb:interface-method
319: * view-type="both"
320: * Requests enactment of a suspended execution object to be resumed. The state is set
321: * to open.running (or a substate) from open.not_running.suspended.
322: *
323: * @throws CannotResume raised when the execution object cannot be resumed. For
324: * example, resuming a WfActivity might not be allowed when the containing
325: * WfProcess is suspended.
326: * @throws NotSuspended raised when the object is not suspended.
327: * @throws Exception
328: */
329: public void resume() throws Exception, CannotResume, NotSuspended {
330: sharkObj.resume();
331: }
332:
333: /**
334: * @ejb:interface-method
335: * view-type="both"
336: * Requests enactment of an execution object to be suspended. The state is set to
337: * open.not_running.suspended (or one of its substates).
338: *
339: * @throws CannotSuspend exception is raised when the execution object cannot be
340: * suspended. For example, an implementation of the WfM Facility might not
341: * support suspension of a WfActivity.
342: * @throws NotRunning raised when the object is not running.
343: * @throws AlreadySuspended raised when the object is already suspended.
344: * @throws Exception
345: */
346: public void suspend() throws Exception, CannotSuspend, NotRunning,
347: AlreadySuspended {
348: sharkObj.suspend();
349: }
350:
351: /**
352: * @ejb:interface-method
353: * view-type="both"
354: * Requests enactment of an execution object to be terminated before its normal
355: * completion. A terminate request is different from an abort request in its effect of
356: * execution object associated with the current execution object. The state is set to
357: * closed.terminated (or one of its substates) from open.running (or one of its
358: * substates).
359: *
360: * @throws CannotStop raised when the execution object cannot be terminated; for
361: * example, termination of a WfActivity might not be allowed when its
362: * implementation is still active and cannot be terminated.
363: * @throws NotRunning raised when the object is not running.
364: * @throws Exception
365: */
366: public void terminate() throws Exception, CannotStop, NotRunning {
367: sharkObj.terminate();
368: }
369:
370: /**
371: * @ejb:interface-method
372: * view-type="both"
373: * Requests enactment of a suspended execution object to be aborted before its normal
374: * completion. The state is set to closed.aborted.
375: *
376: * @throws CannotStop raised when the execution object cannot be aborted.
377: * @throws NotRunning raised when the object is not running.
378: * @throws Exception
379: */
380: public void abort() throws Exception, CannotStop, NotRunning {
381: sharkObj.abort();
382: }
383:
384: /**
385: * @ejb:interface-method
386: * view-type="both"
387: * Zero or more WfEventAudit items can be associated with an execution object. An event
388: * audit item is generated (and associated with the source object) for each workflow
389: * relevant status change (change of state, context or result and change of resource
390: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
391: * operations that request a change of the objects status or implicitly by the workflow
392: * process logic. We will indicate which operations trigger generation of WfEventAudit
393: * items.
394: * <p>
395: * The following operation provide the information about the number of WfEventAudit
396: * items currently associated with a WfExecutionObject.
397: */
398: public int how_many_history() throws Exception, HistoryNotAvailable {
399: return sharkObj.how_many_history();
400: }
401:
402: /**
403: * @ejb:interface-method
404: * view-type="both"
405: * Zero or more WfEventAudit items can be associated with an execution object. An event
406: * audit item is generated (and associated with the source object) for each workflow
407: * relevant status change (change of state, context or result and change of resource
408: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
409: * operations that request a change of the objects status or implicitly by the workflow
410: * process logic. We will indicate which operations trigger generation of WfEventAudit
411: * items.
412: * <p>
413: * The following operation returns iterator for qurying associated event audits based
414: * on some criteria.
415: */
416: public WfEventAuditIterator get_iterator_history(String query,
417: Map names_in_query) throws Exception, HistoryNotAvailable {
418: WfEventAuditIterator wfshark = sharkObj.get_iterator_history(
419: query, names_in_query);
420: WfEventAuditIteratorSS wf = null;
421: try {
422: Context initialContext = EJBJNDIContext.getInstance()
423: .getInitialContext();
424: wf = ((org.enhydra.shark.ejb.WfEventAuditIteratorSSHome) PortableRemoteObject
425: .narrow(
426: initialContext
427: .lookup("org/enhydra/shark/ejb/WfEventAuditIteratorSS"),
428: org.enhydra.shark.ejb.WfEventAuditIteratorSSHome.class))
429: .create(wfshark);
430: return (WfEventAuditIteratorSS) wf.getPassedEJBObject();
431: } catch (Exception ex) {
432: throw new EJBException(ex);
433: }
434: }
435:
436: /**
437: * @ejb:interface-method
438: * view-type="both"
439: * Zero or more WfEventAudit items can be associated with an execution object. An event
440: * audit item is generated (and associated with the source object) for each workflow
441: * relevant status change (change of state, context or result and change of resource
442: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
443: * operations that request a change of the objects status or implicitly by the workflow
444: * process logic. We will indicate which operations trigger generation of WfEventAudit
445: * items.
446: * <p>
447: * The following operation returns max_number of WfEventAudit objects associated with
448: * an WfExecutionObject. If max_number is less or eaqual to zero, or it is greater than
449: * the number of existing event audits, all associated WfEventAudit objects will be
450: * returned.
451: */
452: public WfEventAudit[] get_sequence_history(int max_number)
453: throws Exception, HistoryNotAvailable {
454: try {
455: return SharkEJBUtilities.makeSSEventAudits(sharkObj
456: .get_sequence_history(max_number));
457: } catch (Exception ex) {
458: throw new EJBException(ex);
459: }
460: }
461:
462: /**
463: * @ejb:interface-method
464: * view-type="both"
465: * Zero or more WfEventAudit items can be associated with an execution object. An event
466: * audit item is generated (and associated with the source object) for each workflow
467: * relevant status change (change of state, context or result and change of resource
468: * assignment) of a WfExecutionObject. Status changes can be explicitly triggered by
469: * operations that request a change of the objects status or implicitly by the workflow
470: * process logic. We will indicate which operations trigger generation of WfEventAudit
471: * items.
472: * <p>
473: * The following operation returns true if given event audit is associated with
474: * WfExecutionObject.
475: */
476: public boolean is_member_of_history(WfExecutionObject member)
477: throws Exception {
478: try {
479: boolean ret = false;
480: WfEventAudit[] evs = SharkEJBUtilities
481: .makeSSEventAudits(sharkObj.get_sequence_history(0));
482: if (evs != null) {
483: for (int i = 0; i < evs.length; i++) {
484: WfEventAudit ea = evs[i];
485: if (member.key().equals(ea.process_key())) {
486: ret = true;
487: break;
488: }
489: }
490: }
491: return ret;
492: } catch (Exception ex) {
493: throw new EJBException(ex);
494: }
495: }
496:
497: /**
498: * @ejb:interface-method
499: * view-type="both"
500: * Returns the time when WfExecutionObject changed its state to the current one.
501: */
502: public UtcT last_state_time() throws Exception {
503: return sharkObj.last_state_time();
504: }
505:
506: /**
507: * @ejb:interface-method
508: * view-type="both"
509: * A WfProcess is created (using a WfProcessMgr) by a user or automated resource and
510: * associated with a WfRequester. The WfRequester may be a WfActivity or an adapter for
511: * external clients. WfProcess always has one WfRequester; an implementation of the WfM
512: * Facility may allow for re-assignment of the WfRequester associated with a WfProcess.
513: * <p>
514: * A WfProcess will inform its WfRequester about status changes such as modification of
515: * its state and its context using the requesters receive_event operation.
516: * <p>
517: * The following operation returns the requester.
518: */
519: public WfRequester requester() throws Exception {
520: try {
521: WfRequester requester = sharkObj.requester();
522: if (requester instanceof org.enhydra.shark.api.client.wfmodel.WfActivity) {
523: WfActivitySS wf = null;
524: try {
525: Context initialContext = EJBJNDIContext
526: .getInstance().getInitialContext();
527: wf = ((org.enhydra.shark.ejb.WfActivitySSHome) PortableRemoteObject
528: .narrow(
529: initialContext
530: .lookup("org/enhydra/shark/ejb/WfActivitySS"),
531: org.enhydra.shark.ejb.WfActivitySSHome.class))
532: .create((WfActivity) requester);
533: return (WfActivitySS) wf.getPassedEJBObject();
534: } catch (Exception ex) {
535: throw new EJBException(ex);
536: }
537: } else if (requester instanceof WfLinkingRequesterForSS) {
538: return WfLinkingRequesterForSS.getRequester(sharkObj
539: .key());
540: } else {
541: WfRequesterSS wf = null;
542: try {
543: Context initialContext = EJBJNDIContext
544: .getInstance().getInitialContext();
545: wf = ((org.enhydra.shark.ejb.WfRequesterSSHome) PortableRemoteObject
546: .narrow(
547: initialContext
548: .lookup("org/enhydra/shark/ejb/WfRequesterSS"),
549: org.enhydra.shark.ejb.WfRequesterSSHome.class))
550: .create(requester);
551: return (WfRequesterSS) wf.getPassedEJBObject();
552: } catch (Exception ex) {
553: throw new EJBException(ex);
554: }
555: }
556: } catch (Exception ex) {
557: throw new EJBException(ex);
558: }
559: }
560:
561: /**
562: * @ejb:interface-method
563: * view-type="both"
564: * A WfProcess is created (using a WfProcessMgr) by a user or automated resource and
565: * associated with a WfRequester. The WfRequester may be a WfActivity or an adapter for
566: * external clients. WfProcess always has one WfRequester; an implementation of the WfM
567: * Facility may allow for re-assignment of the WfRequester associated with a WfProcess.
568: * <p>
569: * A WfProcess will inform its WfRequester about status changes such as modification of
570: * its state and its context using the requesters receive_event operation.
571: * <p>
572: * The following operations changes the process requester.
573: */
574: public void set_requester(WfRequester new_value) throws Exception,
575: CannotChangeRequester {
576: if (new_value == null)
577: throw new EJBException(
578: "Trying to set external requester which is null!");
579: if (new_value instanceof WfActivitySS)
580: throw new EJBException(
581: "Can't change requester to activity requester");
582: try {
583: WfLinkingRequesterForSS lr = new WfLinkingRequesterForSS();
584: WfLinkingRequesterForSS.setRequester(sharkObj.key(),
585: (WfRequesterSS) new_value);
586: sharkObj.set_requester(lr);
587: } catch (Exception ex) {
588: throw new EJBException(ex);
589: }
590: }
591:
592: /**
593: * @ejb:interface-method
594: * view-type="both"
595: * Zero or more WfActivities are associated with a WfProcess. The association is
596: * established when an activity is created as part of the enactment of the WfProcess.
597: * <p>
598: * The following operation provide the information about the number of active
599: * WfActivity items currently associated with a WfProcess.
600: */
601: public int how_many_step() throws Exception {
602: return sharkObj.how_many_step();
603: }
604:
605: /**
606: * @ejb:interface-method
607: * view-type="both"
608: * Zero or more WfActivities are associated with a WfProcess. The association is
609: * established when an activity is created as part of the enactment of the WfProcess.
610: * <p>
611: * The following operation returns iterator for qurying associated activities based on
612: * some criteria.
613: */
614: public WfActivityIterator get_iterator_step() throws Exception {
615: WfActivityIterator wfshark = sharkObj.get_iterator_step();
616: WfActivityIteratorSS wf = null;
617: try {
618: Context initialContext = EJBJNDIContext.getInstance()
619: .getInitialContext();
620: wf = ((org.enhydra.shark.ejb.WfActivityIteratorSSHome) PortableRemoteObject
621: .narrow(
622: initialContext
623: .lookup("org/enhydra/shark/ejb/WfActivityIteratorSS"),
624: org.enhydra.shark.ejb.WfActivityIteratorSSHome.class))
625: .create(wfshark);
626: return (WfActivityIteratorSS) wf.getPassedEJBObject();
627: } catch (Exception ex) {
628: throw new EJBException(ex);
629: }
630: }
631:
632: /**
633: * @ejb:interface-method
634: * view-type="both"
635: * Zero or more WfActivities are associated with a WfProcess. The association is
636: * established when an activity is created as part of the enactment of the WfProcess.
637: * <p>
638: * The following operation returns max_number of WfActivity objects associated with an
639: * WfProcess (no matter in which state they are). If max_number is less or eaqual to
640: * zero, or it is greater than the number of existing activities, all associated
641: * WfActivity objects will be returned.
642: */
643: public WfActivity[] get_sequence_step(int max_number)
644: throws Exception {
645: WfActivity[] wfsshark = sharkObj.get_sequence_step(max_number);
646: WfActivitySSHome home = null;
647: InitialContext initialContext = EJBJNDIContext.getInstance()
648: .getInitialContext();
649: home = (WfActivitySSHome) PortableRemoteObject.narrow(
650: initialContext
651: .lookup("org/enhydra/shark/ejb/WfActivitySS"),
652: org.enhydra.shark.ejb.WfActivitySSHome.class);
653: int len = wfsshark.length;
654: WfActivitySS[] remotes = new WfActivitySS[len];
655: for (int i = 0; i < len; i++) {
656: remotes[i] = (WfActivitySS) (home.create(wfsshark[i]))
657: .getPassedEJBObject();
658: }
659: return remotes;
660: }
661:
662: /**
663: * @ejb:interface-method
664: * view-type="both"
665: * Zero or more WfActivities are associated with a WfProcess. The association is
666: * established when an activity is created as part of the enactment of the WfProcess.
667: * <p>
668: * The following operation returns true if given activity is associated with WfProcess.
669: */
670: public boolean is_member_of_step(WfActivity member)
671: throws Exception {
672: try {
673: WfActivity[] acts = get_sequence_step(0);
674: boolean ret = false;
675: if (acts != null) {
676: for (int i = 0; i < acts.length; i++) {
677: WfActivity act = acts[i];
678: if (act.key().equals(member.key())) {
679: ret = true;
680: break;
681: }
682: }
683: }
684: return ret;
685: } catch (Exception ex) {
686: throw new EJBException(ex);
687: }
688: }
689:
690: /**
691: * @ejb:interface-method
692: * view-type="both"
693: * A process is associated with one WfProcessMgr; the association is established when
694: * the WfProcess is generated and cannot be modified. The following operation returns
695: * the WfProcessMgr associated with the WfProcess.
696: */
697: public WfProcessMgr manager() throws Exception {
698: WfProcessMgr wfshark = sharkObj.manager();
699: WfProcessMgrSS wf = null;
700: try {
701: Context initialContext = EJBJNDIContext.getInstance()
702: .getInitialContext();
703: wf = ((org.enhydra.shark.ejb.WfProcessMgrSSHome) PortableRemoteObject
704: .narrow(
705: initialContext
706: .lookup("org/enhydra/shark/ejb/WfProcessMgrSS"),
707: org.enhydra.shark.ejb.WfProcessMgrSSHome.class))
708: .create(wfshark);
709: return (WfProcessMgrSS) wf.getPassedEJBObject();
710: } catch (Exception ex) {
711: throw new EJBException(ex);
712: }
713: }
714:
715: /**
716: * @ejb:interface-method
717: * view-type="both"
718: * The result produced by the WfProcess. In general the result is undefined until the
719: * process completes, but some processes may produce intermediate results. A
720: * ResultNotAvailable exception is raised when the result cannot be obtained yet.
721: */
722: public Map result() throws Exception, ResultNotAvailable {
723: return sharkObj.result();
724: }
725:
726: /**
727: * @ejb:interface-method
728: * view-type="both"
729: * This operation is used to initiate enactment of a WfProcess. The state of the
730: * process is changed from open.not_running.not_started to open.running.
731: *
732: * @throws CannotStart raised when the process cannot be started (e.g., because it is
733: * not properly initialized).
734: * @throws AlreadyRunning raised when the process has already been started.
735: * @throws Exception
736: */
737: public void start() throws Exception, CannotStart, AlreadyRunning {
738: sharkObj.start();
739: }
740:
741: /**
742: * @ejb:interface-method
743: * view-type="both"
744: * This operation is used to get an iterator over WfActivity objects that are in a
745: * certain state. The state is an input parameter. In case an invalid state has been
746: * specified, the exception InvalidState is raised.
747: */
748: public WfActivityIterator get_activities_in_state(String state)
749: throws Exception, InvalidState {
750: WfActivityIterator wfshark = sharkObj
751: .get_activities_in_state(state);
752: WfActivityIteratorSS wf = null;
753: try {
754: Context initialContext = EJBJNDIContext.getInstance()
755: .getInitialContext();
756: wf = ((org.enhydra.shark.ejb.WfActivityIteratorSSHome) PortableRemoteObject
757: .narrow(
758: initialContext
759: .lookup("org/enhydra/shark/ejb/WfActivityIteratorSS"),
760: org.enhydra.shark.ejb.WfActivityIteratorSSHome.class))
761: .create(wfshark);
762: return (WfActivityIteratorSS) wf.getPassedEJBObject();
763: } catch (Exception ex) {
764: throw new EJBException(ex);
765: }
766: }
767:
768: /**
769: * @ejb.interface-method
770: * view-type="both"
771: **/
772: public EJBObject getPassedEJBObject() throws EJBException {
773: try {
774: return context.getEJBObject();
775: } catch (Exception ex) {
776: throw new EJBException(ex);
777: }
778: }
779:
780: public void setSessionContext(SessionContext ctx)
781: throws EJBException, RemoteException {
782: context = ctx;
783: }
784:
785: /**
786: * @ejb:create-method
787: */
788: public void ejbCreate(
789: org.enhydra.shark.api.client.wfmodel.WfProcess proc) {
790: sharkObj = proc;
791: }
792:
793: /* (non-Javadoc)
794: * @see javax.ejb.SessionBean#ejbActivate()
795: */
796: public void ejbActivate() throws EJBException, RemoteException {
797: }
798:
799: /* (non-Javadoc)
800: * @see javax.ejb.SessionBean#ejbPassivate()
801: */
802: public void ejbPassivate() throws EJBException, RemoteException {
803: }
804:
805: /* (non-Javadoc)
806: * @see javax.ejb.SessionBean#ejbRemove()
807: */
808: public void ejbRemove() throws EJBException, RemoteException {
809: }
810: }
|