Methods Summary |
---|
protected void | DeleteOrKeepFailedStubs(java.io.File stubsDir)This is a backdoor designed for QA and support staff.
If the magical environmental variable, "KeepFailedStubs",
is set to "true", then this method returns true.
It results in the generated stubs files being retained and
place into the expected directory with "_failed" appended to the name. The
Directory will be deleted and replaced the next time there
is a failed deployment. It will never be automatically cleaned up.
Note: KeepFailedStubs and true are both case insensitive.
This method will do the following, if the flag is set:
delete already existing _fail directory, if any
rename the given stubsdir to xxx_failed
If the flag is not set, it will wipeout the stubsDir recursively.
//4704059 - backdoor for analyzing stubs
if(!FileUtils.safeIsDirectory(stubsDir))
return; // not an error
if(keepFailedStubsValue)
{
File failedStubsDir = new File(stubsDir.getPath() + FAILED_SUFFIX);
// blow-away any already existing failed dir
FileUtils.whack(failedStubsDir);
stubsDir.renameTo(failedStubsDir);
logger.info(Constants.KEEP_FAILED_STUBS + " is set. Backdoor is open. Saving failed generated ejb files in: " + failedStubsDir.getPath());
}
else
{
FileUtils.whack(stubsDir);
}
|
protected void | addEJBCTime(com.sun.ejb.codegen.IASEJBCTimes ejbcT)
ejbcTime += ejbcT.getTotalTime();
ejbcTiming = ejbcT;
|
protected void | addJSPCTime(long time)
jspcTime += time;
|
protected void | addToSummary(java.lang.String s)
summary.append(s);
summary.append("\n");
|
protected void | begin()
// start profiling...
timeDeployStarted = System.currentTimeMillis();
try
{
instanceEnv.verify();
}
catch(Exception e)
{
throw new IASDeploymentException(e);
}
|
protected boolean | checkAppclientsMainClasses()Makes sure each app client specifies Main-Class in its manifest.
Logs warnings for any client that fails to do so.
/*
*Use the ModuleDescriptors from getModules to obtain the URIs for
*use in the warning if needed.
*/
boolean result = true;
StringBuilder sb = new StringBuilder();
for (Iterator it = request.getDescriptor().getModules(); it != null && it.hasNext(); ) {
ModuleDescriptor md = (ModuleDescriptor) it.next();
if (md.getModuleType() == ModuleType.CAR) {
String archiveURI = md.getArchiveUri();
ApplicationClientDescriptor acd = (ApplicationClientDescriptor) md.getDescriptor();
String mainClassName = acd.getMainClassName();
if (mainClassName == null || mainClassName.length() == 0) {
result = false;
logger.log(Level.WARNING, localStrings.getString("enterprise.deployment.backend.no_main_class"), archiveURI);
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(archiveURI);
}
}
}
if ( ! result) {
/*
*At least one app client failed to identify its main class. Add a
*deployment sub-status warning of the problem.
*/
DeploymentStatus mainClassesNotOKStatus = new DeploymentStatus(request.getCurrentDeploymentStatus());
mainClassesNotOKStatus.setStageDescription(localStrings.getString("enterprise.deployment.backend.appclient_mainclass_checking"));
mainClassesNotOKStatus.setStageStatus(DeploymentStatus.WARNING);
mainClassesNotOKStatus.setStageStatusMessage(localStrings.getString("enterprise.deployment.backend.appclient_mainclass_checking_failed", sb.toString()));
}
return result;
|
void | checkRegisteredAnywhereElse(java.lang.String id)
String error = BaseManager.isRegisteredAnywhere(instanceEnv, id);
if(error != null)
{
String msg = localStrings.getString("enterprise.deployment.backend.nameAlreadyExists", new Object[] { id, error});
throw new IASDeploymentException(msg);
}
|
protected void | cleanAndCheck(java.io.File dir)Cleans out a directory, logging a warning
(such as deployment, undeployment, etc.) if the directory
remains.
if(FileUtils.safeIsDirectory(dir)) {
FileUtils.whack(dir, undeletedFiles);
}
|
public final void | cleanup()
///////////////////////////////////////////////////////////////////////////
///////// Abstract Methods ///////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////// Public Methods ///////
///////////////////////////////////////////////////////////////////////////
cleanup_internal();
|
public abstract void | cleanup_internal()
|
protected void | copyAutodeployedClassFile(java.io.File srcFile, java.io.File destDir)
File autodeployDir = srcFile.getParentFile();
String packageNameDirs="";
while (!autodeployDir.getName().equals(AutoDeployConstants.DEFAULT_AUTODEPLOY_DIR)) {
packageNameDirs=autodeployDir.getName()+ File.separator + packageNameDirs;
autodeployDir = autodeployDir.getParentFile();
}
destDir = new File(destDir, packageNameDirs);
File destFile = new File(destDir, srcFile.getName());
FileUtils.copy(request.getFileSource().getFile(), destFile);
|
protected final void | createClientJar(com.sun.enterprise.util.zip.ZipItem[] clientStubs)
Properties props = request.getOptionalArguments();
String clientJarRequested = props.getProperty(DeploymentProperties.CLIENTJARREQUESTED);
// destination file for the client jar file
File appDirectory = request.getGeneratedXMLDirectory();
// for upgrade scenario, we fall back to original directory
if (appDirectory == null ||
!FileUtils.safeIsDirectory(appDirectory)) {
appDirectory = request.getDeployedDirectory();
}
File clientJar = new File(appDirectory, request.getName()
+ DeploymentImplConstants.ClientJarSuffix);
// now we look if the client jar file is being requested by the client
// tool
if (clientJarRequested!=null &&
Boolean.valueOf(clientJarRequested).booleanValue()) {
// the client jar file is requested upon deployment,
// we need to build synchronously
ClientJarMakerThread.createClientJar(
request, clientJar, clientStubs, CLIENT_JAR_MAKER_CHOICE);
// sets the newly created client jar in the deployment request
request.setClientJar(clientJar);
} else {
// the client jar file is not requester, we build it asynchronously.
Thread clientJarThread = new ClientJarMakerThread(
request, clientJar, clientStubs, CLIENT_JAR_MAKER_CHOICE);
clientJarThread.start();
// done !
}
|
private final void | deleteLockFile()
if(lockFile != null)
lockFile.delete();
|
public abstract void | doRequest()
|
public abstract void | doRequestFinish()
|
public abstract void | doRequestPrepare()
|
protected final void | finish()
long total = System.currentTimeMillis() - timeDeployStarted;
if(total <= 0)
total = 1;
int percentEJBC = (int)(((double)ejbcTime) / ((double)total) * 100.0);
int percentJSPC = (int)(((double)jspcTime) / ((double)total) * 100.0);
deleteLockFile();
StringBuffer timing = new StringBuffer("Total Deployment Time: ");
timing.append(total);
timing.append(" msec, ");
if(jspcTime > 0)
{
timing.append("Total JSP Compile Time: ");
timing.append(jspcTime);
timing.append(" msec (").append(percentJSPC).append("%), ");
}
timing.append("Total EJB Compiler Module Time: ");
timing.append(ejbcTime);
timing.append(" msec, Portion spent EJB Compiling: ");
timing.append(percentEJBC);
timing.append("%");
if(ejbcTiming != null)
timing.append("\nBreakdown of EJBC Module Time: " + ejbcTiming);
logger.fine(timing.toString());
logger.finer(toString());
// helps garbage collection
releaseClassLoader();
|
protected void | generatePolicy()
String s = DeploymentUtils.getSystemPropertyIgnoreCase(Constants.KEEP_FAILED_STUBS);
if(s != null && s.compareToIgnoreCase("true") == 0)
keepFailedStubsValue = true;
else
keepFailedStubsValue = false;
//Reminder.message("KeepFailedStubs is: " + keepFailedStubsValue);
// Each subtype of deployer, overrides this
|
protected final com.sun.enterprise.instance.InstanceEnvironment | getInstanceEnv()
return instanceEnv;
|
public static final boolean | getKeepFailedStubsValue()
return keepFailedStubsValue;
|
protected abstract com.sun.enterprise.instance.BaseManager | getManager()
|
protected abstract java.util.List | getModuleClasspath(com.sun.enterprise.deployment.archivist.Archivist archivist, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
|
protected final DeploymentRequest | getRequest()
return request;
|
protected java.lang.String | getResourceType(java.io.File appDir)
FileInputStream fis = null;
try{
File manifestFile = new File(appDir, JarFile.MANIFEST_NAME);
fis = new FileInputStream(manifestFile);
Manifest manifest = new Manifest(fis);
Attributes attrs = manifest.getMainAttributes();
return attrs.getValue(Constants.APPLICATION_TYPE);
}catch(Throwable t){
// by default resource-type will be assigned "user". Need just return null;
return null;
} finally {
try {
if (fis != null) {
fis.close();
}
} catch (IOException ioe) {
}
}
|
public static java.lang.String | getValidationLevel()
init();
return validationLevel;
|
protected void | handleUndeletedFiles()
// all files have been deleted and nothing needs to be done
if (undeletedFiles.size() == 0) {
return;
}
// log a fine message for all undeleted files for debug purpose
String allUndeletedFilesMsg = localStrings.getString("enterprise.deployment.backend.all_undeleted_files", FileUtils.formatFileCollection(undeletedFiles));
logger.fine(allUndeletedFilesMsg);
for (Iterator<File> files = undeletedFiles.iterator(); files.hasNext();) {
File file = files.next();
if (file.lastModified() > liquidateTimeStamp ) {
files.remove();
}
}
if (undeletedFiles.size() > 0) {
// Try to delete the left-over files using gc (on Windows).
// In any case, mark files that still remain for delete-on-exit.
if ( ! FileUtils.deleteLeftoverFiles(undeletedFiles) ) {
String untouchedUndeletedFilesMsg = localStrings.getString("enterprise.deployment.backend.untouched_undeleted_files", FileUtils.formatFileCollection(undeletedFiles));
DeploymentStatus handleUndeletedFilesStatus =
new DeploymentStatus(request.getCurrentDeploymentStatus());
handleUndeletedFilesStatus.setStageStatus(
DeploymentStatus.WARNING);
handleUndeletedFilesStatus.setStageStatusMessage(
untouchedUndeletedFilesMsg);
// also logged in the server.log for autodeploy
logger.warning(untouchedUndeletedFilesMsg);
}
}
|
private static void | init()Perform class level initialization. I do not want to put it
in the static initializer since the config beans I am accessing
may have not been initialized properly when the class loader
invokes the static initializer.
// already initialized
if (validationLevel!=null) {
return;
}
try {
ConfigContext ctx = ApplicationServer.getServerContext().getConfigContext();
DasConfig dc = ServerBeansFactory.getDasConfigBean(ctx);
validationLevel = dc.getDeployXmlValidation();
} catch(ConfigException ce) {
IASDeploymentException e = new IASDeploymentException(
localStrings.getString(
"enterprise.deployment.backend.cannot_get_validationlevel",
ce.getMessage() ));
e.initCause(ce);
throw e;
}
|
protected final boolean | isArchive()
return request.isArchive();
|
protected final boolean | isDirectory()
return request.isDirectory();
|
protected boolean | isExternallyManagedApp(java.io.File appDir)
File file = new File(appDir, FLAG_FILE);
return file.exists();
|
protected com.sun.enterprise.deployment.Application | loadDescriptors()
// we will need this later
BaseManager manager = getManager();
if (manager==null) {
throw new IASDeploymentException(
localStrings.getString(
"enterprise.deployment.backend.no_manager_registered",
request.getType() ));
}
// look if we should validate the deployment descriptors
init();
boolean validateXml = true;
try {
Archivist archivist = ArchivistFactory.getArchivistForType(request.getType().getModuleType());
archivist.setAnnotationProcessingRequested(true);
String appDir = request.getDeployedDirectory().getAbsolutePath();
FileArchive in = new FileArchive();
in.open(appDir);
if (request.isVerifying()) {
archivist.setRuntimeXMLValidation(true);
archivist.setRuntimeXMLValidationLevel("full");
}
if (validationLevel.equals("none")) {
archivist.setXMLValidation(false);
} else {
archivist.setXMLValidation(true);
archivist.setXMLValidationLevel(validationLevel);
}
//Note in copying of deployment plan to the portable archive,
//we should make sure the manifest in the deployment plan jar
//file does not overwrite the one in the original archive
//NOTE. We are not checking the size of the deploymentPlan file
//here, since it looks like on windows the size of this tmp
//file is always zero when we attempt to query its size.
//Instead, we are making sure the 0 length deployment plan is
//not uploaded in DeploymentFacility implementation.
if (request.getDeploymentPlan() != null) {
DeploymentPlanArchive dpa = new DeploymentPlanArchive();
dpa.open(request.getDeploymentPlan().getAbsolutePath());
if (request.isApplication()) {
ApplicationArchivist aa = (ApplicationArchivist)archivist;
aa.copyInto(request.getDescriptor(), dpa, in, false);
} else {
archivist.copyInto(dpa, in, false);
}
}
// now let's create a class loader for this module
// parent class loader (from admin server)
ClassLoader parent =
(Boolean.getBoolean(com.sun.enterprise.server.PELaunch.USE_NEW_CLASSLOADER_PROPERTY))
? com.sun.enterprise.server.PELaunch.getAppServerChain()
: ClassLoader.getSystemClassLoader();
// sets the parent class loader and class paths in deployment req
DeploymentUtils.setParentClassLoader(parent, getManager(), request);
// parent class paths for this deployment request
List allClassPaths = request.getParentClasspath();
// parent class loader for this deployment request
ClassLoader sharedClassLoader = request.getParentClassLoader();
List moduleClasspath = getModuleClasspath(archivist, in);
request.setModuleClasspath(moduleClasspath);
allClassPaths.addAll(moduleClasspath);
final ClassLoader ejbClassLoader = DeploymentUtils.getClassLoader(
moduleClasspath, sharedClassLoader, null);
// sets the ejb class loader & class paths - used during jspc
request.setEjbClassLoader(ejbClassLoader);
request.setCompleteClasspath(allClassPaths);
// set classloader used for annotation processing
archivist.setClassLoader(ejbClassLoader);
// set the context classloader to ejbClassLoader for DD
// processing
ClassLoader origContextClassLoader =
Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(ejbClassLoader);
Application application = request.getDescriptor();
if (application!=null && ModuleType.EAR.equals(archivist.getModuleType())) {
archivist.readPersistenceDeploymentDescriptors(in, application);
// Now process standard DDs, do this before runtime DDs
archivist.setHandleRuntimeInfo(false);
boolean modulesReadSuccess = ((ApplicationArchivist) archivist).readModulesDescriptors(application, in);
if (modulesReadSuccess) {
// now process runtime DDs
archivist.setHandleRuntimeInfo(true);
archivist.readRuntimeDeploymentDescriptor(in, application);
} else {
// it failed reading sub modules, I null our application which will trigger
// deployment failure handling
application=null;
}
} else {
application = ApplicationArchivist.openArchive(archivist, in, true);
}
if (application==null) {
throw new IASDeploymentException(localStrings.getString(
"enterprise.deployment.backend.error_loading_dds",
new Object[] { request.getName(), " " }));
}
application.setRegistrationName(request.getName());
application.setClassLoader(ejbClassLoader);
archivist.setDescriptor(application);
// let's check for optional dependencies
if (!archivist.performOptionalPkgDependenciesCheck(in)) {
throw new IASDeploymentException(localStrings.getString("enterprise.deployment.backend.archive_opt_dep_not_satisfied", new Object[] {in.getArchiveUri()}));
}
archivist.validate(ejbClassLoader);
if (!application.getWebServiceDescriptors().isEmpty()) {
ModuleContentLinker visitor = new ModuleContentLinker(in);
application.visit((com.sun.enterprise.deployment.util.ApplicationVisitor) visitor);
}
request.setDescriptor(application);
// restore the original context class loader
Thread.currentThread().setContextClassLoader(
origContextClassLoader);
return application;
} catch(SAXParseException spe) {
IASDeploymentException e = new IASDeploymentException(
localStrings.getString(
"enterprise.deployment.backend.saxerror_loading_dds",
request.getName(),String.valueOf(spe.getLineNumber()),
String.valueOf(spe.getColumnNumber()), spe.getLocalizedMessage() ));
e.initCause(spe);
throw e;
} catch(IASDeploymentException e) {
throw e;
} catch (Throwable t) {
IASDeploymentException e = new IASDeploymentException(
localStrings.getString(
"enterprise.deployment.backend.error_loading_dds",
request.getName(), t.getMessage() ));
e.initCause(t);
throw e;
}
|
public final void | releaseClassLoader()
try
{
// releases the parent class loader
ClassLoader parentCL = request.getParentClassLoader();
if ( (parentCL != null) && (parentCL instanceof EJBClassLoader) )
{
((EJBClassLoader) parentCL).done();
}
// releases the ejb class loader
ClassLoader ejbCL = request.getEjbClassLoader();
if ( (ejbCL != null) && (ejbCL instanceof EJBClassLoader) )
{
((EJBClassLoader) ejbCL).done();
}
}
catch (Exception e)
{
// ignore
}
|
public abstract void | removePolicy()
|
public java.lang.String | toString()
return summary.toString();
|