001: /* WfAssignmentEventAuditSSBean.java */
002: package org.enhydra.shark.ejb;
003:
004: import java.rmi.RemoteException;
005:
006: import javax.ejb.EJBException;
007: import javax.ejb.EJBObject;
008: import javax.ejb.SessionBean;
009: import javax.ejb.SessionContext;
010: import javax.naming.Context;
011: import javax.rmi.PortableRemoteObject;
012:
013: import org.enhydra.shark.api.client.timebase.UtcT;
014: import org.enhydra.shark.api.client.wfmodel.SourceNotAvailable;
015: import org.enhydra.shark.api.client.wfmodel.WfActivity;
016: import org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit;
017: import org.enhydra.shark.api.client.wfmodel.WfExecutionObject;
018: import org.enhydra.shark.api.client.wfmodel.WfProcess;
019:
020: /**
021: * @ejb.bean
022: * name="WfAssignmentEventAuditSS"
023: * type="Stateful"
024: * display-name="WfAssignmentEventAudit"
025: * jndi-name="org/enhydra/shark/ejb/WfAssignmentEventAuditSS"
026: * local-jndi-name="org/enhydra/shark/ejb/WfAssignmentEventAuditSSLocal"
027: * transaction-type="Container"
028: * view-type="both"
029: * local-business-interface="org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit"
030: *
031: * @ejb.ejb-ref ejb-name="WfActivitySS"
032: * view-type="both"
033: * ref-name="org/enhydra/shark/ejb/WfActivitySS"
034: * @ejb.ejb-ref ejb-name="WfProcessSS"
035: * view-type="both"
036: * ref-name="org/enhydra/shark/ejb/WfProcessSS"
037: *
038: * @ejb:interface
039: * extends="org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit,javax.ejb.EJBObject"
040: *
041: * @ejb:transaction
042: * type="Required"
043: *
044: * @jonas:bean
045: * ejb-name="WfAssignmentEventAuditSS"
046: * jndi-name="org/enhydra/shark/ejb/WfAssignmentEventAuditSS"
047: *
048: * OMG definition: This interface specializes WfEventAudit for assignment change events. The event
049: * records resource and assignment status before and after the change. The event_type
050: * is activityAssignmentChanged.
051: * An assignment change event is signaled when assignments for an activity are created
052: * (in this case the old_... data is NULL), when the status of an assignment is changed, or
053: * when an existing assignment is reassigned to another resource. The WfActivity
054: * associated with the assignment is reported as the source of the event.
055: * <p>We extended OMG's interface by adding additional method for getting
056: * accepted status property.
057: *
058: * @author V.Puskas
059: * @author S.Bojanic
060: * @author T.Jovanovic
061: * @version 0.1
062: */
063: public abstract class WfAssignmentEventAuditSSBean implements
064: WfAssignmentEventAudit, SessionBean {
065:
066: private SessionContext context;
067: private org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit sharkObj;
068:
069: /**
070: * @ejb:interface-method
071: * view-type="both"
072: * A WfEventAudit can be associated with the WfExecutionObject that triggered the
073: * event. Event audit items are meant to provide information on the execution history
074: * of workflow object even after the source object has been deleted; in this case, no
075: * source would be associated with the WfEventAudit.
076: * <p>
077: * The following operation returns the source of the event, when available; if the
078: * source is not available, a SourceNotAvailable exception is raised.
079: */
080: public WfExecutionObject source() throws Exception,
081: SourceNotAvailable {
082: if (sharkObj.source() instanceof org.enhydra.shark.api.client.wfmodel.WfProcess) {
083: WfProcess wfshark = (WfProcess) sharkObj.source();
084: WfProcessSS wf = null;
085: try {
086: Context initialContext = EJBJNDIContext.getInstance()
087: .getInitialContext();
088: wf = ((org.enhydra.shark.ejb.WfProcessSSHome) PortableRemoteObject
089: .narrow(
090: initialContext
091: .lookup("org/enhydra/shark/ejb/WfProcessSS"),
092: org.enhydra.shark.ejb.WfProcessSSHome.class))
093: .create(wfshark);
094: return (WfProcessSS) wf.getPassedEJBObject();
095: } catch (Exception ex) {
096: throw new EJBException(ex);
097: }
098: } else {
099: WfActivity wfshark = (WfActivity) sharkObj.source();
100: WfActivitySS wf = null;
101: try {
102: Context initialContext = EJBJNDIContext.getInstance()
103: .getInitialContext();
104: wf = ((org.enhydra.shark.ejb.WfActivitySSHome) PortableRemoteObject
105: .narrow(
106: initialContext
107: .lookup("org/enhydra/shark/ejb/WfActivitySS"),
108: org.enhydra.shark.ejb.WfActivitySSHome.class))
109: .create(wfshark);
110: return (WfActivitySS) wf.getPassedEJBObject();
111: } catch (Exception ex) {
112: throw new EJBException(ex);
113: }
114: }
115: }
116:
117: /**
118: * @ejb:interface-method
119: * view-type="both"
120: * Records the time the status change of the source occurred that triggered the event
121: * audit item to be created, using the TimeBase::UtcT data type defined by the OMG Time
122: * Service.
123: */
124: public UtcT time_stamp() throws Exception {
125: UtcT t = sharkObj.time_stamp();
126: return new UtcT(t.time, t.inacclo, t.inacchi, t.tdf);
127: }
128:
129: /**
130: * @ejb:interface-method
131: * view-type="both"
132: * Identifies the specific event type. The following is a set of pre-defined event
133: * types; implementations of the WfM Facility may decide to support additional audit
134: * event types.
135: * <ul>
136: * <li>processCreated - A WfProcess was created
137: * <li>processStateChanged - The state of a WfProcess was changed
138: * <li>processContextChanged - The context of a WfProcess was initialized or changed
139: * <li>activityStateChanged - The state of a WfActivity was changed
140: * <li>activityContextChanged - The context of a WfActivity was changed
141: * <li>activityResultChanged - The result of a WfActivity was set
142: * <li>activityAssigmentChanged - The status or the resource assignment of a
143: * WfAssignment was initialized or changed
144: * </ul>
145: */
146: public String event_type() throws Exception {
147: return sharkObj.event_type();
148: }
149:
150: /**
151: * @ejb:interface-method
152: * view-type="both"
153: * If the event is triggered by a status change of a WfActivity, the key and the name
154: * of the activity is recorded with the WfEventAudit. Otherwise, the activity related
155: * attributes contain a NULL value.
156: * <p>
157: * The following operation returns the key of the WfActivity associated with the event.
158: */
159: public String activity_key() throws Exception {
160: return sharkObj.activity_key();
161: }
162:
163: /**
164: * @ejb:interface-method
165: * view-type="both"
166: * If the event is triggered by a status change of a WfActivity, the key and the name
167: * of the activity is recorded with the WfEventAudit. Otherwise, the activity related
168: * attributes contain a NULL value.
169: * <p>
170: * The following operation return the name of the WfActivity associated with the event.
171: */
172: public String activity_name() throws Exception {
173: return sharkObj.activity_name();
174: }
175:
176: /**
177: * @ejb:interface-method
178: * view-type="both"
179: * The key and the name of the WfProcess associated with the source of an event are
180: * recorded with the WfEventAudit. If the event was triggered by a WfActivity, this is
181: * the containing WfProcess. If it was triggered by a status change of a WfProcess, it
182: * is that process.
183: * <p>
184: * The following operation returns the key of the WfProcess associated with the event.
185: */
186: public String process_key() throws Exception {
187: return sharkObj.process_key();
188: }
189:
190: /**
191: * @ejb:interface-method
192: * view-type="both"
193: * The key and the name of the WfProcess associated with the source of an event are
194: * recorded with the WfEventAudit. If the event was triggered by a WfActivity, this is
195: * the containing WfProcess. If it was triggered by a status change of a WfProcess, it
196: * is that process.
197: * <p>
198: * The following operation returns the name of the WfProcess associated with the event.
199: */
200: public String process_name() throws Exception {
201: return sharkObj.process_name();
202: }
203:
204: /**
205: * @ejb:interface-method
206: * view-type="both"
207: * The WfProcessMgr associated with the workflow object that triggered the event is
208: * identified via its name and version. If the event was triggered by a status change
209: * of an activity, this is the manager of the process that contains the activity. If it
210: * was triggered by a status change of a process, this is the manager of that process.
211: * <p>
212: * The following operation returns the name of the WfProcessMgr associated with the
213: * event.
214: */
215: public String process_mgr_name() throws Exception {
216: return sharkObj.process_mgr_name();
217: }
218:
219: /**
220: * @ejb:interface-method
221: * view-type="both"
222: * The WfProcessMgr associated with the workflow object that triggered the event is
223: * identified via its name and version. If the event was triggered by a status change
224: * of an activity, this is the manager of the process that contains the activity. If it
225: * was triggered by a status change of a process, this is the manager of that process.
226: * <p>
227: * The following operation returns the version of the WfProcessMgr associated with the
228: * event.
229: */
230: public String process_mgr_version() throws Exception {
231: return sharkObj.process_mgr_version();
232: }
233:
234: /**
235: * @ejb:interface-method
236: * view-type="both"
237: * Returns the resource key of the assignment before the change may be recorded. This event also
238: * covers creation of a new assignment; in this case, the before event information is
239: * NULL.
240: */
241: public String old_resource_key() throws Exception {
242: return sharkObj.old_resource_key();
243: }
244:
245: /**
246: * @ejb:interface-method
247: * view-type="both"
248: * Returns the resource name of the assignment before the change may be recorded. This event also
249: * covers creation of a new assignment; in this case, the before event information is
250: * NULL.
251: */
252: public String old_resource_name() throws Exception {
253: return sharkObj.old_resource_name();
254: }
255:
256: /**
257: * @ejb:interface-method
258: * view-type="both"
259: * Returns the resource key of the assignment after the change is recorded.*/
260: public String new_resource_key() throws Exception {
261: return sharkObj.new_resource_key();
262: }
263:
264: /**
265: * @ejb:interface-method
266: * view-type="both"
267: * Returns the resource name of the assignment after the change is recorded.
268: */
269: public String new_resource_name() throws Exception {
270: return sharkObj.new_resource_name();
271: }
272:
273: // doesn't exist in original OMG spec.
274: /**
275: * @ejb:interface-method
276: * view-type="both"
277: * Returns the accepted status of assignment after the change is recorded.
278: */
279: public boolean is_accepted() throws Exception {
280: return sharkObj.is_accepted();
281: }
282:
283: /**
284: * @ejb.interface-method
285: * view-type="both"
286: **/
287: public EJBObject getPassedEJBObject() throws EJBException {
288: try {
289: return context.getEJBObject();
290: } catch (Exception ex) {
291: throw new EJBException(ex);
292: }
293: }
294:
295: public void setSessionContext(SessionContext ctx)
296: throws EJBException, RemoteException {
297: context = ctx;
298: }
299:
300: /**
301: * @ejb:create-method
302: */
303: public void ejbCreate(
304: org.enhydra.shark.api.client.wfmodel.WfAssignmentEventAudit ea) {
305: sharkObj = ea;
306: }
307:
308: /* (non-Javadoc)
309: * @see javax.ejb.SessionBean#ejbActivate()
310: */
311: public void ejbActivate() throws EJBException, RemoteException {
312: }
313:
314: /* (non-Javadoc)
315: * @see javax.ejb.SessionBean#ejbPassivate()
316: */
317: public void ejbPassivate() throws EJBException, RemoteException {
318: }
319:
320: /* (non-Javadoc)
321: * @see javax.ejb.SessionBean#ejbRemove()
322: */
323: public void ejbRemove() throws EJBException, RemoteException {
324: }
325: }
|