Methods Summary |
---|
protected ComponentContext | _getContext(Invocation inv)Called from preInvoke which is called from the EJBObject
for local and remote invocations.
try {
SessionContextImpl sessionCtx =
(SessionContextImpl) pool.getObject(null);
sessionCtx.setState(INVOKING);
return sessionCtx;
} catch (Exception ex) {
throw new EJBException(ex);
}
|
public void | activateEJB(java.lang.Object ctx, java.lang.Object instanceKey)
|
void | afterBegin(EJBContextImpl context)
// Stateless SessionBeans cannot implement SessionSynchronization!!
// EJB2.0 Spec 7.8.
|
void | afterCompletion(EJBContextImpl ctx, int status)
// Stateless SessionBeans cannot implement SessionSynchronization!!
// EJB2.0 Spec 7.8.
// We dissociate the transaction from the bean in releaseContext above
|
public void | appendStats(java.lang.StringBuffer sbuf)
sbuf.append("\nStatelessContainer: ")
.append("CreateCount=").append(statCreateCount).append("; ")
.append("RemoveCount=").append(statRemoveCount).append("; ")
.append("]");
|
void | beforeCompletion(EJBContextImpl context)
// Stateless SessionBeans cannot implement SessionSynchronization!!
// EJB2.0 Spec 7.8.
|
void | checkExists(EJBLocalRemoteObject ejbObj)Check if the given EJBObject/LocalObject has been removed.
// For stateless session beans, EJBObject/EJBLocalObj are never removed.
// So do nothing.
|
public EJBLocalObjectImpl | createEJBLocalBusinessObjectImpl()Called during internal creation of session bean
// No access checks needed because this is called as a result
// of an internal creation, not a user-visible create method.
return theEJBLocalBusinessObjectImpl;
|
public EJBLocalObjectImpl | createEJBLocalObjectImpl()Called during client creation request through EJB LocalHome view.
// Need to do access control check here because BaseContainer.preInvoke
// is not called for stateless sessionbean creates.
authorizeLocalMethod(EJBLocalHome_create);
if ( AppVerification.doInstrument() ) {
AppVerification.getInstrumentLogger().doInstrumentForEjb(
ejbDescriptor, localHomeCreateMethod, null);
}
// For stateless EJBs, EJB2.0 Section 7.8 says that
// Home.create() need not do any real creation.
// If necessary, a stateless bean is created below during getContext().
return theEJBLocalObjectImpl;
|
public EJBObjectImpl | createEJBObjectImpl()
// Need to do access control check here because BaseContainer.preInvoke
// is not called for stateless sessionbean creates.
authorizeRemoteMethod(EJBHome_create);
if ( AppVerification.doInstrument() ) {
AppVerification.getInstrumentLogger().doInstrumentForEjb(
ejbDescriptor, homeCreateMethod, null);
}
statCreateCount++;
// For stateless EJBs, EJB2.0 Section 7.8 says that
// Home.create() need not do any real creation.
// If necessary, a stateless bean is created below during getContext().
return theEJBObjectImpl;
|
public EJBObjectImpl | createRemoteBusinessObjectImpl()
// No access check since this is an internal operation.
statCreateCount++;
return theRemoteBusinessObjectImpl;
|
private SessionContextImpl | createStatelessEJB()called when an invocation arrives and there are no instances
left to deliver the invocation to.
Called from SessionContextFactory.create() !
ComponentInvocation ci = null;
SessionContextImpl context;
try {
// create new stateless EJB
Object ejb = ejbClass.newInstance();
// create SessionContext and set it in the EJB
context = new SessionContextImpl(ejb, this);
context.setInterceptorInstances(
interceptorManager.createInterceptorInstances());
// this allows JNDI lookups from setSessionContext, ejbCreate
ci = new ComponentInvocation(ejb, this, context);
invocationManager.preInvoke(ci);
// setSessionContext will be called without a Tx as required
// by the spec, because the EJBHome.create would have been called
// after the container suspended any client Tx.
// setSessionContext is also called before context.setEJBStub
// because the bean is not allowed to do EJBContext.getEJBObject
if( ejb instanceof SessionBean ) {
((SessionBean)ejb).setSessionContext(context);
}
// Perform injection right after where setSessionContext
// would be called. This is important since injection methods
// have the same "operations allowed" permissions as
// setSessionContext.
injectionManager.injectInstance(ejb, ejbDescriptor, false);
for (Object interceptorInstance : context.getInterceptorInstances()) {
injectionManager.injectInstance(interceptorInstance,
ejbDescriptor, false);
}
if ( isRemote ) {
if( hasRemoteHomeView ) {
context.setEJBObjectImpl(theEJBObjectImpl);
context.setEJBStub(theEJBStub);
}
if( hasRemoteBusinessView ) {
context.setEJBRemoteBusinessObjectImpl
(theRemoteBusinessObjectImpl);
}
}
if ( isLocal ) {
if( hasLocalHomeView ) {
context.setEJBLocalObjectImpl(theEJBLocalObjectImpl);
}
if( hasLocalBusinessView ) {
context.setEJBLocalBusinessObjectImpl
(theEJBLocalBusinessObjectImpl);
}
}
// all stateless beans have the same id and same InstanceKey
context.setInstanceKey(statelessInstanceKey);
//Call ejbCreate() or @PostConstruct method
interceptorManager.intercept(
CallbackType.POST_CONSTRUCT, context);
// Set the state to POOLED after ejbCreate so that
// EJBContext methods not allowed will throw exceptions
context.setState(POOLED);
} catch ( Throwable th ) {
_logger.log(Level.INFO, "ejb.stateless_ejbcreate_exception", th);
CreateException creEx = new CreateException("Could not create stateless EJB");
creEx.initCause(th);
throw creEx;
} finally {
if ( ci != null ) {
invocationManager.postInvoke(ci);
}
}
context.touch();
return context;
|
void | doTimerInvocationInit(Invocation inv, RuntimeTimerState timerState)
if( isRemote ) {
inv.ejbObject = theEJBObjectImpl;
inv.isLocal = false;
} else {
inv.ejbObject = theEJBLocalObjectImpl;
inv.isLocal = true;
}
|
void | forceDestroyBean(EJBContextImpl sc)Force destroy the EJB. Called from postInvokeTx.
Note: EJB2.0 section 18.3.1 says that discarding an EJB
means that no methods other than finalize() should be invoked on it.
if ( sc.getState() == DESTROYED )
return;
// mark context as destroyed
sc.setState(DESTROYED);
//sessionCtxPool.destroyObject(sc);
pool.destroyObject(sc);
|
EJBLocalObjectImpl | getEJBLocalBusinessObjectImpl(java.lang.Object key)Called from EJBLocalObjectImpl.getLocalObject() while deserializing
a local business object reference.
return theEJBLocalBusinessObjectImpl;
|
EJBLocalObjectImpl | getEJBLocalObjectImpl(java.lang.Object key)Called from EJBLocalObjectImpl.getLocalObject() while deserializing
a local object reference.
return theEJBLocalObjectImpl;
|
EJBObjectImpl | getEJBObjectImpl(byte[] instanceKey)Called when a remote invocation arrives for an EJB.
return theEJBObjectImpl;
|
EJBObjectImpl | getEJBRemoteBusinessObjectImpl(byte[] instanceKey)
return theRemoteBusinessObjectImpl;
|
public int | getMaxPoolSize()
return (poolProp.maxPoolSize <= 0)
? Integer.MAX_VALUE
: poolProp.maxPoolSize;
|
public long | getMethodReadyCount()
return pool.getSize();
|
public java.lang.String | getMonitorAttributeValues()
StringBuffer sbuf = new StringBuffer();
sbuf.append("STATELESS ").append(ejbDescriptor.getName());
sbuf.append(pool.getAllAttrValues());
sbuf.append("]");
return sbuf.toString();
|
public int | getSteadyPoolSize()
return (poolProp.steadyPoolSize <= 0)
? 0
: poolProp.steadyPoolSize;
|
protected void | initializeHome()
super.initializeHome();
if ( isRemote ) {
if( hasRemoteHomeView ) {
// Create theEJBObjectImpl
theEJBObjectImpl = instantiateEJBObjectImpl();
theEJBObject = (EJBObject) theEJBObjectImpl.getEJBObject();
// connect the EJBObject to the ProtocolManager
// (creates the stub
// too). Note: cant do this in constructor above because
// containerId is not set at that time.
theEJBStub = (EJBObject)
remoteHomeRefFactory.createRemoteReference
(statelessInstanceKey);
theEJBObjectImpl.setStub(theEJBStub);
}
if( hasRemoteBusinessView ) {
theRemoteBusinessObjectImpl =
instantiateRemoteBusinessObjectImpl();
theRemoteBusinessObject =
theRemoteBusinessObjectImpl.getEJBObject();
for(RemoteBusinessIntfInfo next :
remoteBusinessIntfInfo.values()) {
java.rmi.Remote stub = next.referenceFactory.
createRemoteReference(statelessInstanceKey);
theRemoteBusinessStubs.put
(next.generatedRemoteIntf.getName(), stub);
theRemoteBusinessObjectImpl.setStub
(next.generatedRemoteIntf.getName(), stub);
}
}
}
if ( isLocal ) {
if( hasLocalHomeView ) {
theEJBLocalObjectImpl = instantiateEJBLocalObjectImpl();
}
if( hasLocalBusinessView ) {
theEJBLocalBusinessObjectImpl =
instantiateEJBLocalBusinessObjectImpl();
}
}
if( isWebServiceEndpoint ) {
EjbBundleDescriptor bundle =
ejbDescriptor.getEjbBundleDescriptor();
WebServicesDescriptor webServices = bundle.getWebServices();
Collection myEndpoints =
webServices.getEndpointsImplementedBy(ejbDescriptor);
//FindBugs [Deadstore] Long ejbId = new Long(ejbDescriptor.getUniqueId());
// An ejb can only be exposed through 1 web service endpoint
Iterator iter = myEndpoints.iterator();
com.sun.enterprise.deployment.WebServiceEndpoint next =
(com.sun.enterprise.deployment.WebServiceEndpoint) iter.next();
Class serviceEndpointIntfClass =
loader.loadClass(next.getServiceEndpointInterface());
if (!serviceEndpointIntfClass.isInterface()) {
ServiceInterfaceGenerator generator = new ServiceInterfaceGenerator(loader, ejbClass);
serviceEndpointIntfClass = WsUtil.generateAndLoad(generator, loader);
if (serviceEndpointIntfClass==null) {
throw new RuntimeException("Error generating the SEI");
}
}
Class tieClass=null;
WebServiceInvocationHandler invocationHandler =
new WebServiceInvocationHandler(ejbClass, next,
serviceEndpointIntfClass,
webServiceInvocationInfoMap);
invocationHandler.setContainer(this);
Object servant = (Object) Proxy.newProxyInstance
(loader, new Class[] { serviceEndpointIntfClass },
invocationHandler);
// starting in 2.0, there is no more generated Ties
if (next.getTieClassName()!=null) {
tieClass = loader.loadClass(next.getTieClassName());
}
webServiceEndpoint = WebServiceEjbEndpointRegistry.getRegistry().createEjbEndpointInfo(next, this, servant, tieClass);
WebServiceEjbEndpointRegistry.getRegistry().
registerEjbWebServiceEndpoint(webServiceEndpoint);
}
ObjectFactory sessionCtxFactory = new SessionContextFactory();
poolProp = new PoolProperties();
pool= new NonBlockingPool(ejbDescriptor.getName(),
sessionCtxFactory, poolProp.steadyPoolSize,
poolProp.poolResizeQuantity, poolProp.maxPoolSize,
poolProp.poolIdleTimeoutInSeconds, loader);
registerMonitorableComponents();
|
boolean | isIdentical(EJBObjectImpl ejbo, EJBObject other)
if ( other == ejbo.getStub() ) {
return true;
}else {
try {
// other may be a stub for a remote object.
// Although all stateless sessionbeans for a bean type
// are identical, we dont know whether other is of the
// same bean type as ejbo.
if ( protocolMgr.isIdentical(ejbo.getStub(), other) )
return true;
else
return false;
} catch ( Exception ex ) {
if(_logger.isLoggable(Level.SEVERE)) {
_logger.log(Level.SEVERE,"ejb.ejb_getstub_exception",
logParams);
_logger.log(Level.SEVERE,"",ex);
}
throw new RemoteException("Error during isIdentical.", ex);
}
}
|
public void | onReady()
|
public boolean | passivateEJB(ComponentContext context)
return false;
|
protected void | registerMonitorableComponents()
registryMediator.registerProvider(this);
registryMediator.registerProvider(pool);
super.registerMonitorableComponents();
super.populateMethodMonitorMap();
_logger.log(Level.FINE, "[SLSB Container] registered monitorable");
|
public void | releaseContext(Invocation inv)Called from preInvoke which is called from the EJBObject
for local and remote invocations.
SessionContextImpl sc = (SessionContextImpl)inv.context;
// check if the bean was destroyed
if ( sc.getState()==DESTROYED )
return;
sc.setState(POOLED);
// Stateless beans cant have transactions across invocations
sc.setTransaction(null);
sc.touch();
pool.returnObject(sc);
|
void | removeBean(EJBLocalRemoteObject ejbo, java.lang.reflect.Method removeMethod, boolean local)
if( local ) {
authorizeLocalMethod(BaseContainer.EJBLocalObject_remove);
} else {
authorizeRemoteMethod(BaseContainer.EJBObject_remove);
}
statRemoveCount++;
|
public void | undeploy()
//Change the container state to ensure that all new invocations will be rejected
super.setUndeployedState();
try {
if( isWebServiceEndpoint && (webServiceEndpoint != null) ) {
String endpointAddress =
webServiceEndpoint.getEndpointAddressUri();
WebServiceEjbEndpointRegistry.getRegistry().
unregisterEjbWebServiceEndpoint(endpointAddress);
}
EjbBundleDescriptor desc = ejbDescriptor.getEjbBundleDescriptor();
if (desc != null && desc.getServiceReferenceDescriptors()!= null) {
for (Object srd : desc.getServiceReferenceDescriptors()) {
ClientPipeCloser.getInstance()
.cleanupClientPipe((ServiceReferenceDescriptor)srd);
}
}
if ( hasRemoteHomeView ) {
// destroy EJBObject refs
// XXX invocations still in progress will get exceptions ??
remoteHomeRefFactory.destroyReference
(theEJBObjectImpl.getStub(),
theEJBObjectImpl.getEJBObject());
}
if ( hasRemoteBusinessView ) {
for(RemoteBusinessIntfInfo next :
remoteBusinessIntfInfo.values()) {
next.referenceFactory.destroyReference
(theRemoteBusinessObjectImpl.getStub
(next.generatedRemoteIntf.getName()),
theRemoteBusinessObjectImpl.getEJBObject
(next.generatedRemoteIntf.getName()));
}
}
isPoolClosed = true;
pool.close();
} finally {
super.undeploy();
this.homeCreateMethod = null;
this.localHomeCreateMethod = null;
this.theEJBLocalObjectImpl = null;
this.theEJBObjectImpl = null;
this.theEJBStub = null;
this.pool = null;
this.iased = null;
this.beanCacheDes = null;
this.beanPoolDes = null;
this.svr = null;
this.ejbContainer = null;
this.poolProp = null;
}
|
public boolean | userTransactionMethodsAllowed(ComponentInvocation inv)
boolean utMethodsAllowed = false;
if( isBeanManagedTran ) {
if( inv instanceof Invocation ) {
Invocation i = (Invocation) inv;
EJBContextImpl sc = (EJBContextImpl) i.context;
// If Invocation, only ejbRemove not allowed.
utMethodsAllowed = !sc.isInEjbRemove();
} else {
// This will prevent setSessionContext/ejbCreate access
utMethodsAllowed = false;
}
}
return utMethodsAllowed;
|