1 /** 2 * EasyBeans 3 * Copyright (C) 2006 Bull S.A.S. 4 * Contact: easybeans@objectweb.org 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 * USA 20 * 21 * -------------------------------------------------------------------------- 22 * $Id: EJBContext.java 1100 2006-08-16 13:05:31Z benoitf $ 23 * -------------------------------------------------------------------------- 24 */ 25 26 package javax.ejb; 27 28 import java.security.Identity; 29 import java.security.Principal; 30 import java.util.Properties; 31 32 import javax.transaction.UserTransaction; 33 34 /** 35 * Allows to gets some info on the bean. 36 * @see <a HREF="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a> 37 * @author Florent Benoit 38 */ 39 public interface EJBContext { 40 41 /** 42 * @return the Home(remote) interface of the bean. 43 * throws IllegalStateException if home is not retrieved 44 */ 45 EJBHome getEJBHome(); 46 47 /** 48 * @return the local home interface of the bean. 49 * throws IllegalStateException if local home is not retrieved 50 */ 51 EJBLocalHome getEJBLocalHome(); 52 53 /** 54 * @return deprecated 55 */ 56 @Deprecated 57 Properties getEnvironment(); 58 59 /** 60 * @return deprecated 61 */ 62 @Deprecated 63 Identity getCallerIdentity(); 64 65 /** 66 * @return the caller principal object. 67 */ 68 Principal getCallerPrincipal(); 69 70 /** 71 * @param role deprecated 72 * @return deprecated 73 */ 74 @Deprecated 75 boolean isCallerInRole(final Identity role); 76 77 /** 78 * Check if the given role is in the roles of the current caller's 79 * principal. 80 * @param roleName the role to check. 81 * @return true if it is included, else false. 82 */ 83 boolean isCallerInRole(final String roleName); 84 85 /** 86 * Gets the current transaction. 87 * @return the transaction object 88 * @throws IllegalStateException in case of Container Managed Transaction. 89 */ 90 UserTransaction getUserTransaction() throws IllegalStateException; 91 92 /** 93 * Sets the current transaction in rollback only mode. 94 * @throws IllegalStateException in CMT case 95 */ 96 void setRollbackOnly() throws IllegalStateException; 97 98 /** 99 * Check if current transaction is marked as rollback only. 100 * @return true if current tx is in rollback mode. 101 * @throws IllegalStateException if used with CMT. 102 */ 103 boolean getRollbackOnly() throws IllegalStateException; 104 105 /** 106 * Gets the timer service. 107 * @return an instance of the timer service. 108 * @throws IllegalStateException if used within a SFSB. 109 */ 110 TimerService getTimerService() throws IllegalStateException; 111 112 /** 113 * Search the given name in java:comp/env ENC environment. 114 * @param name the name to search 115 * @return null if not found, else an instance of the object found. 116 * @since EJB 3.0 version. 117 */ 118 Object lookup(final String name); 119 } 120