public class ScatteredEnterpriseArchive extends Object
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());
| Constructor and Description |
|---|
ScatteredEnterpriseArchive(String name)
Construct a new scattered enterprise archive.
|
| Modifier and Type | Method and 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.
|
public ScatteredEnterpriseArchive(String name)
name - Name of the enterprise archive.NullPointerException - if name is null.public void addArchive(URI archiveURI) throws IOException
addMetadata(archiveURI, null)
Follows the same semantics as addArchive(URI, String) method.IOExceptionpublic void addArchive(URI archiveURI, String name) throws IOException
ScatteredArchive URI obtained via ScatteredArchive.toURI().
Location of a library JAR file. Must be a File URI.
Location of a Java EE module. Must be a File URI.
If the specified name is null, then the name is computed as the name of the
File as located by archiveURI.archiveURI - Module or library archive URI.name - name of the module/library as specified in META-INF/application.xmlNullPointerException - if archiveURI is nullIOException - if the archiveURI location is not found.public void addArchive(File archive) throws IOException
addArchive(archive, null)
Follows the same semantics as addArchive(File, String) method.IOExceptionpublic void addArchive(File archive, String name) throws IOException
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()archive - Location of module or library archive.name - name of the module/library as specified in META-INF/application.xmlNullPointerException - if archive is nullIOException - if the archive file is not foundpublic void addMetadata(File metadata) throws IOException
addMetadata(metadata, null)
Follows the same semantics as addMetadata(File, String) method.IOExceptionpublic void addMetadata(File metadata, String name) throws IOException
metadata - location of metdata.name - name of the metadata (e.g., META-INF/application.xml)NullPointerException - if metadata is nullIOException - if metadata is not foundIllegalArgumentException - if metadata is a directory.public URI toURI() throws IOException
IOException - if any I/O error happens while building the URI
or while reading metadata, archives.Copyright © 2013. All Rights Reserved.