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