Methods Summary |
---|
protected static void | addFileToArchive(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, java.lang.String filePath, java.lang.String entryName)add a file to an output abstract archive
FileInputStream is = new FileInputStream(new File(filePath));
OutputStream os = archive.putNextEntry(entryName);
ArchivistUtils.copyWithoutClose(is, os);
is.close();
archive.closeEntry();
|
protected com.sun.enterprise.deployment.util.ModuleDescriptor | addToArchive(ApplicationArchivist appArch, java.lang.String externalDD)Add this archive to an application archivist
AbstractArchive archiveToBeAdded = abstractArchiveFactory.openArchive(path);
File archiveFile = new File(path);
AbstractArchive appArchive = abstractArchiveFactory.openArchive(appArch.getArchiveUri());
String archiveName = getUniqueEntryFilenameFor(appArchive, archiveFile.getName());
appArchive.close();
Descriptor descriptor = null;
if (externalDD != null && !"".equals(externalDD)) {
File externalDescriptorFile = new File(externalDD);
if (externalDescriptorFile.exists()) {
FileInputStream fis = new FileInputStream(externalDescriptorFile);
try {
DeploymentDescriptorFile ddf = getStandardDDFile();
descriptor = ddf.read(fis);
} catch(SAXParseException pe) {
archiveToBeAdded.close();
pe.printStackTrace();
// propagate
throw pe;
}
}
}
if (descriptor==null) {
// We get the deployment descriptors, including maybe the
// runtime deployment descriptors
descriptor = open(archiveToBeAdded);
}
archiveToBeAdded.close();
// Create a new module descriptor for this new module
if (descriptor instanceof BundleDescriptor) {
ModuleDescriptor newModule = new ModuleDescriptor();
newModule.setArchiveUri(archiveName);
newModule.setModuleType(getModuleType());
newModule.setDescriptor((BundleDescriptor) descriptor);
newModule.setManifest(getManifest());
if (externalDD != null && !"".equals(externalDD)) {
newModule.setAlternateDescriptor(externalDD);
}
return newModule;
} else {
return null;
}
|
public void | applyRuntimeInfo(java.io.File runtimeDD, java.io.File output)apply runtimne info to this archive descriptors and saves it
// update the runtime info
getConfigurationDDFile().read(getDescriptor(), new FileInputStream(runtimeDD));
// save the runtime info...
saveRuntimeInfo(output);
|
public boolean | containsRuntimeDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in)
String ddFileName = getRuntimeDeploymentDescriptorPath();
if (ddFileName==null) {
return false;
}
for (Enumeration e = in.entries();e.hasMoreElements();) {
String entryName = (String) e.nextElement();
if (entryName.equals(ddFileName)) {
return true;
}
}
// we iterated all archive elements, could not find our
// runtime DD file, it's a pure j2ee archive
return false;
|
public static void | copyAnEntry(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out, java.lang.String entryName)
InputStream is = null;
InputStream is2 = null;
try {
is = in.getEntry(entryName);
is2 = out.getEntry(entryName);
if (is != null && is2 == null) {
OutputStream os = out.putNextEntry(entryName);
ArchivistUtils.copyWithoutClose(is, os);
}
} finally {
/*
*Close any streams that were opened.
*/
if (is != null) {
is.close();
}
if (is2 != null) {
is2.close();
}
out.closeEntry();
}
|
public static void | copyExtraElements(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
Enumeration entries = in.entries();
if (entries!=null) {
for (;entries.hasMoreElements();) {
String anEntry = (String) entries.nextElement();
if(anEntry.endsWith(PERSISTENCE_DD_ENTRY)) {
// Don't copy persistence.xml file because they are some times
// bundled inside war/WEB-INF/lib/*.jar and hence we always
// read them from exploded directory.
// see Integration Notice #80587
continue;
}
if (anEntry.indexOf(WSDL) != -1 ||
anEntry.indexOf(XML) != -1 ||
anEntry.indexOf(XSD) != -1) {
copyAnEntry(in, out, anEntry);
}
}
}
|
public void | copyInto(com.sun.enterprise.deployment.deploy.shared.AbstractArchive target)Copy this archivist to a new abstract archive
AbstractArchive source = abstractArchiveFactory.openArchive(path);
copyInto(source, target);
|
public void | copyInto(com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target)Copy source archivist to a target abstract archive. By default,
every entry in source archive will be copied to the target archive,
including the manifest of the source archive.
copyInto(source, target, null, true);
|
public void | copyInto(com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target, boolean overwriteManifest)Copy source archivist to a target abstract archive. By default,
every entry in source archive will be copied to the target archive.
copyInto(source, target, null, overwriteManifest);
|
public void | copyInto(com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target, java.util.Vector entriesToSkip)Copy source archivist to a target abstract archive. By default, the manifest
in source archive overwrites the one in target archive.
copyInto(source, target, entriesToSkip, true);
|
public void | copyInto(com.sun.enterprise.deployment.deploy.shared.AbstractArchive source, com.sun.enterprise.deployment.deploy.shared.AbstractArchive target, java.util.Vector entriesToSkip, boolean overwriteManifest)Copy this archivist to a new abstract archive
copyJarElements(source, target, entriesToSkip);
if (overwriteManifest) {
Manifest m = source.getManifest();
if (m != null) {
OutputStream os = target.putNextEntry(JarFile.MANIFEST_NAME);
m.write(os);
target.closeEntry();
}
}
|
protected void | copyJarElements(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out, java.util.Vector ignoreList)copy all contents of a jar file to a new jar file except
for all the deployment descriptors files
Enumeration entries = in.entries();
// we need to add the list of existing entries in the output
// archive to the list of files to ignore to avoid any collision
for (Enumeration outEntriesItr = out.entries();outEntriesItr.hasMoreElements();) {
if (ignoreList==null) {
ignoreList = new Vector();
}
ignoreList.add(outEntriesItr.nextElement());
}
if (entries!=null) {
for (;entries.hasMoreElements();) {
String anEntry = (String) entries.nextElement();
if (ignoreList==null || !ignoreList.contains(anEntry)) {
InputStream is = in.getEntry(anEntry);
OutputStream os = out.putNextEntry(anEntry);
ArchivistUtils.copyWithoutClose(is, os);
is.close();
out.closeEntry();
}
}
}
|
public void | copyStandardDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
String entryName = getDeploymentDescriptorPath();
copyAnEntry(in, out, entryName);
Descriptor desc = getDescriptor();
// only bundle descriptor can have web services
if (desc instanceof BundleDescriptor) {
BundleDescriptor desc2 = (BundleDescriptor)desc;
if (desc2.hasWebServices()) {
DeploymentDescriptorFile webServicesDD =
getWebServicesDDFile((BundleDescriptor)desc2);
String anEntry = webServicesDD.getDeploymentDescriptorPath();
copyAnEntry(in, out, anEntry);
}
}
|
public com.sun.enterprise.deployment.util.ModuleDescriptor | createModuleDescriptor(BundleDescriptor descriptor)creates a new module descriptor for this archivist
ModuleDescriptor newModule = new ModuleDescriptor();
newModule.setModuleType(getModuleType());
newModule.setDescriptor(descriptor);
setDescriptor(descriptor);
return newModule;
|
public void | extractEntry(java.lang.String entryName, java.io.File out)extract a entry of this archive to a file
AbstractArchive archive = abstractArchiveFactory.openArchive(path);
InputStream is = archive.getEntry(entryName);
OutputStream os = new BufferedOutputStream(new FileOutputStream(out));
ArchivistUtils.copy(new BufferedInputStream(is), os);
archive.close();
|
public com.sun.enterprise.deployment.deploy.shared.AbstractArchiveFactory | getAbstractArchiveFactory()
return abstractArchiveFactory;
|
public com.sun.enterprise.deployment.annotation.ErrorHandler | getAnnotationErrorHandler()
return annotationErrorHandler;
|
protected abstract java.lang.String | getArchiveExtension()
|
public java.lang.String | getArchiveUri()
return path;
|
public java.lang.String | getClassPath()
if (manifest==null) {
return null;
}
Attributes atts = manifest.getMainAttributes();
return atts.getValue(Attributes.Name.CLASS_PATH);
|
public abstract DeploymentDescriptorFile | getConfigurationDDFile()
|
public abstract Descriptor | getDefaultBundleDescriptor()
|
public java.lang.String | getDeploymentDescriptorPath()
return getStandardDDFile().getDeploymentDescriptorPath();
|
public abstract Descriptor | getDescriptor()
|
public java.util.Vector | getLibraries(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
Enumeration<String> entries = archive.entries();
if (entries==null)
return null;
Vector libs = new Vector();
while (entries.hasMoreElements()) {
String entryName = entries.nextElement();
if (entryName.indexOf('/")!=-1) {
continue; // not on the top level
}
if (entryName.endsWith(".jar")) {
libs.add(entryName);
}
}
return libs;
|
public java.util.Vector | getListOfFilesToSkip()
Vector filesToSkip = new Vector();
filesToSkip.add(getDeploymentDescriptorPath());
if (manifest!=null) {
filesToSkip.add(JarFile.MANIFEST_NAME);
}
if (getRuntimeDeploymentDescriptorPath()!=null) {
filesToSkip.add(getRuntimeDeploymentDescriptorPath());
}
// Can't depend on having a descriptor, so skip all possible
// web service deployment descriptor paths.
filesToSkip.addAll(WebServicesDeploymentDescriptorFile.
getAllDescriptorPaths());
return filesToSkip;
|
public java.util.jar.Manifest | getManifest()
return manifest;
|
public abstract javax.enterprise.deploy.shared.ModuleType | getModuleType()
|
public PluggableArchivists | getPluggableArchivists()
if (pa==null) {
return ArchivistFactory.getPluggableArchivists();
} else {
return pa;
}
|
public java.lang.String | getRuntimeDeploymentDescriptorPath()
DeploymentDescriptorFile ddFile = getConfigurationDDFile();
if (ddFile!=null) {
return ddFile.getDeploymentDescriptorPath();
} else {
return null;
}
|
public boolean | getRuntimeXMLValidation()
return isValidatingRuntimeXML;
|
public java.lang.String | getRuntimeXMLValidationLevel()
return runtimeValidationLevel;
|
public abstract DeploymentDescriptorFile | getStandardDDFile()
|
protected static java.io.File | getTempFile(java.lang.String fileOrDirPath)utility method to get a tmp file in the current user directory of the provided
directory
if (fileOrDirPath!=null) {
return getTempFile(new File(fileOrDirPath));
} else {
return getTempFile((File) null);
}
|
protected static java.io.File | getTempFile(java.io.File fileOrDir)utility method to get a tmp file in the current user directory of the provided
directory
File dir = null;
if (fileOrDir==null) {
dir=new File(System.getProperty("user.dir"));
} else {
if (!fileOrDir.isDirectory()) {
dir = fileOrDir.getParentFile();
if (dir==null) {
dir=new File(System.getProperty("user.dir"));
}
} else {
dir = fileOrDir;
}
}
return File.createTempFile("tmp", ".jar", dir);
|
protected java.lang.String | getUniqueEntryFilenameFor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, java.lang.String trialName)
Vector entriesNames = new Vector();
Enumeration e = archive.entries();
while (e!=null && e.hasMoreElements()) {
entriesNames.add(e.nextElement());
}
return Descriptor.createUniqueFilenameAmongst(trialName, entriesNames);
|
public DeploymentDescriptorFile | getWebServicesDDFile(Descriptor desc)
return new WebServicesDeploymentDescriptorFile(desc);
|
public java.lang.String | getWebServicesDeploymentDescriptorPath()
return null;
|
public boolean | getXMLValidation()
return isValidatingXML;
|
public java.lang.String | getXMLValidationLevel()
return validationLevel;
|
public boolean | hasRuntimeDeploymentDescriptor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
//check null: since .par archive does not have runtime dds
if (getConfigurationDDFile() != null) {
InputStream runIs = archive.getEntry(
getConfigurationDDFile().getDeploymentDescriptorPath());
if (runIs != null) {
runIs.close();
return true;
}
}
return false;
|
public boolean | hasStandardDeploymentDescriptor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
InputStream stIs = archive.getEntry(getDeploymentDescriptorPath());
if (stIs != null) {
stIs.close();
return true;
}
return false;
|
protected void | initializeContext(com.sun.enterprise.deployment.archivist.Archivist other)initializes this instance from another archivist, this is used
to transfer contextual information between archivists, for
example whether we should handle runtime information and such
handleRuntimeInfo = other.isHandlingRuntimeInfo();
annotationProcessingRequested = other.isAnnotationProcessingRequested();
isValidatingXML = other.isValidatingXML;
validationLevel = other.validationLevel;
abstractArchiveFactory = other.getAbstractArchiveFactory();
classLoader = other.classLoader;
annotationErrorHandler = other.annotationErrorHandler;
|
public boolean | isAnnotationProcessingRequested()
return annotationProcessingRequested;
|
public boolean | isHandlingRuntimeInfo()
return handleRuntimeInfo;
|
public RootDeploymentDescriptor | open(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)Open a new archive file, read the XML descriptor and set the constructed
DOL descriptor instance
setManifest(archive.getManifest());
RootDeploymentDescriptor descriptor = readDeploymentDescriptors(archive);
if (descriptor!=null){
postOpen(descriptor, archive);
}
return descriptor;
|
public RootDeploymentDescriptor | open(java.lang.String path)Open a new archive file, read the XML descriptor and set the constructed
DOL descriptor instance
this.path = path;
File file = new File(path);
if (!file.exists()) {
throw new FileNotFoundException(path);
}
AbstractArchive abstractArchive = abstractArchiveFactory.openArchive(path);
RootDeploymentDescriptor descriptor = open(abstractArchive);
abstractArchive.close();
// attempt validation
validate(null);
return descriptor;
|
public RootDeploymentDescriptor | open(java.io.File file)open a new archive file using a file descriptor
return open(file.getAbsolutePath());
|
public boolean | performOptionalPkgDependenciesCheck(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)Perform Optional packages dependencies checking on an archive
boolean dependenciesSatisfied = true;
Manifest m = archive.getManifest();
if (m!=null) {
dependenciesSatisfied=OptionalPkgDependency.optionalPkgDependencyLogic(m, archive.getArchiveUri());
}
// now check my libraries.
Vector<String> libs = getLibraries(archive);
if (libs!=null) {
for (String libUri : libs) {
JarInputStream jis=null;
try {
jis = new JarInputStream(archive.getEntry(libUri));
m = jis.getManifest();
if (m!=null) {
if (!OptionalPkgDependency.optionalPkgDependencyLogic(m, libUri)) {
dependenciesSatisfied=false;
}
}
} finally {
if (jis!=null)
jis.close();
}
}
}
return dependenciesSatisfied;
|
protected void | postAnnotationProcess(RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)perform any action after annotation processed
|
protected abstract boolean | postHandles(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)
|
protected void | postOpen(RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)perform any post deployment descriptor reading action
|
protected void | postRuntimeDDsRead(RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)perform any action after all runtime DDs read
|
protected void | postStandardDDsRead(RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)perform any action after all standard DDs is read
|
protected void | prepareForInclusion(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)prepare an archivist for inclusion in a application archive.
|
public void | printDescriptor()print the current descriptor associated with this archivist
getDescriptor().visit((DescriptorVisitor) new TracerVisitor());
|
public com.sun.enterprise.deployment.annotation.ProcessingResult | processAnnotations(BundleDescriptor bundleDesc, com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)Process annotations in a bundle descriptor, the annoation processing
is dependent on the type of descriptor being passed.
AnnotatedElementHandler aeHandler =
AnnotatedElementHandlerFactory.createAnnotatedElementHandler(
bundleDesc);
if (aeHandler == null) {
return null;
}
Scanner scanner = ScannerFactory.createScanner(
bundleDesc, this, abstractArchive, classLoader);
if (!scanner.getElements().isEmpty()) {
if (bundleDesc.isDDWithNoAnnotationAllowed()) {
// if we come into this block, it means an old version
// of deployment descriptor has annotation which is not correct
// throw exception in this case
String ddName =
getStandardDDFile().getDeploymentDescriptorPath();
String explodedArchiveName =
new File(abstractArchive.getArchiveUri()).getName();
String archiveName = FileUtils.revertFriendlyFilenameExtension(
explodedArchiveName);
throw new AnnotationProcessorException(
localStrings.getLocalString(
"enterprise.deployment.oldDDwithAnnotation",
"{0} in archive {1} is of version {2}, which cannot support annotations in an application. Please upgrade the deployment descriptor to be a version supported by Java EE 5.0 (or later).",
new Object[] {ddName, archiveName, bundleDesc.getSpecVersion()}));
}
AnnotationProcessor ap = SJSASFactory.getAnnotationProcessor();
ProcessingContext ctx = ap.createContext();
if (annotationErrorHandler != null) {
ctx.setErrorHandler(annotationErrorHandler);
}
ctx.setProcessingInput(scanner);
ctx.pushHandler(aeHandler);
// Make sure there is a classloader available on the descriptor
// during annotation processing.
ClassLoader originalBundleClassLoader = null;
try {
originalBundleClassLoader = bundleDesc.getClassLoader();
} catch(Exception e) {
// getClassLoader can throw exception if not available
}
// Only set classloader if it's not already set.
if( originalBundleClassLoader == null ) {
bundleDesc.setClassLoader(classLoader);
}
try {
return ap.process(ctx);
} finally {
if( originalBundleClassLoader == null ) {
bundleDesc.setClassLoader(null);
}
}
} else {
bundleDesc.setFullFlag(true);
}
return null;
|
protected void | readAnnotations(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive, BundleDescriptor descriptor)
// if the system property is set to process annotation for pre-JavaEE5
// DD, the semantics of isFull flag is: full attribute is set to
// true in DD. Otherwise the semantics is full attribute set to
// true or it is pre-JavaEE5 DD.
boolean isFull = false;
if (processAnnotationForOldDD) {
isFull = descriptor.isFullAttribute();
} else {
isFull = descriptor.isFullFlag();
}
// only process annotation when these two requirements satisfied:
// 1. It is not a full deployment descriptor
// 2. It is called through dynamic deployment
if (!isFull && annotationProcessingRequested
&& classLoader != null) {
try {
ProcessingResult result = processAnnotations(descriptor, abstractArchive);
if (result != null &&
ResultType.FAILED.equals(result.getOverallResult())){
DOLUtils.getDefaultLogger().severe(localStrings.getLocalString(
"enterprise.deployment.archivist.annotationprocessingfailed",
"Annotations processing failed for {0}",
new Object[]{abstractArchive.getArchiveUri()}));
}
//XXX for backward compatible in case of having cci impl in EJB
} catch(NoClassDefFoundError err) {
if (DOLUtils.getDefaultLogger().isLoggable(Level.WARNING)) {
DOLUtils.getDefaultLogger().warning(
"Error in annotation processing: " + err);
}
} catch(AnnotationProcessorException ex) {
DOLUtils.getDefaultLogger().severe(ex.getMessage());
DOLUtils.getDefaultLogger().log(Level.FINE, ex.getMessage(), ex);
throw new IllegalStateException(ex);
}
} else if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
DOLUtils.getDefaultLogger().fine("Annotation is not processed for this archive.");
}
|
public RootDeploymentDescriptor | readDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)Read the standard deployment descriptors (can contained in one or
many file) and return the corresponding initialized descriptor instance.
By default, the standard deployment descriptors are all contained in
the xml file characterized with the path returned by
// read the standard deployment descriptors
BundleDescriptor descriptor = (BundleDescriptor)readStandardDeploymentDescriptor(abstractArchive);
ModuleDescriptor newModule = createModuleDescriptor(descriptor);
newModule.setArchiveUri(abstractArchive.getArchiveUri());
readWebServicesDescriptor(abstractArchive, descriptor);
// Now that we have parsed the standard DD, let's read all the
// PersistenceUnits defined in this archive as well.
readPersistenceDeploymentDescriptors(abstractArchive, getDescriptor());
postStandardDDsRead(descriptor, abstractArchive);
readAnnotations(abstractArchive, descriptor);
postAnnotationProcess(descriptor, abstractArchive);
// now read the runtime deployment descriptors
readRuntimeDeploymentDescriptor(abstractArchive, descriptor);
postRuntimeDDsRead(descriptor, abstractArchive);
return descriptor;
|
protected void | readPersistenceDeploymentDescriptor(com.sun.enterprise.deployment.deploy.shared.Archive subArchive, java.lang.String puRoot, Descriptor descriptor)
final String subArchiveURI = AbstractArchive.class.cast(subArchive).getArchiveUri();
if (logger.isLoggable(Level.FINE)) {
logger.logp(Level.FINE, "Archivist",
"readPersistenceDeploymentDescriptor",
"PURoot = [{0}] subArchive = {1}",
new Object[]{puRoot, subArchiveURI});
}
final RootDeploymentDescriptor rootDD =
RootDeploymentDescriptor.class.cast(descriptor);
if (rootDD.getPersistenceUnitsDescriptor(puRoot) != null) {
if (logger.isLoggable(Level.FINE)) {
logger.logp(Level.FINE, "Archivist",
"readPersistenceDeploymentDescriptor",
"PU has been already read for = {0}",
subArchiveURI);
}
return;
}
PersistenceDeploymentDescriptorFile persistenceDeploymentDescriptorFile
= new PersistenceDeploymentDescriptorFile();
persistenceDeploymentDescriptorFile.setErrorReportingString(
subArchiveURI.toString());
persistenceDeploymentDescriptorFile.setXMLValidation(getXMLValidation());
persistenceDeploymentDescriptorFile.setXMLValidationLevel(
getXMLValidationLevel());
InputStream is = subArchive.getEntry(
persistenceDeploymentDescriptorFile.getDeploymentDescriptorPath());
if (is == null) {
if (logger.isLoggable(Level.FINE)) {
logger.logp(Level.FINE, "Archivist",
"readPersistenceDeploymentDescriptor",
"{0} does not contain {1}, so it is not a PU Root.",
new Object[]{subArchiveURI,
persistenceDeploymentDescriptorFile.getDeploymentDescriptorPath()});
}
return;
}
try {
PersistenceUnitsDescriptor persistenceUnitsDescriptor =
PersistenceUnitsDescriptor.class.cast(
persistenceDeploymentDescriptorFile.read(rootDD, is));
rootDD.addPersistenceUnitsDescriptor(puRoot,
persistenceUnitsDescriptor);
} finally {
is.close();
}
|
public void | readPersistenceDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, Descriptor descriptor)This method is responsible for reading of any persistence DD defined
in the SCOPE of this descriptor. Note, it only reads persistence DD
defined in the current SCOPE.
// This is a no-op implementation as opposed to an abstract method
// because it gets called from ConnectorArchivist.
|
public void | readRuntimeDDFromDeploymentPlan(com.sun.enterprise.deployment.deploy.shared.AbstractArchive planArchive, Descriptor descriptor)Read the runtime deployment descriptors (can contained in one or
many file) from a deployment plan archive, set the corresponding
information in the passed descriptor.
// if we are not supposed to handle runtime info, just pass
String runtimeDDPath = getRuntimeDeploymentDescriptorPath();
if (runtimeDDPath==null || planArchive==null) {
return;
}
// list of entries in the deployment plan
Vector dpEntries = new Vector();
for (Enumeration e = planArchive.entries(); e.hasMoreElements();) {
dpEntries.add(e.nextElement());
}
String entry = runtimeDDPath.substring(runtimeDDPath.lastIndexOf('/")+1);
if (dpEntries.contains(entry)) {
readRuntimeDDFromDeploymentPlan(entry, planArchive, descriptor);
}
|
protected void | readRuntimeDDFromDeploymentPlan(java.lang.String entry, com.sun.enterprise.deployment.deploy.shared.AbstractArchive planArchive, Descriptor descriptor)Read the runtime deployment descriptors (can contained in one or
many file) from a deployment plan archive, set the corresponding
information in the passed descriptor.
InputStream is = null;
try {
is = planArchive.getEntry(entry);
DeploymentDescriptorFile confDD = getConfigurationDDFile();
if (is!=null && confDD!=null) {
if (planArchive.getArchiveUri()!=null) {
confDD.setErrorReportingString(planArchive.getArchiveUri());
}
confDD.setXMLValidation(getXMLValidation());
confDD.read(descriptor, is);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ioe) { }
}
}
|
public void | readRuntimeDeploymentDescriptor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive, Descriptor descriptor)Read the runtime deployment descriptors (can contained in one or
many file) set the corresponding information in the passed descriptor.
By default, the runtime deployment descriptors are all contained in
the xml file characterized with the path returned by
// if we are not supposed to handle runtime info, just pass
String ddFileEntryName = getRuntimeDeploymentDescriptorPath();
if (!isHandlingRuntimeInfo() || ddFileEntryName==null) {
return;
}
InputStream is = null;
try {
// apply the runtime settings if any
is = abstractArchive.getEntry(ddFileEntryName);
DeploymentDescriptorFile confDD = getConfigurationDDFile();
if (abstractArchive.getArchiveUri()!=null) {
confDD.setErrorReportingString(abstractArchive.getArchiveUri());
}
if (is!=null && confDD!=null) {
confDD.setXMLValidation(getRuntimeXMLValidation());
confDD.setXMLValidationLevel(runtimeValidationLevel);
confDD.read(descriptor, is);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ioe) {
}
}
}
|
public Descriptor | readStandardDeploymentDescriptor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)Read the standard deployment descriptors (can contained in one or
many file) and return the corresponding initialized descriptor instance.
By default, the standard deployment descriptors are all contained in
the xml file characterized with the path returned by
InputStream is = null;
try {
is = abstractArchive.getEntry(getStandardDDFile().getDeploymentDescriptorPath());
if (is!=null) {
DeploymentDescriptorFile ddFile = getStandardDDFile();
ddFile.setXMLValidation(getXMLValidation());
ddFile.setXMLValidationLevel(validationLevel);
if (abstractArchive.getArchiveUri()!=null) {
ddFile.setErrorReportingString(abstractArchive.getArchiveUri());
}
Descriptor result = ddFile.read(is);
return result;
} else {
/*
*Always return at least the default, because the info is needed
*when an app is loaded during a server restart and there might not
*be a physical descriptor file.
*/
return getDefaultBundleDescriptor();
}
} finally {
if (is != null) {
is.close();
}
}
|
protected void | readWebServicesDescriptor(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive, Descriptor descriptor)Read the (optional) webservices.xml descriptor in this module.
Only applicable for web and ejb modules.
DeploymentDescriptorFile confDD = getWebServicesDDFile(descriptor);
if (abstractArchive.getArchiveUri()!=null) {
confDD.setErrorReportingString(abstractArchive.getArchiveUri());
}
InputStream is = null;
try {
is = abstractArchive.getEntry(confDD.getDeploymentDescriptorPath());
if (is != null) {
confDD.setXMLValidation(getXMLValidation());
confDD.setXMLValidationLevel(validationLevel);
confDD.read(descriptor, is);
}
} finally {
if (is != null) {
is.close();
}
}
|
protected boolean | renameTmp(java.lang.String from, java.lang.String to)rename a tmp file
AbstractArchive finalArchive = abstractArchiveFactory.openArchive(to);
finalArchive.delete();
AbstractArchive tmpArchive = abstractArchiveFactory.openArchive(from);
boolean success = tmpArchive.renameTo(to);
if (!success) {
throw new IOException("Error renaming JAR");
}
return success;
|
public void | saveRuntimeInfo(java.io.File output)
// if output file is null, we overwrite the current archive...
File outputFile = output;
if (outputFile==null) {
outputFile = getTempFile(path);
}
// copy all entries from source to target except the
// runtime descriptor file
AbstractArchive out = abstractArchiveFactory.createArchive(outputFile.getAbsolutePath());
AbstractArchive in = abstractArchiveFactory.openArchive(path);
Vector skipFiles = new Vector();
skipFiles.add(getRuntimeDeploymentDescriptorPath());
copyInto(in, out, skipFiles);
in.close();
// now save the runtime deployment descriptor...
OutputStream os = out.putNextEntry(getRuntimeDeploymentDescriptorPath());
writeRuntimeDeploymentDescriptors(os);
out.closeEntry();
out.close();
// if we overwrote the old archive, need to rename the tmp now
if (output==null) {
AbstractArchive finalArchive = abstractArchiveFactory.openArchive(path);
finalArchive.delete();
AbstractArchive tmpArchive = abstractArchiveFactory.openArchive(outputFile.getAbsolutePath());
tmpArchive.renameTo(path);
}
|
public void | setAbstractArchiveFactory(com.sun.enterprise.deployment.deploy.shared.AbstractArchiveFactory aa)sets the abstract archive factory associated with this archivist.
abstractArchiveFactory = aa;
|
public void | setAnnotationErrorHandler(com.sun.enterprise.deployment.annotation.ErrorHandler annotationErrorHandler)sets annotation ErrorHandler for this archivist
this.annotationErrorHandler = annotationErrorHandler;
|
public void | setAnnotationProcessingRequested(boolean annotationProcessingRequested)sets if this archivist process annotation
this.annotationProcessingRequested = annotationProcessingRequested;
|
public void | setArchiveUri(java.lang.String path)Sets the path for this archivist's archive file
this.path = path;
|
public void | setClassLoader(java.lang.ClassLoader classLoader)Sets the classloader for this archivist
this.classLoader = classLoader;
|
public void | setClassPath(java.lang.String newClassPath)Sets the class-path for this archive
if (manifest==null) {
manifest = new Manifest();
}
Attributes atts = manifest.getMainAttributes();
atts.putValue(Attributes.Name.CLASS_PATH.toString(), newClassPath);
|
public abstract void | setDescriptor(Descriptor descriptor)Archivist read XML deployment descriptors and keep the
parsed result in the DOL descriptor instances. Sets the descriptor
for a particular Archivist type
|
public void | setHandleRuntimeInfo(boolean handleRuntimeInfo)sets if this archivist saves the runtime info
this.handleRuntimeInfo = handleRuntimeInfo;
|
public void | setManifest(java.util.jar.Manifest m)sets the manifest file for this archive
manifest = m;
|
public void | setModuleDescriptor(com.sun.enterprise.deployment.util.ModuleDescriptor module)Archivists can be associated with a module descriptor once the
XML deployment descriptors have been read and the DOL tree
is initialized.
setDescriptor(module.getDescriptor());
setManifest(module.getManifest());
|
public void | setPluggableArchivists(PluggableArchivists pa)Sets the pluggable archivist factory for this instance
this.pa = pa;
|
public void | setRuntimeXMLValidation(boolean validate)Turn on or off the XML Validation for runtime deployment
descriptors loading
isValidatingRuntimeXML = validate;
|
public void | setRuntimeXMLValidationLevel(java.lang.String level)Sets the runtime xml validation error reporting/recovering level.
The reporting level is active only when xml validation is
turned on @see setXMLValidation.
so far, two values can be passed, medium which reports the
xml validation and continue and full which reports the
xml validation and stop the xml parsing.
runtimeValidationLevel = level;
|
public void | setXMLValidation(boolean validate)Turn on or off the XML Validation for all standard deployment
descriptors loading
isValidatingXML=validate;
|
public void | setXMLValidationLevel(java.lang.String level)Sets the xml validation error reporting/recovering level.
The reporting level is active only when xml validation is
turned on @see setXMLValidation.
so far, two values can be passed, medium which reports the
xml validation and continue and full which reports the
xml validation and stop the xml parsing.
validationLevel = level;
|
public void | validate(java.lang.ClassLoader aClassLoader)validates the DOL Objects associated with this archivist, usually
it requires that a class loader being set on this archivist or passed
as a parameter
|
public void | write()
write(path);
|
public void | write(java.lang.String outPath)saves the archive
AbstractArchive in = abstractArchiveFactory.openArchive(path);
write(in, outPath);
in.close();
|
public void | write(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, java.lang.String outPath)save the archive
AbstractArchive oldArchive=null;
try {
oldArchive = abstractArchiveFactory.openArchive(outPath);
} catch (IOException ioe) {
// there could be many reasons why we cannot open this archive,
// we should continue
}
AbstractArchive out = null;
BufferedOutputStream bos=null;
try {
String tmpName = null;
if (oldArchive!=null && oldArchive.exists() &&
!oldArchive.supportsElementsOverwriting()) {
// this is a rewrite, get a temp file name...
// I am creating a tmp file just to get a name
File outputFile = getTempFile(outPath);
tmpName = outputFile.getAbsolutePath();
outputFile.delete();
out = abstractArchiveFactory.createArchive(tmpName);
oldArchive.close();
} else {
out = abstractArchiveFactory.createArchive(outPath);
}
// write archivist content
writeContents(in, out);
out.close();
in.close();
// if we were using a temp file, time to rewrite the original
if (tmpName!=null) {
AbstractArchive finalArchive = abstractArchiveFactory.openArchive(outPath);
finalArchive.delete();
AbstractArchive tmpArchive = abstractArchiveFactory.openArchive(tmpName);
tmpArchive.renameTo(outPath);
}
} catch (IOException ioe) {
// cleanup
if (out!=null) {
try {
out.close();
//out.delete(); <-- OutputJarArchive.delete isn't supported.
} catch (IOException outIoe) {
// ignore exceptions here, otherwise this will end up masking the real
// IOException in 'ioe'.
}
}
// propagate exception
throw ioe;
}
|
public void | write(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
writeContents(in,out);
|
protected void | writeContents(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)writes the content of an archive to a JarFile
AbstractArchive in = abstractArchiveFactory.openArchive(path);
writeContents(in, out);
in.close();
|
protected void | writeContents(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)writes the content of an archive to a JarFile
writeContents(in, out, null);
|
protected void | writeContents(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out, java.util.Vector entriesToSkip)writes the content of an archive to a JarFile
// Copy original jarFile elements
if (in!=null && in.exists()) {
if (entriesToSkip==null) {
entriesToSkip = getListOfFilesToSkip();
} else {
entriesToSkip.addAll(getListOfFilesToSkip());
}
copyJarElements(in, out, entriesToSkip);
}
// now the deployment descriptors
writeDeploymentDescriptors(out);
// manifest file
if (manifest!=null) {
OutputStream os = out.putNextEntry(JarFile.MANIFEST_NAME);
manifest.write(new DataOutputStream(os));
out.closeEntry();
}
|
public void | writeDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)writes the deployment descriptors (standard and runtime)
to a JarFile using the right deployment descriptor path
// Standard DDs
writeStandardDeploymentDescriptors(out);
// the rest...
writeExtraDeploymentDescriptors(out);
|
protected void | writeExtraDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)write all extra deployment descriptors (like cmp related and runtime dds)
writeRuntimeDeploymentDescriptors(out);
|
public void | writeRuntimeDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)writes the runtime deployment descriptors to an abstract archive
Descriptor desc = getDescriptor();
// Runtime DDs
if (isHandlingRuntimeInfo()) {
DeploymentDescriptorFile confDD = getConfigurationDDFile();
if (confDD!=null) {
OutputStream os = out.putNextEntry(getRuntimeDeploymentDescriptorPath());
confDD.write(desc, os);
out.closeEntry();
}
}
|
public void | writeRuntimeDeploymentDescriptors(java.io.OutputStream os)writes de configuration deployment descriptor to a new XML file
DeploymentDescriptorFile confDD = getConfigurationDDFile();
if (confDD!=null) {
confDD.write(getDescriptor(), os);
}
|
public void | writeStandardDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)writes the standard deployment descriptors to an abstract archive
OutputStream os = out.putNextEntry(getDeploymentDescriptorPath());
writeStandardDeploymentDescriptors(os);
out.closeEntry();
Descriptor desc = getDescriptor();
// only bundle descriptor can have web services
if (desc instanceof BundleDescriptor) {
writeWebServicesDescriptors((BundleDescriptor) desc, out);
}
|
public void | writeStandardDeploymentDescriptors(java.io.OutputStream os)writes the standard deployment descriptor to an output stream
getStandardDDFile().write(getDescriptor(), os);
|
protected void | writeWebServicesDescriptors(BundleDescriptor desc, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
if (desc.hasWebServices()) {
DeploymentDescriptorFile webServicesDD = getWebServicesDDFile(desc);
OutputStream os = out.putNextEntry(webServicesDD.getDeploymentDescriptorPath());
webServicesDD.write(desc, os);
out.closeEntry();
}
|