001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: EJBContext.java 1100 2006-08-16 13:05:31Z benoitf $
023: * --------------------------------------------------------------------------
024: */package javax.ejb;
025:
026: import java.security.Identity;
027: import java.security.Principal;
028: import java.util.Properties;
029:
030: import javax.transaction.UserTransaction;
031:
032: /**
033: * Allows to gets some info on the bean.
034: * @see <a href="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a>
035: * @author Florent Benoit
036: */
037: public interface EJBContext {
038:
039: /**
040: * @return the Home(remote) interface of the bean.
041: * throws IllegalStateException if home is not retrieved
042: */
043: EJBHome getEJBHome();
044:
045: /**
046: * @return the local home interface of the bean.
047: * throws IllegalStateException if local home is not retrieved
048: */
049: EJBLocalHome getEJBLocalHome();
050:
051: /**
052: * @return deprecated
053: */
054: @Deprecated
055: Properties getEnvironment();
056:
057: /**
058: * @return deprecated
059: */
060: @Deprecated
061: Identity getCallerIdentity();
062:
063: /**
064: * @return the caller principal object.
065: */
066: Principal getCallerPrincipal();
067:
068: /**
069: * @param role deprecated
070: * @return deprecated
071: */
072: @Deprecated
073: boolean isCallerInRole(final Identity role);
074:
075: /**
076: * Check if the given role is in the roles of the current caller's
077: * principal.
078: * @param roleName the role to check.
079: * @return true if it is included, else false.
080: */
081: boolean isCallerInRole(final String roleName);
082:
083: /**
084: * Gets the current transaction.
085: * @return the transaction object
086: * @throws IllegalStateException in case of Container Managed Transaction.
087: */
088: UserTransaction getUserTransaction() throws IllegalStateException;
089:
090: /**
091: * Sets the current transaction in rollback only mode.
092: * @throws IllegalStateException in CMT case
093: */
094: void setRollbackOnly() throws IllegalStateException;
095:
096: /**
097: * Check if current transaction is marked as rollback only.
098: * @return true if current tx is in rollback mode.
099: * @throws IllegalStateException if used with CMT.
100: */
101: boolean getRollbackOnly() throws IllegalStateException;
102:
103: /**
104: * Gets the timer service.
105: * @return an instance of the timer service.
106: * @throws IllegalStateException if used within a SFSB.
107: */
108: TimerService getTimerService() throws IllegalStateException;
109:
110: /**
111: * Search the given name in java:comp/env ENC environment.
112: * @param name the name to search
113: * @return null if not found, else an instance of the object found.
114: * @since EJB 3.0 version.
115: */
116: Object lookup(final String name);
117: }
|