@Contract public abstract class Archivist<T extends BundleDescriptor> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
annotationProcessingRequested |
protected static String |
APPCLIENT_EXTENSION |
protected static String |
APPLICATION_EXTENSION |
protected ClassLoader |
classLoader |
protected List<ConfigurationDeploymentDescriptorFile> |
confDDFiles |
protected static String |
CONNECTOR_EXTENSION |
protected T |
descriptor |
protected static String |
EJB_EXTENSION |
protected List<ExtensionsArchivist> |
extensionsArchivists |
protected org.glassfish.hk2.api.ServiceLocator |
habitat |
protected boolean |
handleRuntimeInfo |
protected org.glassfish.hk2.api.ServiceLocator |
locator |
protected static Logger |
logger |
protected Manifest |
manifest |
static String |
MANIFEST_VERSION_VALUE |
protected String |
path |
protected DeploymentDescriptorFile<T> |
standardDD |
protected static String |
UPLOAD_EXTENSION |
protected static String |
WEB_EXTENSION |
protected static String |
WEB_FRAGMENT_EXTENSION |
| Constructor and Description |
|---|
Archivist()
Creates new Archivist
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
addFileToArchive(WritableArchive archive,
String filePath,
String entryName)
add a file to an output abstract archive
|
void |
copyAnEntry(ReadableArchive in,
WritableArchive out,
String entryName) |
void |
copyExtraElements(ReadableArchive in,
WritableArchive out) |
void |
copyInto(ReadableArchive source,
WritableArchive target)
Copy source archivist to a target abstract archive.
|
void |
copyInto(ReadableArchive source,
WritableArchive target,
boolean overwriteManifest)
Copy source archivist to a target abstract archive.
|
void |
copyInto(ReadableArchive source,
WritableArchive target,
Vector entriesToSkip)
Copy source archivist to a target abstract archive.
|
void |
copyInto(ReadableArchive source,
WritableArchive target,
Vector entriesToSkip,
boolean overwriteManifest)
Copy this archivist to a new abstract archive
|
void |
copyInto(WritableArchive target)
Copy this archivist to a new abstract archive
|
protected void |
copyJarElements(ReadableArchive in,
WritableArchive out,
Vector ignoreList)
copy all contents of a jar file to a new jar file except
for all the deployment descriptors files
|
void |
copyStandardDeploymentDescriptors(ReadableArchive in,
WritableArchive out) |
ModuleDescriptor |
createModuleDescriptor(T descriptor)
creates a new module descriptor for this archivist
|
Vector |
getAllWebservicesDeploymentDescriptorPaths() |
ErrorHandler |
getAnnotationErrorHandler() |
protected abstract String |
getArchiveExtension() |
ClassLoader |
getClassLoader()
Gets the classloader for this archivist
|
String |
getClassPath() |
abstract List<ConfigurationDeploymentDescriptorFile> |
getConfigurationDDFiles() |
abstract T |
getDefaultBundleDescriptor() |
String |
getDeploymentDescriptorPath() |
T |
getDescriptor() |
List<ExtensionsArchivist> |
getExtensionArchivists() |
Vector |
getLibraries(Archive archive) |
Vector |
getListOfFilesToSkip(ReadableArchive archive) |
Manifest |
getManifest() |
abstract ArchiveType |
getModuleType() |
String |
getPath() |
String |
getRuntimeDeploymentDescriptorPath(ReadableArchive archive) |
boolean |
getRuntimeXMLValidation() |
String |
getRuntimeXMLValidationLevel() |
ModuleScanner |
getScanner()
Returns the scanner for this archivist, usually it is the scanner regitered
with the same module type as this archivist, but subclasses can return a
different version
|
abstract DeploymentDescriptorFile<T> |
getStandardDDFile() |
protected static File |
getTempFile(File fileOrDir)
utility method to get a tmp file in the current user directory of the provided
directory
|
protected static File |
getTempFile(String fileOrDirPath)
utility method to get a tmp file in the current user directory of the provided
directory
|
protected String |
getUniqueEntryFilenameFor(Archive archive,
String trialName) |
boolean |
getXMLValidation() |
String |
getXMLValidationLevel() |
boolean |
handles(ReadableArchive archive)
Returns true if this archivist is capable of handling the archive type
Here we check for the existence of the deployment descriptors
|
boolean |
hasRuntimeDeploymentDescriptor(ReadableArchive archive) |
boolean |
hasStandardDeploymentDescriptor(ReadableArchive archive) |
protected void |
initializeContext(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
|
boolean |
isAnnotationProcessingRequested() |
boolean |
isHandlingRuntimeInfo() |
protected boolean |
isProcessAnnotation(BundleDescriptor descriptor) |
T |
open(File file)
open a new archive file using a file descriptor
|
T |
open(ReadableArchive archive)
Open a new archive file, read the deployment descriptors and annotations * and set the constructed DOL descriptor instance
|
T |
open(ReadableArchive archive,
Application app) |
T |
open(ReadableArchive descriptorArchive,
ReadableArchive contentArchive) |
T |
open(ReadableArchive descriptorArchive,
ReadableArchive contentArchive,
Application app)
Creates the DOL object graph for an app for which the descriptor(s)
reside in one archive and the content resides in another.
|
T |
open(String path)
Open a new archive file, read the XML descriptor and set the constructed
DOL descriptor instance
|
Application |
openWith(Application app,
ReadableArchive archive) |
boolean |
performOptionalPkgDependenciesCheck(ReadableArchive archive)
Perform Optional packages dependencies checking on an archive
|
protected void |
postAnnotationProcess(T descriptor,
ReadableArchive archive)
perform any action after annotation processed
|
protected abstract boolean |
postHandles(ReadableArchive archive)
Returns true if this archivist is capable of handling the archive type
Here we check for the existence of the deployment descriptors
|
protected void |
postOpen(T descriptor,
ReadableArchive archive)
perform any post deployment descriptor reading action
|
void |
postRuntimeDDsRead(T descriptor,
ReadableArchive archive)
perform any action after all runtime DDs read
|
protected void |
postStandardDDsRead(T descriptor,
ReadableArchive archive,
Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions)
perform any action after all standard DDs is read
|
protected void |
postValidate(BundleDescriptor bundleDesc,
ReadableArchive archive) |
void |
printDescriptor()
print the current descriptor associated with this archivist
|
protected ProcessingResult |
processAnnotations(RootDeploymentDescriptor bundleDesc,
ModuleScanner scanner,
ReadableArchive archive)
Process annotations in a bundle descriptor, the annoation processing
is dependent on the type of descriptor being passed.
|
ProcessingResult |
processAnnotations(T bundleDesc,
ReadableArchive archive)
Process annotations in a bundle descriptor, the annoation processing
is dependent on the type of descriptor being passed.
|
protected void |
readAnnotations(ReadableArchive archive,
T descriptor,
Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions)
Read all Java EE annotations
|
protected void |
readAnnotations(ReadableArchive archive,
T descriptor,
Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions,
ModuleScanner scanner) |
Object |
readMetaInfo(ReadableArchive archive) |
void |
readRuntimeDeploymentDescriptor(ReadableArchive archive,
T descriptor)
Read the runtime deployment descriptors (can contained in one or
many file) set the corresponding information in the passed descriptor.
|
void |
readRuntimeDeploymentDescriptor(ReadableArchive archive,
T descriptor,
boolean warnIfMultipleDDs)
Read the runtime deployment descriptors (can contained in one or
many file) set the corresponding information in the passed descriptor.
|
T |
readStandardDeploymentDescriptor(ReadableArchive archive)
Read the standard deployment descriptors (can contained in one or
many file) and return the corresponding initialized descriptor instance.
|
protected boolean |
renameTmp(String from,
String to)
rename a tmp file
|
void |
setAnnotationErrorHandler(ErrorHandler annotationErrorHandler)
sets annotation ErrorHandler for this archivist
|
void |
setAnnotationProcessingRequested(boolean annotationProcessingRequested)
sets if this archivist process annotation
|
void |
setArchiveUri(String path)
Sets the path for this archivist's archive file
|
void |
setClassLoader(ClassLoader classLoader)
Sets the classloader for this archivist
|
void |
setClassPath(String newClassPath)
Sets the class-path for this archive
|
void |
setDescriptor(T descriptor)
Archivist read XML deployment descriptors and keep the
parsed result in the DOL descriptor instances.
|
void |
setExtensionArchivists(List<ExtensionsArchivist> archivists)
Set the applicable extension archivists for this archivist
|
void |
setHandleRuntimeInfo(boolean handleRuntimeInfo)
sets if this archivist saves the runtime info
|
void |
setManifest(Manifest m)
sets the manifest file for this archive
|
void |
setModuleDescriptor(<any> module)
Archivists can be associated with a module descriptor once the
XML deployment descriptors have been read and the DOL tree
is initialized.
|
void |
setRuntimeXMLValidation(boolean validate)
Turn on or off the XML Validation for runtime deployment
descriptors loading
|
void |
setRuntimeXMLValidationLevel(String level)
Sets the runtime xml validation error reporting/recovering level.
|
void |
setXMLValidation(boolean validate)
Turn on or off the XML Validation for all standard deployment
descriptors loading
|
void |
setXMLValidationLevel(String level)
Sets the xml validation error reporting/recovering level.
|
void |
validate(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
|
void |
write() |
void |
write(ReadableArchive in,
String outPath)
save the archive
|
void |
write(ReadableArchive in,
WritableArchive out) |
void |
write(String outPath)
saves the archive
|
protected void |
writeContents(ReadableArchive in,
WritableArchive out)
writes the content of an archive to another archive
|
protected void |
writeContents(ReadableArchive in,
WritableArchive out,
Vector entriesToSkip)
writes the content of an archive to a JarFile
|
protected void |
writeContents(WritableArchive out)
writes the content of an archive to a JarFile
|
void |
writeDeploymentDescriptors(ReadableArchive in,
WritableArchive out)
writes the deployment descriptors (standard and runtime)
to a JarFile using the right deployment descriptor path
|
void |
writeExtensionDeploymentDescriptors(ReadableArchive in,
WritableArchive out)
Write extension descriptors
|
void |
writeRuntimeDeploymentDescriptors(ReadableArchive in,
WritableArchive out)
writes the runtime deployment descriptors to an abstract archive
|
void |
writeStandardDeploymentDescriptors(WritableArchive out)
writes the standard deployment descriptors to an abstract archive
|
protected static final Logger logger
public static final String MANIFEST_VERSION_VALUE
protected String path
protected boolean handleRuntimeInfo
protected boolean annotationProcessingRequested
protected Manifest manifest
protected DeploymentDescriptorFile<T extends BundleDescriptor> standardDD
protected List<ConfigurationDeploymentDescriptorFile> confDDFiles
protected ClassLoader classLoader
protected static final String APPLICATION_EXTENSION
protected static final String APPCLIENT_EXTENSION
protected static final String WEB_EXTENSION
protected static final String WEB_FRAGMENT_EXTENSION
protected static final String EJB_EXTENSION
protected static final String CONNECTOR_EXTENSION
protected static final String UPLOAD_EXTENSION
protected T extends BundleDescriptor descriptor
@Inject protected org.glassfish.hk2.api.ServiceLocator habitat
@Inject protected org.glassfish.hk2.api.ServiceLocator locator
protected List<ExtensionsArchivist> extensionsArchivists
protected void initializeContext(Archivist other)
public void setExtensionArchivists(List<ExtensionsArchivist> archivists)
descriptor - for this archivist instnacepublic List<ExtensionsArchivist> getExtensionArchivists()
public void setDescriptor(T descriptor)
descriptor - for this archivist instnacepublic T getDescriptor()
public T open(ReadableArchive archive) throws IOException, SAXParseException
archive - the archive file pathIOExceptionSAXParseExceptionpublic T open(ReadableArchive descriptorArchive, ReadableArchive contentArchive) throws IOException, SAXParseException
IOExceptionSAXParseExceptionpublic T open(ReadableArchive descriptorArchive, ReadableArchive contentArchive, Application app) throws IOException, SAXParseException
This allows the app client container to use both the generated JAR which contains the descriptors that are filled in during deployment and also the developer's original JAR which contains the classes that might be subject to annotation processing.
descriptorArchive - archive containing the descriptor(s)contentArchive - archive containing the classes, etc.app - owning DOL application (if any)IOExceptionSAXParseExceptionpublic T open(ReadableArchive archive, Application app) throws IOException, SAXParseException
IOExceptionSAXParseExceptionpublic Application openWith(Application app, ReadableArchive archive) throws IOException, SAXParseException
IOExceptionSAXParseExceptionpublic T open(String path) throws IOException, SAXParseException
path - the archive file pathIOExceptionSAXParseExceptionpublic T open(File file) throws IOException, SAXParseException
file - the archive to openIOExceptionSAXParseExceptionprotected void postStandardDDsRead(T descriptor, ReadableArchive archive, Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions) throws IOException
descriptor - the deployment descriptor for the modulearchive - the module archiveextensions - map of extension archivistsIOExceptionprotected void postAnnotationProcess(T descriptor, ReadableArchive archive) throws IOException
descriptor - the deployment descriptor for the modulearchive - the module archiveIOExceptionpublic void postRuntimeDDsRead(T descriptor, ReadableArchive archive) throws IOException
descriptor - the deployment descriptor for the modulearchive - the module archiveIOExceptionprotected void postOpen(T descriptor, ReadableArchive archive) throws IOException
descriptor - the deployment descriptor for the modulearchive - the module archiveIOExceptionprotected void readAnnotations(ReadableArchive archive, T descriptor, Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions) throws IOException
IOExceptionprotected void readAnnotations(ReadableArchive archive, T descriptor, Map<ExtensionsArchivist,RootDeploymentDescriptor> extensions, ModuleScanner scanner) throws IOException
IOExceptionpublic ModuleScanner getScanner()
public ProcessingResult processAnnotations(T bundleDesc, ReadableArchive archive) throws AnnotationProcessorException, IOException
protected ProcessingResult processAnnotations(RootDeploymentDescriptor bundleDesc, ModuleScanner scanner, ReadableArchive archive) throws AnnotationProcessorException, IOException
public T readStandardDeploymentDescriptor(ReadableArchive archive) throws IOException, SAXParseException
IOExceptionSAXParseExceptionpublic void readRuntimeDeploymentDescriptor(ReadableArchive archive, T descriptor) throws IOException, SAXParseException
archive - the archivedescriptor - the initialized deployment descriptorIOExceptionSAXParseExceptionpublic void readRuntimeDeploymentDescriptor(ReadableArchive archive, T descriptor, boolean warnIfMultipleDDs) throws IOException, SAXParseException
archive - the archivedescriptor - the initialized deployment descriptorwarnIfMultipleDDs - whether to log warnings if both the GlassFish and the legacy Sun descriptors are presentIOExceptionSAXParseExceptionpublic void write()
throws IOException
IOExceptionpublic void write(String outPath) throws IOException
outPath - the file to useIOExceptionpublic void write(ReadableArchive in, String outPath) throws IOException
in - archive to copy old elements fromoutPath - the file to useIOExceptionpublic void write(ReadableArchive in, WritableArchive out) throws IOException
IOExceptionprotected void writeContents(WritableArchive out) throws IOException
out - jar output stream to write toIOExceptionprotected void writeContents(ReadableArchive in, WritableArchive out) throws IOException
in - input archiveout - output archiveIOExceptionprotected void writeContents(ReadableArchive in, WritableArchive out, Vector entriesToSkip) throws IOException
in - input archiveout - archive output stream to write toentriesToSkip - files to not write from the original archiveIOExceptionpublic void writeDeploymentDescriptors(ReadableArchive in, WritableArchive out) throws IOException
in - the input archiveout - the abstract archive file to write toIOExceptionpublic void writeStandardDeploymentDescriptors(WritableArchive out) throws IOException
out - archive to write toIOExceptionpublic void writeRuntimeDeploymentDescriptors(ReadableArchive in, WritableArchive out) throws IOException
in - the input archiveout - output archiveIOExceptionpublic void writeExtensionDeploymentDescriptors(ReadableArchive in, WritableArchive out) throws IOException
in - the input archiveout - the output archiveIOExceptionpublic String getDeploymentDescriptorPath()
public String getRuntimeDeploymentDescriptorPath(ReadableArchive archive) throws IOException
IOExceptionpublic void setModuleDescriptor(<any> module)
public boolean performOptionalPkgDependenciesCheck(ReadableArchive archive) throws IOException
IOExceptionpublic abstract ArchiveType getModuleType()
public abstract DeploymentDescriptorFile<T> getStandardDDFile()
public abstract List<ConfigurationDeploymentDescriptorFile> getConfigurationDDFiles()
public abstract T getDefaultBundleDescriptor()
protected abstract String getArchiveExtension()
protected abstract boolean postHandles(ReadableArchive archive) throws IOException
IOExceptionpublic boolean hasStandardDeploymentDescriptor(ReadableArchive archive) throws IOException
IOExceptionpublic boolean hasRuntimeDeploymentDescriptor(ReadableArchive archive) throws IOException
IOExceptionpublic boolean handles(ReadableArchive archive)
archive - the input archivepublic ModuleDescriptor createModuleDescriptor(T descriptor)
public void printDescriptor()
public void setHandleRuntimeInfo(boolean handleRuntimeInfo)
handleRuntimeInfo - to true to save the runtime infopublic boolean isHandlingRuntimeInfo()
public void setAnnotationProcessingRequested(boolean annotationProcessingRequested)
annotationProcessingRequested - to true to process annotationpublic boolean isAnnotationProcessingRequested()
public void setAnnotationErrorHandler(ErrorHandler annotationErrorHandler)
annotationErrorHandler - public ErrorHandler getAnnotationErrorHandler()
public void setManifest(Manifest m)
m - manifest to use at saving timepublic Manifest getManifest()
public void setClassPath(String newClassPath)
newClassPath - the new class-pathpublic String getClassPath()
public Vector getLibraries(Archive archive)
protected String getUniqueEntryFilenameFor(Archive archive, String trialName) throws IOException
IOExceptionprotected static File getTempFile(String fileOrDirPath) throws IOException
fileOrDirPath - path to a file or directory to use as temp location (use parent directory
if a file is provided)IOExceptionpublic Vector getListOfFilesToSkip(ReadableArchive archive) throws IOException
IOExceptionprotected static File getTempFile(File fileOrDir) throws IOException
fileOrDir - file or directory to use as temp location (use parent directory
if a file is provided)IOExceptionprotected static void addFileToArchive(WritableArchive archive, String filePath, String entryName) throws IOException
archive - abstraction to use when adding the filefilePath - to the file to addentryName - the entry name in the archiveIOExceptionprotected void copyJarElements(ReadableArchive in, WritableArchive out, Vector ignoreList) throws IOException
in - jar fileout - jar fileignoreList - vector of entry name to not copy from to source jar fileIOExceptionprotected boolean renameTmp(String from, String to) throws IOException
from - nameto - nameIOExceptionpublic void setArchiveUri(String path)
public String getPath()
public void setClassLoader(ClassLoader classLoader)
classLoader - classLoaderpublic ClassLoader getClassLoader()
public void setXMLValidation(boolean validate)
validate - set to true to turn on XML validationpublic boolean getXMLValidation()
public void setRuntimeXMLValidation(boolean validate)
validate - set to true to turn on XML validationpublic boolean getRuntimeXMLValidation()
public void setXMLValidationLevel(String level)
public String getXMLValidationLevel()
public void setRuntimeXMLValidationLevel(String level)
public String getRuntimeXMLValidationLevel()
public void validate(ClassLoader aClassLoader)
protected void postValidate(BundleDescriptor bundleDesc, ReadableArchive archive)
public void copyInto(WritableArchive target) throws IOException
target - the new archive to use to copy our contents intoIOExceptionpublic void copyInto(ReadableArchive source, WritableArchive target) throws IOException
source - the source archive to copy fromtarget - the target archive to copy toIOExceptionpublic void copyInto(ReadableArchive source, WritableArchive target, boolean overwriteManifest) throws IOException
source - the source archive to copy fromtarget - the target archive to copy tooverwriteManifest - if true, the manifest in source archive
overwrites the one in target archiveIOExceptionpublic void copyInto(ReadableArchive source, WritableArchive target, Vector entriesToSkip) throws IOException
source - the source archive to copy fromtarget - the target archive to copy toentriesToSkip - the entries that will be skipped by target archiveIOExceptionpublic void copyInto(ReadableArchive source, WritableArchive target, Vector entriesToSkip, boolean overwriteManifest) throws IOException
source - the source archive to copy fromtarget - the target archive to copy toentriesToSkip - the entries that will be skipped by target archiveoverwriteManifest - if true, the manifest in source archive
overwrites the one in target archiveIOExceptionpublic void copyAnEntry(ReadableArchive in, WritableArchive out, String entryName) throws IOException
IOExceptionpublic void copyStandardDeploymentDescriptors(ReadableArchive in, WritableArchive out) throws IOException
IOExceptionpublic void copyExtraElements(ReadableArchive in, WritableArchive out) throws IOException
IOExceptionpublic Object readMetaInfo(ReadableArchive archive)
protected boolean isProcessAnnotation(BundleDescriptor descriptor)
public Vector getAllWebservicesDeploymentDescriptorPaths()
Copyright © 2019. All rights reserved.