|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.glassfish.embeddable.archive.ScatteredArchive
public class ScatteredArchive
Abstraction for a Scattered Java EE module (parts disseminated in various directories).
Usage example :
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish();
glassfish.start();
// Create a scattered web application.
ScatteredArchive archive = new ScatteredArchive("testapp", ScatteredArchive.Type.WAR);
// target/classes directory contains my complied servlets
archive.addClassPath(new File("target", "classes"));
// resources/sun-web.xml is my WEB-INF/sun-web.xml
archive.addMetadata(new File("resources", "sun-web.xml"));
// resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory
archive.addMetadata(new File("resources", "MyLogFactory"),
"META-INF/services/org.apache.commons.logging.LogFactory");
Deployer deployer = glassfish.getDeployer();
// Deploy my scattered web application
deployer.deploy(archive.toURI());
| Nested Class Summary | |
|---|---|
static class |
ScatteredArchive.Type
Enumeration values for the scattered Java EE module types. |
| Constructor Summary | |
|---|---|
ScatteredArchive(String name,
ScatteredArchive.Type type)
Construct a new empty scattered archive. |
|
ScatteredArchive(String name,
ScatteredArchive.Type type,
File rootDirectory)
Construct a new scattered archive with all the contents from the rootDirectory. |
|
| Method Summary | |
|---|---|
void |
addClassPath(File classpath)
Add a directory or a JAR file to this scattered archive. |
void |
addMetadata(File metadata)
Add a new metadata to this scattered archive. |
void |
addMetadata(File metadata,
String name)
Add a new metadata to this scattered archive. |
URI |
toURI()
Get the deployable URI for this scattered archive. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ScatteredArchive(String name,
ScatteredArchive.Type type)
name - name of the archive.type - type of the archive
NullPointerException - if name or type is null
public ScatteredArchive(String name,
ScatteredArchive.Type type,
File rootDirectory)
throws IOException
rootDirectory/WEB-INF/classes/org/myorg/FooServlet.class
rootDirectory/WEB-INF/classes/org/myorg/Bar.class
rootDirectory/WEB-INF/web.xml
rootDirectory/WEB-INF/lib/myjar.jar
rootDirectory/index.jsp
rootDirectory/theme.css
rootDirectory/helper.js
Some files can then be scattered in different locations and be specified
through the appropriate add methods of this class.
name - name of the archive.type - type of the archiverootDirectory - root directory.
NullPointerException - if name, type or rootDirectory is null.
IOException - if rootDirectory does not exist.
IllegalArgumentException - if rootDirectory is not a directory.| Method Detail |
|---|
public void addClassPath(File classpath)
throws IOException
TEMP/abc/org/myorg/a/A.class
TEMP/abc/org/myorg/b/B.class
TEMP/abc/com/xyz/c/C.class
TEMP/abc/LocalStrings.properties
TEMP/abc/image/1.png
then addClassPath(new File("TEMP", "abc") will make:
(a) The following classes available in the deployed scattered archive application:
org.myorg.a.A
org.myorg.b.B
com.xyz.c.C
(b) LocalStrings.properties available in the deployed scattered archive application.
So, the deployed application can do ResourceBundle.getBundle("LocalStrings");
(c) image/1.png available in the deployed scattered archive application.
So, the deployed application can load the image file via getClass().getClassLoader().getResource("image/1.png");
If there is any other type of file under TEMP/abc then it will also be available
in the deployed scattered archive application's classloader.
Case 2: classpath is a JAR file
Let us say there is TEMP/xyz.jar, then addClassPath(new File("TEMP", "xyz.jar"))
will make all the classes and any random files inside TEMP/xyz.jar
available in the deployed scattered archive application.
classpath - A directory or a JAR file.
NullPointerException - if classpath is null
IOException - if the classpath is not found.
public void addMetadata(File metadata)
throws IOException
addMetadata(metadata, null)
Follows the same semantics as addMetadata(File, String) method.
IOException
public void addMetadata(File metadata,
String name)
throws IOException
"WEB-INF/" + metadata.getName() for WAR type archive.
"META-INF/" + metadata.getName() for other type of archive.
If the scattered archive already contains the metadata with the same name,
then the old value is replaced.
metadata - location of the metadataname - name of the metadata (e.g.,
META-INF/ejb.xml or META-INF/sun-ejb-jar.xml)
NullPointerException - if metadata is null
IOException - if metadata does not exist.
IllegalArgumentException - 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, classpath elements, rootDirectory.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||