01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.workflow.ejb;
06:
07: import com.opensymphony.workflow.WorkflowContext;
08:
09: import javax.ejb.SessionContext;
10:
11: /**
12: * EJB specific workflow context.
13: * The default implementation is to get the caller principal from the
14: * container's SessionContext. If different behaviour is desired, this
15: * class can be subclassed with whatever custom logic in place to look
16: * up the caller. This can be done by specifying a <code>workflowContext</code>
17: * property in the ejb persistence store's properties in osworkflow.xml.
18: * The value of this properly should be the classname of the WorkflowContext
19: * to use.
20: *
21: * @author Hani Suleiman
22: * @version $Revision: 1.6 $
23: */
24: public class EJBWorkflowContext implements WorkflowContext {
25: //~ Instance fields ////////////////////////////////////////////////////////
26:
27: private SessionContext sessionContext;
28:
29: //~ Methods ////////////////////////////////////////////////////////////////
30:
31: public String getCaller() {
32: return sessionContext.getCallerPrincipal().getName();
33: }
34:
35: public void setRollbackOnly() {
36: sessionContext.setRollbackOnly();
37: }
38:
39: public void setSessionContext(SessionContext context) {
40: this .sessionContext = context;
41: }
42:
43: public SessionContext getSessionContext() {
44: return sessionContext;
45: }
46: }
|