WebModuleDeployerpublic class WebModuleDeployer extends ModuleDeployer WebModuleDeployer is a class for deploying Web Modules
Much of the code is in the super-class. |
Fields Summary |
---|
private com.sun.enterprise.instance.WebModulesManager | webModulesMgr | private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Methods Summary |
---|
protected com.sun.enterprise.instance.BaseManager | createConfigManager(com.sun.enterprise.instance.InstanceEnvironment ienv, com.sun.enterprise.instance.ModuleEnvironment menv)
webModulesMgr = new WebModulesManager(ienv);
return webModulesMgr;
| protected void | deploy()
// module dir where this module is exploded
String mLocation;
try {
mLocation = moduleDir.getCanonicalPath();
} catch(java.io.IOException e) {
throw new IASDeploymentException(e);
}
// loads the deployment descriptors
Application app = loadDescriptors();
// Set the generated XML directory in application desc
request.getDescriptor().setGeneratedXMLDirectory(xmlDir.getAbsolutePath());
WebBundleDescriptor bundleDesc = (WebBundleDescriptor) app.getStandaloneBundleDescriptor();
// The priority order of how the context root should be used:
// 1. Context root specified by user (via --contextRoot option
// or via gui), i.e. request.getContextRoot()
// 2. Context root specified in sun-web.xml i.e.
// bundleDesc.getContextRoot()
// 3. The default context root (archive name etc) i.e.
// req.getDefaultContextRoot()
if (request.getContextRoot() == null ||
request.getContextRoot().trim().equals("")) {
if (bundleDesc.getContextRoot() != null &&
!bundleDesc.getContextRoot().trim().equals("")) {
request.setContextRoot(bundleDesc.getContextRoot());
} else {
request.setContextRoot(request.getDefaultContextRoot());
}
}
ZipItem[] clientStubs = runEJBC();
try
{
// 4919768 -- please remove this line after October, 2003
// bnevins 9-9-2003
// For some reason, a year ago the check was added to see if there are any
// jsp files by calling: bundleDesc.getJspDescriptors()).isEmpty().
// But it is an unneccessary restriction. Many stock web.xml files do not have
// the magic <jsp-file> tag -- but the web module contains jsp files. In this case
// the isEmpty() will return true and JSP precompilation will not occur until Tomcat
// gets to it later at runtime. The jsp compiler
// in such a case will find them and generate the servlet java files(s).
// So I removed the check. And I tested to make sure everything will work with
// (a) normal web modules where the jsp files are tagged in the xml
// (b) web modules that don't have the tags in web.xml but the module DOES have jsp files
// (c) web modules that have no jsp files
//old code: if(request.getPrecompileJSP() && !(bundleDesc.getJspDescriptors()).isEmpty())
if(request.getPrecompileJSP())
{
long time = System.currentTimeMillis();
JSPCompiler.compile(
moduleDir,
jspDir,
bundleDesc,
request.getCompleteClasspath());
addJSPCTime(System.currentTimeMillis() - time);
}
// runs verifier if verifier option is ON
runVerifier();
}
catch(IASDeploymentException de)
{
throw de;
}
catch(Exception e)
{
throw new IASDeploymentException(e);
}
| protected void | generatePolicy()
// if this is a part of an application then AppDeployerBase will be
// called.
// The rolemapper is not created for standalone web components
// Load the WebArchivist, so that the rolemapper is instantiated.
try{
if(webModulesMgr == null){
webModulesMgr =
(WebModulesManager)createConfigManager(getInstanceEnv(),
moduleEnv);
}
Application app = request.getDescriptor();
WebBundleDescriptor wbd = (WebBundleDescriptor) app.getStandaloneBundleDescriptor();
// other things like creating the WebSecurityManager
WebSecurityManagerFactory wsmf = null;
wsmf = WebSecurityManagerFactory.getInstance();
// this should create all permissions
wsmf.newWebSecurityManager(wbd);
// for an application the securityRoleMapper should already be created.
// I am just creating the web permissions and handing it to the security
// component.
if(request.isApplication()){
return;
}
String name = WebSecurityManager.getContextID(wbd) ;
SecurityUtil.generatePolicyFile(name);
}catch(IASDeploymentException iasde){ // what exception to propagate ahead
// there will be problems in accessing the application
String msg =
localStrings.getString("enterprise.deployment.backend.generate_policy_error" );
logger.log(Level.WARNING, msg, iasde);
throw iasde;
}catch(ConfigException ce){
// there will be problems in accessing the application
String msg =
localStrings.getString("enterprise.deployment.backend.generate_policy_error" );
logger.log(Level.WARNING, msg, ce);
throw new IASDeploymentException(ce.toString());
} catch(IASSecurityException iassec){
// log this
String msg =
localStrings.getString("enterprise.deployment.backend.generate_policy_error" );
logger.log(Level.WARNING, msg, iassec);
throw new IASDeploymentException(msg, iassec);
}
| protected boolean | needsJSPs()
// override this for any module that works with generated JSPs
return true;
| protected boolean | needsStubs()
// override this for webservices stubs/ties
return true;
| protected void | preDeploy()
try
{
assert moduleDir != null;
assert StringUtils.ok(moduleName);
if(request.isArchive())
{
// check if this is a .war file or a single .class file
if (request.getFileSource().getFile().getName().endsWith(".class")) {
// we just need to copy the file to the WEB-INF/lib/classes
File subDir = new File(moduleDir, "WEB-INF");
subDir = new File(subDir, "classes");
copyAutodeployedClassFile(request.getFileSource().getFile(), subDir);
} else {
/*
* Bug 4980750 - Specify the temporary directory into which to explode nested jars.
* This allows web services compilation to avoid including the nested jar file in the
* classpath. Their inclusion there was causing jar files to be opened but never
* closed (as a result of Introspection during web services compilation and, in turn,
* the use of sun.misc.URLClasspath which is where the unbalanced open actually occurs).
* With the nested jar's contents unjarred into this temporary directory, the temp.
* directory can be included in the web services compilation classpath rather than the
* jar file. The open jar file was causing subsequent redeployments of the same
* application to fail because on Windows the open jar file could not be overwritten.
*/
J2EEModuleExploder.explodeJar(request.getFileSource().getFile(), moduleDir);
}
}
xmlDir.mkdirs();
stubsDir.mkdirs();
}
catch(Exception e)
{
throw new IASDeploymentException(e);
}
| public void | removePolicy()
if (request.isApplication()) {
return;
}
WebSecurityManagerFactory wsmf = WebSecurityManagerFactory.getInstance();
String requestName = request.getName();
String[] name
= wsmf.getAndRemoveContextIdForWebAppName(requestName);
try {
if(name != null){
if(name[0] != null)
SecurityUtil.removePolicy(name[0]);
wsmf.removeWebSecurityManager(name[0]);
}
} catch(IASSecurityException ex) {
String msg = localStrings.getString(
"enterprise.deployment.backend.remove_policy_error",name);
logger.log(Level.WARNING, msg, ex);
throw new IASDeploymentException(msg, ex);
}
|
|