All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.ejb.EJBContext Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

The newest version!
/*
 * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package jakarta.ejb;

import java.util.*;
import java.security.Principal;
import jakarta.transaction.UserTransaction;

/**
 * The EJBContext interface provides an instance with access to the container-provided runtime context of an enterprise
 * bean instance.
 *
 * 

* This interface is extended by the SessionContext, EntityContext, and * MessageDrivenContext interfaces to provide additional methods specific to the enterprise interface bean * type. * * @see SessionContext * @see MessageDrivenContext * @see EntityContext * @since EJB 1.0 */ public interface EJBContext { /** * Obtain the enterprise bean's remote home interface. * * @return The enterprise bean's remote home interface. * @exception java.lang.IllegalStateException if the enterprise bean does not have a remote home interface. */ EJBHome getEJBHome() throws IllegalStateException; /** * Obtain the enterprise bean's local home interface. * * @return The enterprise bean's local home interface. * @exception java.lang.IllegalStateException if the enterprise bean does not have a local home interface. * @since EJB 2.0 */ EJBLocalHome getEJBLocalHome() throws IllegalStateException; /** * Obtain the java.security.Principal that identifies the caller. * * @return The Principal object that identifies the caller. This method never returns null. * @exception IllegalStateException The Container throws the exception if the instance is not allowed to call this * method. * @since EJB 1.1 */ Principal getCallerPrincipal() throws IllegalStateException; /** * Test if the caller has a given security role. * * @param roleName The name of the security role. The role must be one of the security roles that is defined in the * deployment descriptor. * @return True if the caller has the specified role. * @exception IllegalStateException The Container throws the exception if the instance is not allowed to call this * method. * @since EJB 1.1 */ boolean isCallerInRole(String roleName) throws IllegalStateException; /** * Obtain the transaction demarcation interface. * * Only enterprise beans with bean-managed transactions are allowed to to use the UserTransaction * interface. As entity beans must always use container-managed transactions, only session beans or message-driven beans * with bean-managed transactions are allowed to invoke this method. * * @return The UserTransaction interface that the enterprise bean instance can use for transaction * demarcation. * @exception IllegalStateException The Container throws the exception if the instance is not allowed to use the * UserTransaction interface (i.e. the instance is of a bean with container-managed transactions). */ UserTransaction getUserTransaction() throws IllegalStateException; /** * Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction * marked for rollback can never commit. * * Only enterprise beans with container-managed transactions are allowed to use this method. * * @exception IllegalStateException The Container throws the exception if the instance is not allowed to use this method * (i.e. the instance is of a bean with bean-managed transactions). */ void setRollbackOnly() throws IllegalStateException; /** * Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for * example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the * current transaction. * * Only enterprise beans with container-managed transactions are allowed to use this method. * * @return True if the current transaction is marked for rollback, false otherwise. * @exception IllegalStateException The Container throws the exception if the instance is not allowed to use this method * (i.e. the instance is of a bean with bean-managed transactions). */ boolean getRollbackOnly() throws IllegalStateException; /** * Get access to the enterprise bean Timer Service. * * @exception IllegalStateException The Container throws the exception if the instance is not allowed to use this method * (e.g. if the bean is a stateful session bean) * @since EJB 2.1 * @return a {@link jakarta.ejb.TimerService} object. */ TimerService getTimerService() throws IllegalStateException; /** * Lookup a resource within the java: namespace. Names referring to entries within the private component * namespace can be passed as unqualified strings. In that case the lookup will be relative to * "java:comp/env/". * * For example, assuming an enterprise bean defines an ejb-local-ref with ejb-ref-name * "ejb/BarRef" the following two calls to EJBContext.lookup are equivalent : * * ejbContext.lookup("ejb/BarRef"); ejbContext.lookup("java:comp/env/ejb/BarRef"); * * @param name Name of the entry * @exception IllegalArgumentException The Container throws the exception if the given name does not match an entry * within the component's environment. * @since EJB 3.0 * @return a {@link java.lang.Object} object. */ Object lookup(String name) throws IllegalArgumentException; /** * The getContextData method enables a business method, lifecycle callback method, or timeout method to * retrieve any interceptor/webservices context associated with its invocation. * * @return the context data that interceptor context associated with this invocation. If there is no context data, an * empty Map<String,Object> object will be returned. * @since EJB 3.1 */ Map getContextData(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy