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