Class Archivist<T extends BundleDescriptor>

    • Constructor Detail

      • Archivist

        public Archivist()
        Creates new Archivist
    • Method Detail

      • initializeContext

        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
      • setExtensionArchivists

        public void setExtensionArchivists​(List<ExtensionsArchivist> archivists)
        Set the applicable extension archivists for this archivist
        Parameters:
        descriptor - for this archivist instnace
      • setDescriptor

        public void setDescriptor​(T descriptor)
        Archivist read XML deployment descriptors and keep the parsed result in the DOL descriptor instances. Sets the descriptor for a particular Archivist type
        Parameters:
        descriptor - for this archivist instnace
      • getDescriptor

        public T getDescriptor()
        Returns:
        the Descriptor for this archvist
      • open

        public T open​(ReadableArchive descriptorArchive,
                      ReadableArchive contentArchive,
                      Application app)
               throws IOException,
                      SAXParseException
        Creates the DOL object graph for an app for which the descriptor(s) reside in one archive and the content resides in another.

        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.

        Parameters:
        descriptorArchive - archive containing the descriptor(s)
        contentArchive - archive containing the classes, etc.
        app - owning DOL application (if any)
        Returns:
        DOL object graph for the application
        Throws:
        IOException
        SAXParseException
      • postAnnotationProcess

        protected void postAnnotationProcess​(T descriptor,
                                             ReadableArchive archive)
                                      throws IOException
        perform any action after annotation processed
        Parameters:
        descriptor - the deployment descriptor for the module
        archive - the module archive
        Throws:
        IOException
      • postRuntimeDDsRead

        public void postRuntimeDDsRead​(T descriptor,
                                       ReadableArchive archive)
                                throws IOException
        perform any action after all runtime DDs read
        Parameters:
        descriptor - the deployment descriptor for the module
        archive - the module archive
        Throws:
        IOException
      • postOpen

        protected void postOpen​(T descriptor,
                                ReadableArchive archive)
                         throws IOException
        perform any post deployment descriptor reading action
        Parameters:
        descriptor - the deployment descriptor for the module
        archive - the module archive
        Throws:
        IOException
      • getScanner

        public ModuleScanner getScanner()
        Returns the scanner for this archivist, usually it is the scanner registered with the same module type as this archivist, but subclasses can return a different version
      • readStandardDeploymentDescriptor

        public T readStandardDeploymentDescriptor​(ReadableArchive archive)
                                           throws IOException,
                                                  SAXParseException
        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
        Returns:
        the initialized descriptor
        Throws:
        IOException
        SAXParseException
      • readRuntimeDeploymentDescriptor

        public void readRuntimeDeploymentDescriptor​(ReadableArchive archive,
                                                    T descriptor)
                                             throws IOException,
                                                    SAXParseException
        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
        Parameters:
        archive - the archive
        descriptor - the initialized deployment descriptor
        Throws:
        IOException
        SAXParseException
      • readRuntimeDeploymentDescriptor

        public void readRuntimeDeploymentDescriptor​(ReadableArchive archive,
                                                    T descriptor,
                                                    boolean warnIfMultipleDDs)
                                             throws IOException,
                                                    SAXParseException
        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
        Parameters:
        archive - the archive
        descriptor - the initialized deployment descriptor
        warnIfMultipleDDs - whether to log warnings if both the GlassFish and the legacy Sun descriptors are present
        Throws:
        IOException
        SAXParseException
      • write

        public void write​(String outPath)
                   throws IOException
        saves the archive
        Parameters:
        outPath - the file to use
        Throws:
        IOException
      • writeContents

        protected void writeContents​(WritableArchive out)
                              throws IOException
        writes the content of an archive to a JarFile
        Parameters:
        out - jar output stream to write to
        Throws:
        IOException
      • writeContents

        protected void writeContents​(ReadableArchive in,
                                     WritableArchive out,
                                     Vector entriesToSkip)
                              throws IOException
        writes the content of an archive to a JarFile
        Parameters:
        in - input archive
        out - archive output stream to write to
        entriesToSkip - files to not write from the original archive
        Throws:
        IOException
      • writeDeploymentDescriptors

        public void writeDeploymentDescriptors​(ReadableArchive in,
                                               WritableArchive out)
                                        throws IOException
        writes the deployment descriptors (standard and runtime) to a JarFile using the right deployment descriptor path
        Parameters:
        in - the input archive
        out - the abstract archive file to write to
        Throws:
        IOException
      • writeStandardDeploymentDescriptors

        public void writeStandardDeploymentDescriptors​(WritableArchive out)
                                                throws IOException
        writes the standard deployment descriptors to an abstract archive
        Parameters:
        out - archive to write to
        Throws:
        IOException
      • writeRuntimeDeploymentDescriptors

        public void writeRuntimeDeploymentDescriptors​(ReadableArchive in,
                                                      WritableArchive out)
                                               throws IOException
        writes the runtime deployment descriptors to an abstract archive
        Parameters:
        in - the input archive
        out - output archive
        Throws:
        IOException
      • writeExtensionDeploymentDescriptors

        public void writeExtensionDeploymentDescriptors​(ReadableArchive in,
                                                        WritableArchive out)
                                                 throws IOException
        Write extension descriptors
        Parameters:
        in - the input archive
        out - the output archive
        Throws:
        IOException
      • getDeploymentDescriptorPath

        public String getDeploymentDescriptorPath()
        Returns:
        the location of the DeploymentDescriptor file for a particular type of J2EE Archive
      • getRuntimeDeploymentDescriptorPath

        public String getRuntimeDeploymentDescriptorPath​(ReadableArchive archive)
                                                  throws IOException
        Returns:
        the location of the runtime deployment descriptor file for a particular type of J2EE Archive
        Throws:
        IOException
      • setModuleDescriptor

        public void setModuleDescriptor​(ModuleDescriptor<T> module)
        Archivists can be associated with a module descriptor once the XML deployment descriptors have been read and the DOL tree is initialized.
      • performOptionalPkgDependenciesCheck

        public boolean performOptionalPkgDependenciesCheck​(ReadableArchive archive)
                                                    throws IOException
        Perform Optional packages dependencies checking on an archive
        Throws:
        IOException
      • getModuleType

        public abstract ArchiveType getModuleType()
        Returns:
        the module type handled by this archivist as defined in the application DTD/Schema
      • getStandardDDFile

        public abstract DeploymentDescriptorFile<T> getStandardDDFile()
        Returns:
        the DeploymentDescriptorFile responsible for handling standard deployment descriptor
      • getConfigurationDDFiles

        public abstract List<ConfigurationDeploymentDescriptorFile> getConfigurationDDFiles()
        Returns:
        the list of the DeploymentDescriptorFile responsible for handling the configuration deployment descriptors
      • getDefaultBundleDescriptor

        public abstract T getDefaultBundleDescriptor()
        Returns:
        a default BundleDescriptor for this archivist
      • getArchiveExtension

        protected abstract String getArchiveExtension()
        Returns:
        The archive extension handled by a specific archivist
      • postHandles

        protected abstract boolean postHandles​(ReadableArchive archive)
                                        throws IOException
        Returns true if this archivist is capable of handling the archive type Here we check for the existence of the deployment descriptors
        Returns:
        true if the archivist is handling the provided archive
        Throws:
        IOException
      • handles

        public 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
        Parameters:
        archive - the input archive
        Returns:
        true if this archivist can handle this archive
      • createModuleDescriptor

        public ModuleDescriptor createModuleDescriptor​(T descriptor)
        creates a new module descriptor for this archivist
        Returns:
        the new module descriptor
      • printDescriptor

        public void printDescriptor()
        print the current descriptor associated with this archivist
      • setHandleRuntimeInfo

        public void setHandleRuntimeInfo​(boolean handleRuntimeInfo)
        sets if this archivist saves the runtime info
        Parameters:
        handleRuntimeInfo - to true to save the runtime info
      • isHandlingRuntimeInfo

        public boolean isHandlingRuntimeInfo()
        Returns:
        true if this archivist will save the runtime info
      • setAnnotationProcessingRequested

        public void setAnnotationProcessingRequested​(boolean annotationProcessingRequested)
        sets if this archivist process annotation
        Parameters:
        annotationProcessingRequested - to true to process annotation
      • isAnnotationProcessingRequested

        public boolean isAnnotationProcessingRequested()
        Returns:
        true if this archivist will process annotation
      • setAnnotationErrorHandler

        public void setAnnotationErrorHandler​(ErrorHandler annotationErrorHandler)
        sets annotation ErrorHandler for this archivist
        Parameters:
        annotationErrorHandler -
      • getAnnotationErrorHandler

        public ErrorHandler getAnnotationErrorHandler()
        Returns:
        annotation ErrorHandler of this archivist
      • setManifest

        public void setManifest​(Manifest m)
        sets the manifest file for this archive
        Parameters:
        m - manifest to use at saving time
      • getManifest

        public Manifest getManifest()
        Returns:
        the manifest file for this archive
      • setClassPath

        public void setClassPath​(String newClassPath)
        Sets the class-path for this archive
        Parameters:
        newClassPath - the new class-path
      • getClassPath

        public String getClassPath()
        Returns:
        the class-path as set in the manifest associated with the archive
      • getLibraries

        public Vector getLibraries​(Archive archive)
        Returns:
        a list of libraries included in the archivist
      • getTempFile

        protected static File getTempFile​(String fileOrDirPath)
                                   throws IOException
        utility method to get a tmp file in the current user directory of the provided directory
        Parameters:
        fileOrDirPath - path to a file or directory to use as temp location (use parent directory if a file is provided)
        Throws:
        IOException
      • getListOfFilesToSkip

        public Vector getListOfFilesToSkip​(ReadableArchive archive)
                                    throws IOException
        Returns:
        the list of files that should not be copied from the old archive when a save is performed.
        Throws:
        IOException
      • getTempFile

        protected static File getTempFile​(File fileOrDir)
                                   throws IOException
        Utility method to get a tmp file in the current user directory of the provided directory
        Parameters:
        fileOrDir - file or directory to use as temp location (use parent directory if a file is provided)
        Throws:
        IOException
      • addFileToArchive

        protected static void addFileToArchive​(WritableArchive archive,
                                               String filePath,
                                               String entryName)
                                        throws IOException
        add a file to an output abstract archive
        Parameters:
        archive - abstraction to use when adding the file
        filePath - to the file to add
        entryName - the entry name in the archive
        Throws:
        IOException
      • copyJarElements

        protected void copyJarElements​(ReadableArchive in,
                                       WritableArchive out,
                                       Vector ignoreList)
                                throws IOException
        copy all contents of a jar file to a new jar file except for all the deployment descriptors files
        Parameters:
        in - jar file
        out - jar file
        ignoreList - vector of entry name to not copy from to source jar file
        Throws:
        IOException
      • setArchiveUri

        public void setArchiveUri​(String path)
        Sets the path for this archivist's archive file
      • getPath

        public String getPath()
        Returns:
        the path for this archivist's archive file
      • setClassLoader

        public void setClassLoader​(ClassLoader classLoader)
        Sets the classloader for this archivist
        Parameters:
        classLoader - classLoader
      • getClassLoader

        public ClassLoader getClassLoader()
        Gets the classloader for this archivist
        Returns:
        classLoader
      • setXMLValidation

        public void setXMLValidation​(boolean validate)
        Turn on or off the XML Validation for all standard deployment descriptors loading
        Parameters:
        validate - set to true to turn on XML validation
      • getXMLValidation

        public boolean getXMLValidation()
        Returns:
        true if the Deployment Descriptors XML will be validated while reading.
      • setRuntimeXMLValidation

        public void setRuntimeXMLValidation​(boolean validate)
        Turn on or off the XML Validation for runtime deployment descriptors loading
        Parameters:
        validate - set to true to turn on XML validation
      • getRuntimeXMLValidation

        public boolean getRuntimeXMLValidation()
        Returns:
        true if the runtime XML will be validated while reading.
      • setXMLValidationLevel

        public void setXMLValidationLevel​(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.
      • getXMLValidationLevel

        public String getXMLValidationLevel()
        Returns:
        the xml validation reporting level
      • setRuntimeXMLValidationLevel

        public void setRuntimeXMLValidationLevel​(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.
      • getRuntimeXMLValidationLevel

        public String getRuntimeXMLValidationLevel()
        Returns:
        the runtime xml validation reporting level
      • validate

        public 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
      • copyInto

        public void copyInto​(WritableArchive target)
                      throws IOException
        Copy this archivist to a new abstract archive
        Parameters:
        target - the new archive to use to copy our contents into
        Throws:
        IOException
      • copyInto

        public void copyInto​(ReadableArchive source,
                             WritableArchive target)
                      throws IOException
        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.
        Parameters:
        source - the source archive to copy from
        target - the target archive to copy to
        Throws:
        IOException
      • copyInto

        public void copyInto​(ReadableArchive source,
                             WritableArchive target,
                             boolean overwriteManifest)
                      throws IOException
        Copy source archivist to a target abstract archive. By default, every entry in source archive will be copied to the target archive.
        Parameters:
        source - the source archive to copy from
        target - the target archive to copy to
        overwriteManifest - if true, the manifest in source archive overwrites the one in target archive
        Throws:
        IOException
      • copyInto

        public void copyInto​(ReadableArchive source,
                             WritableArchive target,
                             Vector entriesToSkip)
                      throws IOException
        Copy source archivist to a target abstract archive. By default, the manifest in source archive overwrites the one in target archive.
        Parameters:
        source - the source archive to copy from
        target - the target archive to copy to
        entriesToSkip - the entries that will be skipped by target archive
        Throws:
        IOException
      • copyInto

        public void copyInto​(ReadableArchive source,
                             WritableArchive target,
                             Vector entriesToSkip,
                             boolean overwriteManifest)
                      throws IOException
        Copy this archivist to a new abstract archive
        Parameters:
        source - the source archive to copy from
        target - the target archive to copy to
        entriesToSkip - the entries that will be skipped by target archive
        overwriteManifest - if true, the manifest in source archive overwrites the one in target archive
        Throws:
        IOException
      • isProcessAnnotation

        protected boolean isProcessAnnotation​(BundleDescriptor descriptor)
      • getAllWebservicesDeploymentDescriptorPaths

        public Vector getAllWebservicesDeploymentDescriptorPaths()