/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* Abstraction for a scattered archive (parts disseminated in various directories)
*
* @author Jerome Dochez
*/
public static class Builder {
/**
* Construct a new scattered archive builder with the minimum information
* By default, a scattered archive is not different from any other
* archive where all the files are located under a top level
* directory (topDir).
* Some files can then be scattered in different locations and be specified
* through the appropriate setters.
* Alternatively, topDir can be null to specify a truely scattered archive
* and all the locations must be specified.
*
* @param name archive name
* @param topDir top level directory
*/
}
/**
* Construct a new scattered archive builder with a set of URLs as repository
* for locating archive resources (like .class files).
* @param name archive name
* @param urls set of resources repository
*/
}
}
/**
* Sets the location of resources files
*
* @param resources the resources directory
* @return itself
*/
}
return this;
}
/**
* Add a new metadata locator for this scattered archive. A metadata is identified
* the embedded server is requesting the metadata file.
* The name for this metadata will be obtained by doing metadata.getName()
*
* @param metadata the metadata file location
*
* @return itself
*/
}
}
/**
* Add a new metadata locator for this scattered archive. A metadata is identified
* the embedded server is requesting the metadata file.
*
* or ejb.xml).
*
* @param metadata the metadata file location
*
* @return itself
*/
}
return this;
}
/**
* Adds a directory to the classes classpath. Will be used to retrieve requested .class
* files.
*
* @param location must be a directory location
* @return itself
*/
if (!location.isDirectory()) {
throw new IllegalArgumentException("location is not a directory");
}
try {
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
return this;
}
/**
* Adds a URL for the classes classpath. Will be used to retrieve requested .class files
*
* @param classpath the new classpath element.
* @return itself
*/
return this;
}
/**
* Creates a new scattered jar file using this builder instance configuration.
* The resulting instance will behave like a jar file when introspected by the
* embedded instance.
*
* @return new scattered instance jar file
*/
}
/**
* Creates a new scattered war file using this builder instance configuration.
* The resulting instance will behave like a war file when introspected by the
* embedded instance.
*
* @return the scattered instance war file
*/
}
/**
* Supported types of scattered archives.
*/
public enum type {
}
}
try {
} catch (MalformedURLException ignore) {
}
}
}
// todo : look at Open(URI), is it ok ?
/**
* Get the classpath URLs
*
* @return A read-only copy of the classpath URL Collection
*/
}
/**
* @return The resources directory
*/
return resources;
}
/**
* Returns the InputStream for the given entry name
* The file name must be relative to the root of the module.
*
* @param arg the file name relative to the root of the module.
* @return the InputStream for the given entry name or null if not found.
*/
}
}
return null;
}
}
}
return 0L;
}
/**
* Returns whether or not a file by that name exists
* The file name must be relative to the root of the module.
*
* @param name the file name relative to the root of the module.
* @return does the file exist?
*/
return true;
}
}
/**
* Returns an enumeration of the module file entries. All elements
* in the enumeration are of type String. Each String represents a
* file name relative to the root of the module.
* <p><strong>Currently under construction</strong>
*
* @return an enumeration of the archive file entries.
*/
// TODO: abstraction breakage. We need file-level abstraction for archive
// and then more structured abstraction.
try {
}
File f;
try {
} catch(URISyntaxException e) {
}
if (f.isFile()) {
while (jarEntries.hasMoreElements()) {
if (jarEntry.isDirectory()) {
continue;
}
}
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (localResources!=null) {
}
}
if (!directory.isDirectory())
return;
if (f.isDirectory()) {
} else {
}
}
}
/**
* Returns the manifest information for this archive
*
* @return the manifest info
*/
try {
} finally {
}
}
return new Manifest();
}
/**
* Returns the path used to create or open the underlying archive
* <p/>
* <p/>
* TODO: abstraction breakage:
* Several callers, most notably {@link org.glassfish.api.deployment.DeploymentContext#getSourceDir()}
* implementation, assumes that this URI is an URL, and in fact file URL.
* <p/>
* <p/>
* If this needs to be URL, use of {@link URI} is misleading. And furthermore,
* if its needs to be a file URL, this should be {@link File}.
*
* @return the path for this archive.
*/
}
}
try {
//TODO : Fix this
if (f.isFile())
}
}
return null;
} catch (Exception e) {
return null;
}
}
/**
* Returns the name of the archive.
* <p/>
* Implementations should not return null.
*
* @return the name of the archive
*/
return name;
}
/**
* Returns the archive type
* @return the archive type
*/
return type;
}
/**
* Returns an enumeration of the module file entries with the
* specified prefix. All elements in the enumeration are of
* type String. Each String represents a file name relative
* to the root of the module.
* <p><strong>Currently Not Supported</strong>
*
* @param s the prefix of entries to be included
* @return an enumeration of the archive file entries.
*/
while (entries.hasMoreElements()) {
if (entry.startsWith(s))
}
return prefixedEntries.elements();
}
}
}
}
}
if (f.exists()) {
return f;
}
}
}
}
try {
} catch(URISyntaxException e) {
}
if (f.exists()) {
return f;
}
}
return null;
}
try {
} catch(URISyntaxException e) {
}
try {
return jar;
}
}
return null;
}
}
return null;
}
}
}