001: /*
002: * Danet GmbH
003: *
004: * $Id: UtilEJB.java,v 1.5 2006/10/11 09:05:54 drmlipp Exp $
005: *
006: * $Log: UtilEJB.java,v $
007: * Revision 1.5 2006/10/11 09:05:54 drmlipp
008: * Fixed EJB naming.
009: *
010: * Revision 1.4 2006/10/07 20:41:34 mlipp
011: * Merged J2EE 1.4 adaptions from test branch.
012: *
013: * Revision 1.3 2005/04/08 11:28:02 drmlipp
014: * Merged changes from 1.3 branch up to 1.3p6.
015: *
016: * Revision 1.2.6.1 2005/04/04 20:08:55 drmlipp
017: * Changed WLS transaction isolation.
018: *
019: * Revision 1.2 2004/09/10 12:44:28 drmlipp
020: * Enabled call by reference for weblogic by default.
021: *
022: * Revision 1.1.1.6 2004/08/18 15:17:35 drmlipp
023: * Update to 1.2
024: *
025: * Revision 1.16 2004/07/07 11:34:00 lipp
026: * Clarified transaction attributes.
027: *
028: * Revision 1.15 2004/06/23 18:50:29 lipp
029: * Added jndi-names for jonas.
030: *
031: * Revision 1.14 2004/06/23 15:06:38 lipp
032: * Started JOnAS port.
033: *
034: * Revision 1.13 2004/01/14 07:59:44 lipp
035: * Added transaction isolation attribute for WLS.
036: *
037: * Revision 1.12 2003/09/28 19:21:09 lipp
038: * More improvements concerning security handling.
039: *
040: * Revision 1.11 2003/09/11 13:25:49 lipp
041: * Improved naming scheme for symbolic role names.
042: *
043: * Revision 1.10 2003/09/03 15:23:50 lipp
044: * Support for local interfaces.
045: *
046: * Revision 1.9 2003/08/25 20:23:33 lipp
047: * Fixed problem with weblogic principal.
048: *
049: * Revision 1.8 2003/05/23 15:42:41 lipp
050: * Fixed deployment unit dependencies.
051: *
052: * Revision 1.7 2003/03/31 16:50:27 huaiyang
053: * Logging using common-logging.
054: *
055: * Revision 1.6 2003/02/14 16:47:21 lipp
056: * Fixed comments.
057: *
058: * Revision 1.5 2002/11/22 09:56:15 lipp
059: * Clarified usage of the danet utility bean for user preferences.
060: *
061: * Revision 1.4 2002/11/18 16:21:00 montag
062: * role-name changed to "Danet UtilEJBs User".
063: *
064: * Revision 1.3 2002/11/18 15:41:51 montag
065: * wrong permission removed.
066: *
067: * Revision 1.2 2002/11/18 14:58:37 montag
068: * Retrieve getLoggedOnUser() from Util ejb.
069: *
070: * Revision 1.1 2002/11/15 15:41:53 montag
071: * New session ejb Util.
072: *
073: *
074: */
075: package de.danet.an.util;
076:
077: import java.security.Principal;
078:
079: import javax.ejb.SessionBean;
080: import javax.ejb.SessionContext;
081: import javax.ejb.CreateException;
082:
083: /**
084: * The stateless session bean <code>UtilEJB</code> provides server-side
085: * util functionalitity which can be used by client applications.
086: *
087: * @ejb.bean name="Util" display-name="Danet Util EJB"
088: * jndi-name="ejb/@@@_Utility-EJBs_UtilEJB_JNDI_Name_@@@"
089: * local-jndi-name="ejb/@@@_Utility-EJBs_UtilEJB_JNDI_Name_@@@Local"
090: * type="Stateless" transaction-type="Container" view-type="both"
091: * @jonas.bean ejb-name="Util"
092: * jndi-name="@@@_Utility-EJBs_UtilEJB_JNDI_Name_@@@"
093: * @ejb.home remote-class="de.danet.an.util.UtilHome"
094: * @ejb.interface remote-class="de.danet.an.util.Util"
095: * @ejb.transaction type="Required"
096: * @weblogic.enable-call-by-reference True
097: */
098: public class UtilEJB implements SessionBean {
099:
100: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
101: .getLog(UtilEJB.class);
102:
103: /**
104: *The SessionContext interface of the instance.
105: */
106: private SessionContext ctx;
107:
108: /**
109: * Set the associated session context. The container calls this method
110: * after the instance creation.
111: * @see javax.ejb.SessionBean
112: * @param context a SessionContext interface for the instance
113: */
114: public void setSessionContext(SessionContext context) {
115: ctx = context;
116: }
117:
118: /**
119: * The activate method is called when the instance is activated from its
120: * "passive" state. The instance should acquire any resource that it has
121: * released earlier in the ejbPassivate() method.
122: * @see javax.ejb.SessionBean
123: */
124: public void ejbActivate() {
125: // nothing to do
126: }
127:
128: /**
129: * The passivate method is called before the instance enters the
130: * "passive" state. The instance should release any resources that it
131: * can re-acquire later in the ejbActivate() method.
132: * @see javax.ejb.SessionBean
133: */
134: public void ejbPassivate() {
135: // nothing to do
136: }
137:
138: /**
139: * A container invokes this method before it ends the life of the session
140: * object. This happens as a result of a client's invoking a remove
141: * operation, or when a container decides to terminate the session object
142: * after a timeout.
143: * @see javax.ejb.SessionBean
144: */
145: public void ejbRemove() {
146: // nothing to do
147: }
148:
149: /**
150: * Create an new instance of StaffDirectoryEJB.
151: * @throws CreateException if the StaffDirectoryEJB can not
152: * be create.
153: */
154: public void ejbCreate() throws CreateException {
155: // nothing to do
156: }
157:
158: /**
159: * Returns the user currently logged on as a <code>Principal</code>.
160: * @return the caller principal.
161: * @ejb.interface-method
162: */
163: public Principal getEJBPrincipal() {
164: return new SimplePrincipal(ctx.getCallerPrincipal().getName());
165: }
166:
167: }
|