org.glassfish.osgijavaeebase
Class OSGiBundleArchive

java.lang.Object
  extended by com.sun.enterprise.deploy.shared.AbstractReadableArchive
      extended by org.glassfish.osgijavaeebase.OSGiBundleArchive
All Implemented Interfaces:
java.lang.Iterable<BundleResource>, org.glassfish.api.deployment.archive.Archive, org.glassfish.api.deployment.archive.ReadableArchive, URIable

public class OSGiBundleArchive
extends com.sun.enterprise.deploy.shared.AbstractReadableArchive
implements URIable, java.lang.Iterable<BundleResource>

Adapts a Bundle to Archive. It uses JAR File space of the bundle (via getEntry and getEntryPaths APIs), so a bundle does not have to be in resolved state. Since it represents JAR File space of the bundle, it does not consider resources from any fragments.

Author:
Sanjeeb.Sahoo@Sun.COM

Field Summary
 
Fields inherited from class com.sun.enterprise.deploy.shared.AbstractReadableArchive
extraData, parentArchive
 
Constructor Summary
OSGiBundleArchive(org.osgi.framework.Bundle b)
           
 
Method Summary
 void close()
           
 boolean delete()
           
 java.util.Enumeration<java.lang.String> entries()
           
 java.util.Enumeration<java.lang.String> entries(java.lang.String prefix)
           
 boolean exists()
           
 boolean exists(java.lang.String name)
           
 long getArchiveSize()
           
 java.util.Collection<java.lang.String> getDirectories()
          Returns the enumeration of first level directories in this archive
 java.lang.String getDistanceFromTop()
          When this archive is embedded in another archive, this method returns the distance from top.
 java.io.InputStream getEntry(java.lang.String name)
           
 long getEntrySize(java.lang.String name)
           
 java.net.URI getEntryURI(java.lang.String name)
           
 java.io.InputStream getInputStream()
           
 java.util.jar.Manifest getManifest()
           
 java.lang.String getName()
           
 org.glassfish.api.deployment.archive.ReadableArchive getParentArchive()
           
 org.glassfish.api.deployment.archive.ReadableArchive getSubArchive(java.lang.String name)
           
 java.net.URI getURI()
          It returns URI for the underlying file if it can locate such a file.
 boolean isDirectory(java.lang.String name)
           
 java.util.Iterator<BundleResource> iterator()
           
 void open(java.net.URI uri)
           
 boolean renameTo(java.lang.String name)
           
 void setParentArchive(org.glassfish.api.deployment.archive.ReadableArchive parentArchive)
           
 
Methods inherited from class com.sun.enterprise.deploy.shared.AbstractReadableArchive
getExtraData, removeExtraData, setExtraData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSGiBundleArchive

public OSGiBundleArchive(org.osgi.framework.Bundle b)
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface org.glassfish.api.deployment.archive.Archive
Throws:
java.io.IOException

entries

public java.util.Enumeration<java.lang.String> entries()
Specified by:
entries in interface org.glassfish.api.deployment.archive.Archive

getDirectories

public java.util.Collection<java.lang.String> getDirectories()
                                                      throws java.io.IOException
Returns the enumeration of first level directories in this archive

Specified by:
getDirectories in interface org.glassfish.api.deployment.archive.Archive
Returns:
enumeration of directories under the root of this archive
Throws:
java.io.IOException

entries

public java.util.Enumeration<java.lang.String> entries(java.lang.String prefix)
Specified by:
entries in interface org.glassfish.api.deployment.archive.Archive

isDirectory

public boolean isDirectory(java.lang.String name)
Specified by:
isDirectory in interface org.glassfish.api.deployment.archive.Archive

getManifest

public java.util.jar.Manifest getManifest()
                                   throws java.io.IOException
Specified by:
getManifest in interface org.glassfish.api.deployment.archive.Archive
Throws:
java.io.IOException

getURI

public java.net.URI getURI()
It returns URI for the underlying file if it can locate such a file. Else, it returns null.

Specified by:
getURI in interface org.glassfish.api.deployment.archive.Archive
Returns:

getArchiveSize

public long getArchiveSize()
                    throws java.lang.SecurityException
Specified by:
getArchiveSize in interface org.glassfish.api.deployment.archive.Archive
Throws:
java.lang.SecurityException

getName

public java.lang.String getName()
Specified by:
getName in interface org.glassfish.api.deployment.archive.Archive

getEntry

public java.io.InputStream getEntry(java.lang.String name)
                             throws java.io.IOException
Specified by:
getEntry in interface org.glassfish.api.deployment.archive.ReadableArchive
Throws:
java.io.IOException

exists

public boolean exists(java.lang.String name)
Specified by:
exists in interface org.glassfish.api.deployment.archive.ReadableArchive

getEntrySize

public long getEntrySize(java.lang.String name)
Specified by:
getEntrySize in interface org.glassfish.api.deployment.archive.ReadableArchive

open

public void open(java.net.URI uri)
          throws java.io.IOException
Specified by:
open in interface org.glassfish.api.deployment.archive.ReadableArchive
Throws:
java.io.IOException

getSubArchive

public org.glassfish.api.deployment.archive.ReadableArchive getSubArchive(java.lang.String name)
                                                                   throws java.io.IOException
Specified by:
getSubArchive in interface org.glassfish.api.deployment.archive.ReadableArchive
Throws:
java.io.IOException

exists

public boolean exists()
Specified by:
exists in interface org.glassfish.api.deployment.archive.ReadableArchive

delete

public boolean delete()
Specified by:
delete in interface org.glassfish.api.deployment.archive.ReadableArchive

renameTo

public boolean renameTo(java.lang.String name)
Specified by:
renameTo in interface org.glassfish.api.deployment.archive.ReadableArchive

setParentArchive

public void setParentArchive(org.glassfish.api.deployment.archive.ReadableArchive parentArchive)
Specified by:
setParentArchive in interface org.glassfish.api.deployment.archive.ReadableArchive
Overrides:
setParentArchive in class com.sun.enterprise.deploy.shared.AbstractReadableArchive

getParentArchive

public org.glassfish.api.deployment.archive.ReadableArchive getParentArchive()
Specified by:
getParentArchive in interface org.glassfish.api.deployment.archive.ReadableArchive
Overrides:
getParentArchive in class com.sun.enterprise.deploy.shared.AbstractReadableArchive

getEntryURI

public java.net.URI getEntryURI(java.lang.String name)
Specified by:
getEntryURI in interface URIable
Parameters:
name - the entry name relative to the root of the archive
Returns:
the URI corresponding to the entry, null if no such entry found

getDistanceFromTop

public java.lang.String getDistanceFromTop()
Description copied from interface: URIable
When this archive is embedded in another archive, this method returns the distance from top.

Specified by:
getDistanceFromTop in interface URIable
Returns:

iterator

public java.util.Iterator<BundleResource> iterator()
Specified by:
iterator in interface java.lang.Iterable<BundleResource>

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns:
a Jar format InputStream for this bundle's content
Throws:
java.io.IOException


Copyright © 2011 GlassFish Community. All Rights Reserved.