Methods Summary |
---|
abstract void | createLeafMBean(com.sun.enterprise.deployment.Descriptor descriptor)Create jsr77 mBean for the leaf object
The leaf mBean correspond to the child object of rootMBean.
For an ejb stand-alone module it will be ejb
and for a web stand-alone module it will be servlet
and for a connector stand-alone module it will be resource adapter
|
abstract void | createLeafMBeans()Create jsr77 mBeans for components within root mBean
The leaf mBeans correspond to the child objects of rootMBean.
For an ejb stand-alone module it will be ejbs
and for a web stand-alone module it will be servlets
and for a connector stand-alone module it will be resource adapters
|
abstract void | createRootMBean()Create jsr77 root mBean
The root mBean corresponds to either an application
or stand-alone module depending on j2ee type
|
abstract void | deleteLeafAndRootMBeans()Delete jsr77 mBeans for the root and its' components
|
abstract void | deleteLeafMBean(com.sun.enterprise.deployment.Descriptor descriptor)Delete jsr77 mBean for the leaf object
The leaf mBean correspond to the child object of rootMBean.
For an ejb stand-alone module it will be ejb
and for a web stand-alone module it will be servlet
and for a connector stand-alone module it will be resource adapter
|
abstract void | deleteLeafMBeans()Delete jsr77 mBeans for components within root mBean
The leaf mBeans correspond to the child objects of rootMBean.
For an ejb stand-alone module it will be ejbs
and for a web stand-alone module it will be servlets
and for a connector stand-alone module it will be resource adapters
|
abstract void | deleteRootMBean()Delete jsr77 root mBean
The root mBean corresponds to either an application
or stand-alone module depending on j2ee type
|
abstract boolean | doLoad(boolean jsr77)Loads a deployed application or stand alone module.
If jsr77 is true then corresponding jsr77 mBeans will be created
during load time.
|
protected void | done()Helps garbage collector by assigning member variables to null.
This is called from unload.
// releases resources (file handles, etc) in the class loader
if (this.ejbClassLoader instanceof EJBClassLoader) {
((EJBClassLoader) ejbClassLoader).done();
}
// set connector descriptor classloaders to null
Set rars = this.application.getRarDescriptors();
for (Iterator itr = rars.iterator(); itr.hasNext();) {
ConnectorDescriptor cd = (ConnectorDescriptor) itr.next();
cd.setClassLoader(null);
}
this.id = null;
this.parentClassLoader = null;
this.application = null;
this.ejbClassLoader = null;
this.registry = null;
this.configManager = null;
|
public void | generateEntryContext(java.lang.Object context)
ServerEntryHelper.generateAppLoaderEntryContext((Descriptor) context);
|
com.sun.enterprise.deployment.Application | getApplication()Returns the deployment descriptor object used by this loader.
return this.application;
|
protected boolean | getCascade()
return this.cascade;
|
java.lang.ClassLoader | getClassLoader()Returns the ejb class loader used by this loader.
return this.ejbClassLoader;
|
com.sun.enterprise.config.ConfigContext | getConfigContext()
return dynamicConfigContext;
|
protected int | getLoadUnloadAction()
return this.loadUnloadAction;
|
protected void | initializeLoader(java.lang.String[] classPaths, java.lang.String moduleRoot, javax.enterprise.deploy.shared.ModuleType moduleType)Initializes this loader by creating the ejb class loader.
this.ejbClassLoader = EJBClassPathUtils.createEJBClassLoader(
classPaths, moduleRoot, this.id, this.parentClassLoader, moduleType);
|
protected void | initializeLoader(java.lang.ClassLoader clazzloader)Initializes this loader to the given classloader
this.ejbClassLoader = clazzloader;
|
boolean | load(boolean jsr77)Loads a deployed application or stand alone module.
Verifies that the module's directory exists and is valid before
trying to load the module, so as to display a useful warning in the
log without displaying a stack trace from later failures (such as
failed attempts to load classes from the module).
If jsr77 is true then corresponding jsr77 mBeans will be created
during load time.
return (verifyModuleDirectory() && doLoad(jsr77));
|
protected boolean | loadEjbs(boolean jsr77)Creates the bean containers for all ejbs.
If jsr77 is true then corresponding jsr77 mBeans will be created
during load time.
// application.getApplicationArchivist().getClassLoader();
final ClassLoader loader = this.ejbClassLoader;
if (this.application == null) {
return false;
}
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[AbstractLoader] Id: " + this.id +
" Setting thread context class loader to: " + loader);
}
/*
*5003242 - Save current context class loader as it is changed. Restored in finally block of next try.
*/
ClassLoader savedContextClassLoader = Utility.setContextClassLoader(loader);
try {
if (!application.isVirtual()) {
// adds the ejb class loader to the repository
this.registry.addAppId2ClassLoader(this.id, this.ejbClassLoader);
} else {
this.registry.addModuleId2ClassLoader(this.id, this.ejbClassLoader);
}
// adds the deployment descriptor obj to the repository
this.registry.addClassLoader2Application(this.ejbClassLoader,
this.application);
HashSet myContainers = new HashSet();
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST,
"[AbstractLoader] Id: " + this.id
+ " Unique Id: " + this.application.getUniqueId());
}
Vector beanDescriptors = application.getEjbDescriptors();
// create EJB containers for each EJB
Enumeration e = beanDescriptors.elements();
ContainerFactory cf = Switch.getSwitch().getContainerFactory();
while (e.hasMoreElements()) {
EjbDescriptor nextDescriptor = (EjbDescriptor) e.nextElement();
// detects any unique id collisions
if ( !this.registry.isUnique( nextDescriptor.getUniqueId() ) ) {
_logger.log(Level.SEVERE, "loader.duplicate_unique_id",
new Object[] {
String.valueOf(nextDescriptor.getUniqueId()),
nextDescriptor.getName()
});
// unload all the ejbs
unloadEjbs(jsr77);
// abort loading
return false;
}
try {
if(ffsmf == null){
ffsmf = FactoryForSecurityManagerFactoryImpl.getInstance();
}
SecurityManagerFactory smf = ffsmf.getSecurityManagerFactory("ejb");
SecurityManager sm = smf.createSecurityManager(nextDescriptor);
// create the bean container
Container container = null;
try {
notifyEjbEvent(EjbContainerEvent.BEFORE_EJB_CONTAINER_LOAD,
nextDescriptor);
container = cf.createContainer(nextDescriptor, loader,
sm, dynamicConfigContext);
notifyEjbEvent(EjbContainerEvent.AFTER_EJB_CONTAINER_LOAD,
nextDescriptor);
} catch (NameAlreadyBoundException jndiEx) {
// logs a message
_logger.log(Level.SEVERE, "loader.jndi_name_conflict",
new Object[] {
this.id,
nextDescriptor.getJndiName(),
nextDescriptor.getName()
});
// logs the actual exception
_logger.log(Level.SEVERE,
"loader.naming_exception_in_createcontainer", jndiEx);
// remove all loaded ejbs
unloadEjbs(jsr77);
// abort loading
return false;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,
"Created container with uinque id: "
+ nextDescriptor.getUniqueId());
}
// adds the container to the repository
this.registry.addDescriptor2Container(nextDescriptor,container);
// adds the container to the temp local table
myContainers.add(container);
} catch (Exception beanEx) {
_logger.log(Level.SEVERE,
"loader.unexpected_error_while_creating_ejb_container",
beanEx);
// remove all loaded ejbs
unloadEjbs(jsr77);
return false;
}
if (jsr77) {
try {
createLeafMBean(nextDescriptor);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING, "loader.create_ejb_mbean_exception", mbe);
}
}
}
try {
Enumeration en = beanDescriptors.elements();
// generate policy files for applications with ejbs not otherwise
while (en.hasMoreElements()) {
EjbDescriptor nextDescriptor = (EjbDescriptor)en.nextElement();
SecurityUtil.generatePolicyFile(
EJBSecurityManager.getContextID(nextDescriptor));
}
} catch (Exception ge) {
_logger.log(Level.SEVERE,
"code.could_not_generate/load_the_policy_files_for_system_app",
ge);
// remove all loaded ejbs
unloadEjbs(jsr77);
return false;
}
// notify ejb containers that application deployment succeeded.
Iterator iter = myContainers.iterator();
while ( iter.hasNext() ) {
Container c = (Container) iter.next();
c.doAfterApplicationDeploy();
//IASRI 4717059 BEGIN
/*
if (robFlag) {
if ( c instanceof EntityContainer) {
( (EntityContainer) c).setROBNotifier(robNotifier);
}
}
*/
//IASRI 4717059 END
}
// diagnostics of all the roles and acls
com.sun.enterprise.security.Audit.showACL(this.application);
// log that ejbs were loaded
if (this.application.getEjbComponentCount() > 0) {
_logger.log(Level.INFO, "loader.ejbs_loaded", this.id);
}
_logger.log(Level.FINE,"[AbstractLoader] loadEjbs completed");
return true;
} finally {
/*
*5003242 - Restore saved context class loader.
*/
Utility.setContextClassLoader(savedContextClassLoader);
}
|
protected boolean | loadPersistenceUnits()Loads all the EJB 3.0 persistence entities bundled in this application.
try{
new PersistenceUnitLoaderImpl().load(new ApplicationInfoImpl());
return true;
}catch(Exception ge){
_logger.log(Level.WARNING, ge.getMessage(), ge);
return false;
}
|
protected boolean | loadRars(boolean jsr77)Load the rars of that application
If jsr77 is true then corresponding jsr77 mBeans will be created
during load time.
try {
String appLocation = this.configManager.getLocation(this.id);
Set rars = application.getRarDescriptors();
ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
for (Iterator itr = rars.iterator(); itr.hasNext();) {
ConnectorDescriptor cd = (ConnectorDescriptor) itr.next();
String rarName = cd.getDeployName();
String location = DeploymentUtils.getEmbeddedModulePath(
appLocation, rarName);
String jndiName = this.id+
ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER+
FileUtils.makeFriendlyFilenameNoExtension(rarName);
connectorRuntime.createActiveResourceAdapter(
cd,jndiName,location);
if (jsr77) {
createLeafMBean(cd);
}
}
// now load resources associated with these embedded RARs
try {
ConnectorResourcesLoader crl = new ConnectorResourcesLoader();
crl.loadEmbeddedRarResources(id,getApplication());
} catch (ConfigException cex) {
_logger.log(Level.SEVERE, "loader.connector_resource_initialization_error", cex);
}
} catch (Exception rarEx) {
_logger.log(Level.WARNING,
"loader.application_loader_exception", rarEx);
}
_logger.log(Level.FINE,"[AbstractLoader] loadRars completed");
return true;
|
protected boolean | loadWebserviceEndpoints(boolean jsr77)Loads all the Web Service Management MBeans.
If jsr77 is true then corresponding jsr77 mBeans will be created
during load time.
boolean result = true;
if (this.application == null) {
result = false;
} else {
Set bundleSet = new HashSet();
bundleSet.addAll(this.application.getEjbBundleDescriptors());
bundleSet.addAll(this.application.getWebBundleDescriptors());
// unload web service endpoint
Iterator itr = bundleSet.iterator();
while ( itr.hasNext() ) {
BundleDescriptor nextDescriptor = (BundleDescriptor)
itr.next();
try {
WSMonitorLifeCycleFactory.getInstance().
getWSMonitorLifeCycleProvider().
registerWebServiceEndpoints(
this.application.getRegistrationName(), nextDescriptor);
} catch (Exception e) {
_logger.log(Level.WARNING,
"loader.register_ws_endpoint_error",
this.application.getRegistrationName());
_logger.log(Level.WARNING,
"loader.register_ws_endpoint_exception", e);
result = false;
}
/*
if (jsr77) {
try {
createLeafMBeans(nextDescriptor);
} catch (MBeanException mbe) {
mbe.printStackTrace();
_logger.log(Level.WARNING,
"loader.create_ejb_mbean_exception", mbe);
}
}
*/
_logger.log(Level.FINE,
"[AbstractLoader] Unload Web Service Endpoint(s) Status: " +
result);
}
}
return result;
|
protected void | notifyAppEvent(int eventType)
ApplicationEvent event = new ApplicationEvent(eventType,
getApplication(), getClassLoader(), dynamicConfigContext);
generateEntryContext(getApplication());
loaderEventNotifier.notifyListeners(event);
|
protected void | notifyEjbEvent(int eventType, com.sun.enterprise.deployment.EjbDescriptor desc)
EjbContainerEvent event = new EjbContainerEvent(eventType,
desc, getClassLoader());
generateEntryContext(desc);
loaderEventNotifier.notifyListeners(event);
|
protected void | setCascade(boolean cascade)
this.cascade=cascade;
|
void | setConfigContext(com.sun.enterprise.config.ConfigContext dynamicConfigContext)
this.dynamicConfigContext = dynamicConfigContext;
|
protected void | setLoadUnloadAction(int loadUnloadAction)
this.loadUnloadAction = loadUnloadAction;
|
abstract void | setState(int state)Set state for jsr77 root mBean
The state can be set for a root mBean and it could be
one of STARTING, RUNNING, STOPPING, STOPPED, or FAILED
|
abstract boolean | unload(boolean jsr77)Unloads a deployed application or stand alone module.
If jsr77 is true then corresponding jsr77 mBeans will be deleted
during unload time.
|
protected boolean | unloadEjbs(boolean jsr77)Unloads all the ejb bean containers.
If jsr77 is true then corresponding jsr77 mBeans will be deleted
during unload time.
boolean result = true;
if (this.application == null) {
result = false;
} else {
// undeploy ejb module
Vector beanDescriptors = this.application.getEjbDescriptors();
Enumeration e = beanDescriptors.elements();
while ( e.hasMoreElements() ) {
EjbDescriptor nextDescriptor = (EjbDescriptor) e.nextElement();
notifyEjbEvent(EjbContainerEvent.BEFORE_EJB_CONTAINER_UNLOAD,
nextDescriptor);
// removes the unique id from the registry
this.registry.removeUniqueId( nextDescriptor.getUniqueId() );
try {
// removes the bean container from the application registry
Container container = (Container) this.registry.
removeDescriptor2Container(nextDescriptor);
if (container != null) {
container.undeploy();
}
} catch (Exception beanEx) {
result = false;
_logger.log(Level.WARNING,
"loader.unexpected_error_while_unloading_ejb_container",
beanEx);
}
notifyEjbEvent(EjbContainerEvent.AFTER_EJB_CONTAINER_UNLOAD,
nextDescriptor);
if (jsr77) {
try {
deleteLeafMBean(nextDescriptor);
} catch (MBeanException mbe) {
_logger.log(Level.WARNING,
"loader.delete_ejb_mbean_exception", mbe);
}
}
}
if (!application.isVirtual()) {
// removes the class loader from the application registry
this.registry.removeAppId2ClassLoader(this.id);
} else {
this.registry.removeModuleId2ClassLoader(this.id);
}
// removes the descriptor object from the application registry
this.registry.removeClassLoader2Application(this.ejbClassLoader);
}
_logger.log(Level.FINE,"[AbstractLoader] Unload EJB(s) Status: "
+ result);
return result;
|
protected boolean | unloadPersistenceUnits()Unloads all the EJB 3.0 persistence entities bundled in this application.
try{
new PersistenceUnitLoaderImpl().unload(new ApplicationInfoImpl());
return true;
}catch(Exception ge){
_logger.log(Level.WARNING, ge.getMessage(), ge);
return false;
}
|
protected boolean | unloadRars(boolean jsr77)Unloads all the rar.
If jsr77 is true then corresponding jsr77 mBeans will be deleted
during unload time.
boolean result = true;
// undeploy rar module
try {
Set rarsDescriptors = this.application.getRarDescriptors();
ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
for (Iterator itr = rarsDescriptors.iterator(); itr.hasNext();) {
ConnectorDescriptor cd = (ConnectorDescriptor) itr.next();
String rarName = cd.getDeployName();
String jndiName = this.id+
ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER+
FileUtils.makeFriendlyFilenameNoExtension(rarName);
connectorRuntime.destroyActiveResourceAdapter(jndiName,cascade);
if (jsr77) {
deleteLeafMBean(cd);
}
}
} catch (Exception rarEx) {
result = false;
_logger.log(Level.WARNING,
"loader.application_loader_exception", rarEx);
}
_logger.log(Level.FINE,"[AbstractLoader] Unload RAR(s) Status: "
+ result);
return result;
|
protected boolean | unloadWebserviceEndpoints(boolean jsr77)Unloads all the Web Service Management MBeans.
If jsr77 is true then corresponding jsr77 mBeans will be deleted
during unload time.
boolean result = true;
if (this.application == null) {
result = false;
} else {
// unload web service endpoint
Set bundleSet = new HashSet();
bundleSet.addAll(this.application.getEjbBundleDescriptors());
bundleSet.addAll(this.application.getWebBundleDescriptors());
Iterator itr = bundleSet.iterator();
while ( itr.hasNext() ) {
BundleDescriptor nextDescriptor = (BundleDescriptor) itr.next();
try {
WSMonitorLifeCycleFactory.getInstance().
getWSMonitorLifeCycleProvider().
unregisterWebServiceEndpoints(
this.application.getRegistrationName(), nextDescriptor);
} catch (Exception e) {
_logger.log(Level.WARNING,
"loader.unregister_ws_endpoint_error",
this.application.getRegistrationName());
_logger.log(Level.WARNING,
"loader.register_ws_endpoint_exception", e);
result = false;
}
/*
if (jsr77) {
try {
deleteLeafMBeans(nextDescriptor);
} catch (MBeanException mbe) {
mbe.printStackTrace();
_logger.log(Level.WARNING,
"loader.delete_ejb_mbean_exception", mbe);
}
}
*/
_logger.log(Level.FINE,
"[AbstractLoader] Unload Web Service Endpoint(s) Status: " +
result);
}
}
return result;
|
private boolean | verifyModuleDirectory()
String moduleDirectory;
try {
moduleDirectory = configManager.getLocation(id);
} catch (ConfigException ce) {
_logger.log(Level.WARNING, "loader.configexception", ce);
return false;
}
boolean result = FileUtils.safeIsDirectory(moduleDirectory);
if ( ! result) {
/*
*Log a warning message without a stack trace.
*/
_logger.log(Level.WARNING, "loader.module_dir_error", new Object[] {id, moduleDirectory});
}
return result;
|