Fields Summary |
---|
private static final Logger | _logger |
private static com.sun.enterprise.util.LocalStringManagerImpl | localStrings |
protected static final int | NOT_INITIALIZED |
private Object | ejb |
protected transient BaseContainer | container |
protected transient Transaction | transaction |
private transient Context | initialContext |
private transient ArrayList | resources |
private transient int | concInvokeCount |
protected transient EJBObject | ejbStub |
protected transient EJBObjectImpl | ejbObjectImpl |
protected transient EJBObjectImpl | ejbRemoteBusinessObjectImpl |
protected transient EJBLocalObjectImpl | ejbLocalObjectImpl |
protected transient EJBLocalObjectImpl | ejbLocalBusinessObjectImpl |
private transient long | lastTimeUsed |
protected transient int | state |
protected final boolean | isRemoteInterfaceSupported |
protected final boolean | isLocalInterfaceSupported |
protected transient boolean | inEjbRemove |
private Object[] | interceptorInstances |
Methods Summary |
---|
protected void | checkAccessToCallerSecurity()Overridden in containers that allow access to isCallerInRole() and
getCallerPrincipal()
throw new IllegalStateException("Operation not allowed");
|
protected void | checkActivatePassivate()
if( inActivatePassivate() ) {
throw new IllegalStateException("Operation not allowed.");
}
|
public void | checkTimerServiceMethodAccess()The EJB spec makes a distinction between access to the TimerService
object itself (via EJBContext.getTimerService) and access to the
methods on TimerService, Timer, and TimerHandle. The latter case
is covered by this check. It is overridden in the applicable concrete
context impl subclasses.
throw new IllegalStateException("EJB Timer Service method calls " +
"cannot be called in this context");
|
public synchronized void | decrementConcurrentInvokeCount()Decrement the number of concurrent invocations on this bean
(could happen with re-entrant bean).
Used by TM.
concInvokeCount--;
|
void | deleteAllReferences()Called after this context is freed up.
ejb = null;
container = null;
transaction = null;
resources = null;
ejbStub = null;
ejbObjectImpl = null;
ejbRemoteBusinessObjectImpl = null;
ejbLocalObjectImpl = null;
ejbLocalBusinessObjectImpl = null;
|
public java.security.Identity | getCallerIdentity()
// This method is deprecated.
// see EJB2.0 section 21.2.5
throw new RuntimeException(
"getCallerIdentity() is deprecated, please use getCallerPrincipal().");
|
public java.security.Principal | getCallerPrincipal()
checkAccessToCallerSecurity();
com.sun.enterprise.SecurityManager sm = container.getSecurityManager();
return sm.getCallerPrincipal();
|
public int | getConcurrentInvokeCount()Get the number of concurrent invocations on this bean
(could happen with re-entrant bean).
Used by TM.
return concInvokeCount;
|
public Container | getContainer()
return container;
|
public java.lang.Object | getEJB()
return ejb;
|
public EJBHome | getEJBHome()
if (! isRemoteInterfaceSupported) {
throw new IllegalStateException("EJBHome not available");
}
return container.getEJBHomeStub();
|
EJBLocalObjectImpl | getEJBLocalBusinessObjectImpl()
return ejbLocalBusinessObjectImpl;
|
public EJBLocalHome | getEJBLocalHome()
if (! isLocalInterfaceSupported) {
throw new IllegalStateException("EJBLocalHome not available");
}
return container.getEJBLocalHome();
|
public EJBLocalObject | getEJBLocalObject()This is a SessionContext/EntityContext method.
if ( ejbLocalObjectImpl == null ) {
throw new IllegalStateException("EJBLocalObject not available");
}
// Have to convert EJBLocalObjectImpl to the client-view of
// EJBLocalObject
return (EJBLocalObject) ejbLocalObjectImpl.getClientObject();
|
EJBLocalObjectImpl | getEJBLocalObjectImpl()
return ejbLocalObjectImpl;
|
public EJBObject | getEJBObject()This is a SessionContext/EntityContext method.
if (ejbStub == null) {
throw new IllegalStateException("EJBObject not available");
}
return ejbStub;
|
EJBObjectImpl | getEJBObjectImpl()
return ejbObjectImpl;
|
EJBObjectImpl | getEJBRemoteBusinessObjectImpl()
return this.ejbRemoteBusinessObjectImpl;
|
public java.util.Properties | getEnvironment()
// This is deprecated, see EJB2.0 section 20.6.
return container.getEnvironmentProperties();
|
public java.lang.Object[] | getInterceptorInstances()
return this.interceptorInstances;
|
public long | getLastTimeUsed()
return lastTimeUsed;
|
public java.util.List | getResourceList()Get all the resources associated with the context
if (resources == null)
resources = new ArrayList(0);
return resources;
|
public boolean | getRollbackOnly()
if ( state == NOT_INITIALIZED )
throw new IllegalStateException("EJB not in READY state");
// EJB2.0 section 7.5.2: only EJBs with container managed transactions
// can use this method.
if ( container.isBeanManagedTx() )
throw new IllegalStateException(
"Illegal operation for bean-managed transactions");
J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
try {
int status = tm.getStatus();
if ( status == Status.STATUS_NO_TRANSACTION ) {
// EJB which was invoked without a global transaction.
throw new IllegalStateException("No transaction context.");
}
checkActivatePassivate();
if ( status == Status.STATUS_MARKED_ROLLBACK
|| status == Status.STATUS_ROLLEDBACK
|| status == Status.STATUS_ROLLING_BACK )
return true;
else
return false;
} catch (Exception ex) {
_logger.log(Level.FINE, "Exception in method getRollbackOnly()",
ex);
IllegalStateException illEx = new IllegalStateException(ex.toString());
illEx.initCause(ex);
throw illEx;
}
|
int | getState()
return state;
|
public javax.transaction.Transaction | getTransaction()
return transaction;
|
public javax.transaction.UserTransaction | getUserTransaction()
throw new IllegalStateException("Operation not allowed");
|
protected boolean | inActivatePassivate()
return inActivatePassivate(
container.invocationManager.getCurrentInvocation());
|
protected boolean | inActivatePassivate(ComponentInvocation inv)
boolean inActivatePassivate = false;
if ( inv instanceof Invocation ) {
Method currentMethod = ((Invocation)inv).method;
inActivatePassivate = (currentMethod != null)
? (currentMethod.getName().equals("ejbActivate") ||
currentMethod.getName().equals("ejbPassivate")
)
: false;
}
return inActivatePassivate;
|
public synchronized void | incrementConcurrentInvokeCount()Increment the number of concurrent invocations on this bean
(could happen with re-entrant bean).
Used by TM.
concInvokeCount++;
|
public boolean | isCallerInRole(java.security.Identity identity)
// THis method is deprecated.
// This implementation is as in EJB2.0 section 21.2.5
return isCallerInRole(identity.getName());
|
public boolean | isCallerInRole(java.lang.String roleRef)
if ( roleRef == null )
throw new IllegalArgumentException("Argument is null");
checkAccessToCallerSecurity();
EjbDescriptor ejbd = container.getEjbDescriptor();
RoleReference rr = ejbd.getRoleReferenceByName(roleRef);
if ( rr == null ) {
throw new IllegalArgumentException(
"No mapping available for role reference " + roleRef);
}
com.sun.enterprise.SecurityManager sm = container.getSecurityManager();
return sm.isCallerInRole(roleRef);
|
boolean | isInEjbRemove()
return inEjbRemove;
|
boolean | isTimedObject()
return container.isTimedObject();
|
boolean | isUnitialized()Returns true if this context has NOT progressed past its initial
state. The point at which this happens is container-specific.
return (state == NOT_INITIALIZED);
|
public java.lang.Object | lookup(java.lang.String name)
Object o = null;
if( name == null ) {
throw new IllegalArgumentException("Argument is null");
}
try {
if( initialContext == null ) {
initialContext = new InitialContext();
}
// name is relative to the private component namespace
o = initialContext.lookup("java:comp/env/" + name);
} catch(Exception e) {
throw new IllegalArgumentException(e);
}
return o;
|
public void | registerResource(com.sun.enterprise.resource.ResourceHandle h)Register a resource opened by the EJB instance
associated with this Context.
if ( resources == null )
resources = new ArrayList();
resources.add(h);
|
void | setContainer(BaseContainer container)
this.container = container;
|
void | setEJBLocalBusinessObjectImpl(EJBLocalObjectImpl localBusObjectImpl)
this.ejbLocalBusinessObjectImpl = localBusObjectImpl;
|
void | setEJBLocalObjectImpl(EJBLocalObjectImpl localObjectImpl)
this.ejbLocalObjectImpl = localObjectImpl;
|
void | setEJBObjectImpl(EJBObjectImpl ejbo)
this.ejbObjectImpl = ejbo;
|
void | setEJBRemoteBusinessObjectImpl(EJBObjectImpl ejbo)
this.ejbRemoteBusinessObjectImpl = ejbo;
|
void | setEJBStub(EJBObject ejbStub)
this.ejbStub = ejbStub;
|
void | setHardRef(java.lang.Object referent)
|
void | setInEjbRemove(boolean beingRemoved)
inEjbRemove = beingRemoved;
|
void | setInterceptorInstances(java.lang.Object[] instances)The following are EJBContextImpl-specific methods.
this.interceptorInstances = instances;
|
public void | setRollbackOnly()
if ( state == NOT_INITIALIZED )
throw new IllegalStateException("EJB not in READY state");
// EJB2.0 section 7.5.2: only EJBs with container managed transactions
// can use this method.
if ( container.isBeanManagedTx() )
throw new IllegalStateException(
"Illegal operation for bean-managed transactions");
J2EETransactionManager tm = Switch.getSwitch().getTransactionManager();
try {
if ( tm.getStatus() == Status.STATUS_NO_TRANSACTION ) {
// EJB might be in a non-business method (for SessionBeans)
// or afterCompletion.
// OR this was a NotSupported/Never/Supports
// EJB which was invoked without a global transaction.
// In that case the JDBC connection would have autoCommit=true
// so the container doesnt have to do anything.
throw new IllegalStateException("No transaction context.");
}
checkActivatePassivate();
tm.setRollbackOnly();
} catch (Exception ex) {
IllegalStateException illEx = new IllegalStateException(ex.toString());
illEx.initCause(ex);
throw illEx;
}
|
void | setSoftRef(java.lang.ref.SoftReference softRef)
|
void | setState(int s)
state = s;
|
public void | setTransaction(javax.transaction.Transaction tr)
transaction = tr;
|
void | touch()
lastTimeUsed = System.currentTimeMillis();
|
public void | unregisterResource(com.sun.enterprise.resource.ResourceHandle h)Unregister a resource from this Context.
if ( resources == null )
resources = new ArrayList();
resources.remove(h);
|