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