Package org.glassfish.embeddable.archive
Class ScatteredEnterpriseArchive
- java.lang.Object
-
- org.glassfish.embeddable.archive.ScatteredEnterpriseArchive
-
public class ScatteredEnterpriseArchive extends Object
Abstraction for a Scattered Java EE Application. Usage example :GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(); glassfish.start(); // Create a scattered web application. ScatteredArchive webmodule = new ScatteredArchive("testweb", ScatteredArchive.Type.WAR); // target/classes directory contains my complied servlets webmodule.addClassPath(new File("target", "classes")); // resources/sun-web.xml is my WEB-INF/sun-web.xml webmodule.addMetadata(new File("resources", "sun-web.xml")); // Create a scattered enterprise archive. ScatteredEnterpriseArchive archive = new ScatteredEnterpriseArchive("testapp"); // src/application.xml is my META-INF/application.xml archive.addMetadata(new File("src", "application.xml")); // Add scattered web module to the scattered enterprise archive. // src/application.xml references Web module as "scattered.war". Hence specify the name while adding the archive. archive.addArchive(webmodule.toURI(), "scattered.war"); // lib/mylibrary.jar is a library JAR file. archive.addArchive(new File("lib", "mylibrary.jar")); // target/ejbclasses contain my compiled EJB module. // src/application.xml references EJB module as "ejb.jar". Hence specify the name while adding the archive. archive.addArchive(new File("target", "ejbclasses"), "ejb.jar"); Deployer deployer = glassfish.getDeployer(); // Deploy my scattered web application deployer.deploy(webmodule.toURI());
- Author:
- [email protected]
-
-
Constructor Summary
Constructors Constructor Description ScatteredEnterpriseArchive(String name)
Construct a new scattered enterprise archive.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArchive(File archive)
Add a module or a library to this scattered enterprise archive.void
addArchive(File archive, String name)
Add a module or a library to this scattered enterprise archive.void
addArchive(URI archiveURI)
Add a module or a library to this scattered enterprise archive.void
addArchive(URI archiveURI, String name)
Add a module or a library to this scattered enterprise archive.void
addMetadata(File metadata)
Add a new metadata to this scattered enterprise archive.void
addMetadata(File metadata, String name)
Add a new metadata to this enterprise archive.URI
toURI()
Get the deployable URI for this scattered enterprise archive.
-
-
-
Constructor Detail
-
ScatteredEnterpriseArchive
public ScatteredEnterpriseArchive(String name)
Construct a new scattered enterprise archive.- Parameters:
name
- Name of the enterprise archive.- Throws:
NullPointerException
- if name is null.
-
-
Method Detail
-
addArchive
public void addArchive(URI archiveURI) throws IOException
Add a module or a library to this scattered enterprise archive. The addArchive(archiveURI) method has the same effect as:addMetadata(archiveURI, null)
Follows the same semantics asaddArchive(URI, String)
method.- Throws:
IOException
-
addArchive
public void addArchive(URI archiveURI, String name) throws IOException
Add a module or a library to this scattered enterprise archive. The specified archiveURI must be one of the following:ScatteredArchive URI obtained via
If the specified name is null, then the name is computed as the name of the File as located by archiveURI.ScatteredArchive.toURI()
. Location of a library JAR file. Must be a File URI. Location of a Java EE module. Must be a File URI.- Parameters:
archiveURI
- Module or library archive URI.name
- name of the module/library as specified in META-INF/application.xml- Throws:
NullPointerException
- if archiveURI is nullIOException
- if the archiveURI location is not found.
-
addArchive
public void addArchive(File archive) throws IOException
Add a module or a library to this scattered enterprise archive. The addArchive(archive) method has the same effect as:addArchive(archive, null)
Follows the same semantics asaddArchive(File, String)
method.- Throws:
IOException
-
addArchive
public void addArchive(File archive, String name) throws IOException
Add a module or a library to this scattered enterprise archive. The specified archive location should be one of the following:Location of a library JAR file. Location of a Java EE module.
If the specified name is null, then the name is computed as archive.getName()- Parameters:
archive
- Location of module or library archive.name
- name of the module/library as specified in META-INF/application.xml- Throws:
NullPointerException
- if archive is nullIOException
- if the archive file is not found
-
addMetadata
public void addMetadata(File metadata) throws IOException
Add a new metadata to this scattered enterprise archive. The addMetadata(metadata) method has the same effect as:addMetadata(metadata, null)
Follows the same semantics asaddMetadata(File, String)
method.- Throws:
IOException
-
addMetadata
public void addMetadata(File metadata, String name) throws IOException
Add a new metadata to this enterprise archive. A metadata is identified by its name (e.g., META-INF/application.xml) If the specified name is null, then the name is computed as "META-INF/" + metadata.getName() If the scattered enterprise archive already contains the metadata with the same name, the old value is replaced.- Parameters:
metadata
- location of metdata.name
- name of the metadata (e.g., META-INF/application.xml)- Throws:
NullPointerException
- if metadata is nullIOException
- if metadata is not foundIllegalArgumentException
- if metadata is a directory.
-
toURI
public URI toURI() throws IOException
Get the deployable URI for this scattered enterprise archive. Note : java.io.tmpdir is used while building the URI.- Returns:
- Deployable scattered enterprise Archive URI.
- Throws:
IOException
- if any I/O error happens while building the URI or while reading metadata, archives.
-
-