Methods Summary |
---|
public Container | createContainer(EjbDescriptor ejbDescriptor, java.lang.ClassLoader loader, com.sun.enterprise.SecurityManager sm, com.sun.enterprise.config.ConfigContext dynamicConfigContext)
BaseContainer container = null;
boolean hasHome = true;
String commitOption = null;
String appid = ejbDescriptor.getApplication().getRegistrationName();
String archiveuri = ejbDescriptor.getEjbBundleDescriptor().
getModuleDescriptor().getArchiveUri();
String modulename =
com.sun.enterprise.util.io.FileUtils.makeFriendlyFilename(archiveuri);
String ejbname = ejbDescriptor.getName();
IASEjbExtraDescriptors iased = null;
//Server svr = null;
Config cfg = null;
EjbContainer ejbContainerDesc = null;
try {
// instantiate container class
if (ejbDescriptor instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sd = (EjbSessionDescriptor)ejbDescriptor;
if ( sd.isStateless() ) {
container = new StatelessSessionContainer(ejbDescriptor, loader);
} else {
//container = new StatefulSessionContainer(ejbDescriptor, loader);
BaseContainerBuilder builder =
new StatefulContainerBuilder();
builder.buildContainer(ejbDescriptor, loader,
dynamicConfigContext);
container = builder.getContainer();
//containers.put(ejbDescriptor.getUniqueId(), container);
//builder.completeInitialization(sm);
}
} else if ( ejbDescriptor instanceof EjbMessageBeanDescriptor ) {
container = new MessageBeanContainer(ejbDescriptor, loader);
// Message-driven beans don't have a home or remote interface.
hasHome = false;
} else {
if (((EjbEntityDescriptor)ejbDescriptor).getIASEjbExtraDescriptors()
.isIsReadOnlyBean()) {
EjbEntityDescriptor robDesc = (EjbEntityDescriptor) ejbDescriptor;
container = new ReadOnlyBeanContainer (ejbDescriptor, loader);
} else
if ((ejbDescriptor.getLocalHomeClassName() != null) &&
(ejbDescriptor.getLocalHomeClassName()
.equals("com.sun.ejb.containers.TimerLocalHome"))) {
container = new TimerBeanContainer(ejbDescriptor, loader);
} else {
iased = ((EjbEntityDescriptor)ejbDescriptor).
getIASEjbExtraDescriptors();
if (iased != null) {
commitOption = iased.getCommitOption();
}
if (commitOption == null) {
try {
ServerContext sc =
ApplicationServer.getServerContext();
cfg = ServerBeansFactory.getConfigBean
(sc.getConfigContext());
} catch (ConfigException ex) {
_logger.log(Level.WARNING,
"ejb.createContainer_exception", ex);
}
ejbContainerDesc = cfg.getEjbContainer();
commitOption = ejbContainerDesc.getCommitOption();
}
if (commitOption.equals("A")) {
_logger.log(Level.WARNING,
"ejb.commit_option_A_not_supported",
new Object []{ejbDescriptor.getName()}
);
container =
new EntityContainer(ejbDescriptor, loader);
} else if (commitOption.equals("C")) {
_logger.log(Level.FINE, "Using commit option C for: "
+ ejbDescriptor.getName());
container = new CommitCEntityContainer(ejbDescriptor,
loader);
} else {
_logger.log(Level.FINE,"Using commit option B for: " +
ejbDescriptor.getName());
container = new EntityContainer(ejbDescriptor, loader);
}
}
}
containers.put(ejbDescriptor.getUniqueId(), container);
container.setSecurityManager(sm);
// Initialize home after putting the container into containers,
// so that any calls from ProtocolManager during home initialization
// (e.g. is_a during PRO.narrow) will work.
if ( hasHome ) {
container.initializeHome();
}
container.setDebugMonitorFlag(debugMonitoring);
return container;
} catch ( InvalidNameException ex ) {
_logger.log(Level.SEVERE,"ejb.create_container_exception", ex.toString());
_logger.log(Level.SEVERE,"Invalid jndiName for" + "appId=" + appid +
"; moduleName=" + modulename + "; ejbName=" + ejbname);
_logger.log(Level.SEVERE,"jndiName=" + ejbDescriptor.getJndiName());
// removes the ejb from containers table
try {
removeContainer(ejbDescriptor.getUniqueId());
} catch (Exception e) {
_logger.log(Level.FINE, "", e);
}
throw ex;
} catch (UnsupportedOperationException unSupEx) {
throw unSupEx;
} catch ( Exception ex ) {
_logger.log(Level.SEVERE,"ejb.create_container_exception", ex.toString());
_logger.log(Level.SEVERE,"appId=" + appid + " moduleName=" + modulename +
" ejbName=" + ejbname);
if (debug) {
_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
// removes the ejb from containers table
try {
removeContainer(ejbDescriptor.getUniqueId());
} catch (Exception e) {
_logger.log(Level.FINE, "", e);
}
throw ex;
}
|
java.util.Vector | getBeans(javax.transaction.Transaction tx)
TxData txData = (TxData) ((J2EETransaction) tx).getContainerData();
if ( txData == null ) {
txData = new TxData();
((J2EETransaction)tx).setContainerData(txData);
}
if( txData.beans == null ) {
txData.beans = new Vector();
}
return txData.beans;
|
public Container | getContainer(long ejbId)Get the container instance corresponding to the given EJB id.
Called from the POAProtocolMgr when an invocation arrives for
the home/remote object (and other callers).
return (Container)containers.get(ejbId);
|
public static com.sun.ejb.spi.container.ContainerService | getContainerService()
return _containerService;
|
ContainerSynchronization | getContainerSync(javax.transaction.Transaction tx)Get/create a ContainerSynchronization object for the given tx.
Called only from BaseContainer.
TxData txData = (TxData) ((J2EETransaction) tx).getContainerData();
if ( txData == null ) {
txData = new TxData();
((J2EETransaction)tx).setContainerData(txData);
}
if( txData.sync == null ) {
txData.sync = new ContainerSynchronization(tx, this);
tx.registerSynchronization(txData.sync);
}
return txData.sync;
|
private void | getDebugMonitoringDetails()
try{
Properties props = System.getProperties();
String str=props.getProperty("MONITOR_EJB_CONTAINER");
if( null != str) {
str = str.toLowerCase();
debugMonitoring = Boolean.valueOf(str).booleanValue();
String period =
props.getProperty("MONITOR_EJB_TIME_PERIOD_SECONDS");
if (period != null) {
debugMonitoringPeriodMS =
(new Long(period).longValue())* 1000;
}
}
} catch(Exception e) {
_logger.log(Level.INFO,
"ContainerFactoryImpl.getDebugMonitoringDetails(), " +
" Exception when trying to " +
"get the System properties - ", e);
}
|
public java.lang.Object | getEJBContextObject(java.lang.String contextType)
InvocationManager invMgr = Switch.getSwitch().getInvocationManager();
ComponentInvocation currentInv = invMgr.getCurrentInvocation();
if(currentInv == null) {
throw new IllegalStateException("no current invocation");
} else if (currentInv.getInvocationType() !=
ComponentInvocation.EJB_INVOCATION) {
throw new IllegalStateException
("Illegal invocation type for EJB Context : "
+ currentInv.getInvocationType());
}
Object returnObject = currentInv.context;
if( contextType.equals("javax.ejb.TimerService") ) {
if( ejbTimerService == null ) {
throw new IllegalStateException("EJB Timer Service not " +
"available");
}
returnObject = new EJBTimerServiceWrapper
(ejbTimerService, (EJBContextImpl) currentInv.context);
}
return returnObject;
|
EJBTimerService | getEJBTimerService()
return ejbTimerService;
|
public EjbDescriptor | getEjbDescriptor(long ejbId)Return the EjbDescriptor for the given ejbId.
Called from the ProtocolManager.
Container c = (Container)containers.get(ejbId);
if ( c == null ) {
return null;
}
return c.getEjbDescriptor();
|
public static java.util.Timer | getTimer()
return _timer;
|
public javax.transaction.TransactionManager | getTransactionMgr()
return pmtm;
|
public void | initEJBTimerService()
ejbTimerService = null;
|
public java.util.Enumeration | listContainers()List all container instances in this JVM.
return containers.elements();
|
public javax.persistence.EntityManager | lookupExtendedEntityManager(javax.persistence.EntityManagerFactory factory)
Switch theSwitch = Switch.getSwitch();
InvocationManager invMgr = theSwitch.getInvocationManager();
ComponentInvocation inv = invMgr.getCurrentInvocation();
EntityManager em = null;
if( (inv != null) &&
(inv.getInvocationType() == ComponentInvocation.EJB_INVOCATION )) {
EjbDescriptor ejbDesc = (EjbDescriptor)
theSwitch.getDescriptorFor(inv.getContainerContext());
if( (ejbDesc instanceof EjbSessionDescriptor) &&
( ((EjbSessionDescriptor)ejbDesc).isStateful() ) ) {
em = ((SessionContextImpl)inv.context).
getExtendedEntityManager(factory);
}
}
return em;
|
public void | removeContainer(long ejbId)Remove the container instance corresponding to the given EJB id.
containers.remove(ejbId);
|
void | removeContainerSync(javax.transaction.Transaction tx)
|
public void | restoreEJBTimers()
if( ejbTimerService != null ) {
ejbTimerService.restoreTimers();
}
|
public void | setEJBTimerService(EJBTimerService ejbTimerService)Set EJB Timer Service. Can be null if timer service is being disabled.
this.ejbTimerService = ejbTimerService;
DistributedEJBServiceFactory.setDistributedEJBTimerService(
(DistributedEJBTimerService)ejbTimerService );
if( null != ejbTimerService ) {
//Register the Admin event listener to satisfy requests from the
//admin cli. The AdminEJBTimerListerner is created as a singleton
AdminEJBTimerEventListenerImpl.getEjbTimerEventListener();
}
|
public void | shutdownEJBTimerService()
if( ejbTimerService != null ) {
ejbTimerService.shutdown();
}
|