Class BundleWiringImpl
- java.lang.Object
-
- org.apache.felix.framework.BundleWiringImpl
-
- All Implemented Interfaces:
BundleReference
,BundleWiring
,Wiring
- Direct Known Subclasses:
ExtensionManager.ExtensionManagerWiring
public class BundleWiringImpl extends java.lang.Object implements BundleWiring
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BundleWiringImpl.BundleClassLoader
static class
BundleWiringImpl.BundleClassLoaderJava5
private static class
BundleWiringImpl.ResourceSource
(package private) static class
BundleWiringImpl.ToLocalUrlEnumeration
-
Field Summary
Fields Modifier and Type Field Description static int
EAGER_ACTIVATION
static int
LAZY_ACTIVATION
static int
LISTRESOURCES_DEBUG
private java.lang.ClassLoader
m_bootClassLoader
private BundleWiringImpl.BundleClassLoader
m_classLoader
private java.util.Map
m_configMap
private java.lang.ThreadLocal
m_cycleCheck
private static java.lang.ClassLoader
m_defBootClassLoader
private static java.lang.ThreadLocal
m_deferredActivation
private static java.lang.reflect.Constructor
m_dexFileClassConstructor
private static java.lang.reflect.Method
m_dexFileClassLoadClass
private static java.lang.reflect.Method
m_dexFileClassLoadDex
private java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>>
m_excludedPkgFilters
private java.util.List<Content>
m_fragmentContents
private java.util.List<BundleRevision>
m_fragments
private boolean
m_implicitBootDelegation
private java.util.Map<java.lang.String,BundleRevision>
m_importedPkgs
private java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>>
m_includedPkgFilters
private boolean
m_isDisposed
private static boolean
m_isPreJava5
private java.lang.ThreadLocal
m_listResourcesCycleCheck
private Logger
m_logger
private java.util.Map<java.lang.String,java.util.List<BundleRevision>>
m_requiredPkgs
private java.util.List<BundleCapability>
m_resolvedCaps
private java.util.List<NativeLibrary>
m_resolvedNativeLibs
private java.util.List<BundleRequirement>
m_resolvedReqs
private StatefulResolver
m_resolver
private BundleRevisionImpl
m_revision
private static SecurityManagerEx
m_sm
private boolean
m_useLocalURLs
private java.util.List<BundleWire>
m_wires
private java.util.List<BundleRequirement>
m_wovenReqs
-
Fields inherited from interface org.osgi.framework.wiring.BundleWiring
FINDENTRIES_RECURSE, LISTRESOURCES_LOCAL, LISTRESOURCES_RECURSE
-
-
Constructor Summary
Constructors Constructor Description BundleWiringImpl(Logger logger, java.util.Map configMap, StatefulResolver resolver, BundleRevisionImpl revision, java.util.List<BundleRevision> fragments, java.util.List<BundleWire> wires, java.util.Map<java.lang.String,BundleRevision> importedPkgs, java.util.Map<java.lang.String,java.util.List<BundleRevision>> requiredPkgs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDynamicWire(BundleWire wire)
private static java.util.List<Wire>
asWireList(java.util.List wires)
private java.util.Collection<BundleWiringImpl.ResourceSource>
calculateRemotePackageResources(BundleWire bw, BundleCapability cap, boolean recurse, java.lang.String path, java.util.List<java.lang.String> pattern, java.util.Set<java.lang.String> noMerging)
(package private) static java.net.URL
convertToLocalUrl(java.net.URL url)
private java.net.URL
createURL(int port, java.lang.String path)
private java.lang.ClassLoader
determineParentClassLoader()
private static java.lang.String
diagnoseClassLoadError(StatefulResolver resolver, BundleRevision revision, java.lang.String name)
void
dispose()
private java.lang.Object
doImplicitBootDelegation(java.lang.Class[] classes, java.lang.String name, boolean isClass)
private java.lang.Object
findClassOrResourceByDelegation(java.lang.String name, boolean isClass)
java.util.List<java.net.URL>
findEntries(java.lang.String path, java.lang.String filePattern, int options)
Returns entries in this bundle wiring'sbundle revision
and its attached fragment revisions.private java.util.Enumeration
findResourcesByDelegation(java.lang.String name)
(package private) java.lang.ClassLoader
getBootDelegationClassLoader()
Bundle
getBundle()
Returns theBundle
object associated with thisBundleReference
.java.util.List<BundleCapability>
getCapabilities(java.lang.String namespace)
Returns the capabilities provided by this bundle wiring.java.lang.Class
getClassByDelegation(java.lang.String name)
java.lang.ClassLoader
getClassLoader()
Returns the class loader for this bundle wiring.private java.lang.ClassLoader
getClassLoaderInternal()
(package private) java.util.List<Content>
getFragmentContents()
(package private) java.util.List<BundleRevision>
getFragments()
BundleRevision
getImportedPackageSource(java.lang.String pkgName)
java.util.List<NativeLibrary>
getNativeLibraries()
private static java.lang.String
getPathHead(java.lang.String resource)
java.util.List<Wire>
getProvidedResourceWires(java.lang.String namespace)
Returns theWire
s to the providedcapabilities
of this wiring.java.util.List<BundleWire>
getProvidedWires(java.lang.String namespace)
Returns theBundleWire
s to the providedcapabilities
of this bundle wiring.java.util.List<Wire>
getRequiredResourceWires(java.lang.String namespace)
Returns theWire
s to therequirements
in use by this wiring.java.util.List<BundleWire>
getRequiredWires(java.lang.String namespace)
Returns theBundleWire
s to therequirements
in use by this bundle wiring.java.util.List<BundleRequirement>
getRequirements(java.lang.String namespace)
Returns the requirements of this bundle wiring.BundleRevision
getResource()
Returns the resource associated with this wiring.java.net.URL
getResourceByDelegation(java.lang.String name)
java.util.List<Capability>
getResourceCapabilities(java.lang.String namespace)
Returns the capabilities provided by this wiring.java.util.List<Requirement>
getResourceRequirements(java.lang.String namespace)
Returns the requirements of this wiring.java.util.Enumeration
getResourcesByDelegation(java.lang.String name)
BundleRevision
getRevision()
Returns the bundle revision for the bundle in this bundle wiring.private static java.lang.String
getTrailingPath(java.lang.String resource)
boolean
hasPackageSource(java.lang.String pkgName)
private boolean
isClassExternal(java.lang.Class clazz)
Tries to determine whether the given class is part of the framework or not.private boolean
isClassLoadedFromBundleRevision(java.lang.Class clazz)
boolean
isCurrent()
Returnstrue
if this bundle wiring is the current bundle wiring.private boolean
isFiltered(java.lang.String name)
boolean
isInUse()
Returnstrue
if this bundle wiring is in use.java.util.Collection<java.lang.String>
listResources(java.lang.String path, java.lang.String filePattern, int options)
Returns the names of resources visible to this bundle wiring'sclass loader
.private java.util.Collection<BundleWiringImpl.ResourceSource>
listResourcesInternal(java.lang.String path, java.util.List<java.lang.String> pattern, int options)
private static boolean
matchesPattern(java.util.List<java.lang.String> pattern, java.lang.String resource)
private static java.util.List<java.util.List<java.lang.String>>
parsePkgFilters(BundleCapability cap, java.lang.String filtername)
private java.lang.Object
searchDynamicImports(java.lang.String pkgName, java.lang.String name, boolean isClass)
private java.lang.Object
searchImports(java.lang.String pkgName, java.lang.String name, boolean isClass)
(package private) boolean
shouldBootDelegate(java.lang.String pkgName)
java.lang.String
toString()
-
-
-
Field Detail
-
LISTRESOURCES_DEBUG
public static final int LISTRESOURCES_DEBUG
- See Also:
- Constant Field Values
-
EAGER_ACTIVATION
public static final int EAGER_ACTIVATION
- See Also:
- Constant Field Values
-
LAZY_ACTIVATION
public static final int LAZY_ACTIVATION
- See Also:
- Constant Field Values
-
m_logger
private final Logger m_logger
-
m_configMap
private final java.util.Map m_configMap
-
m_resolver
private final StatefulResolver m_resolver
-
m_revision
private final BundleRevisionImpl m_revision
-
m_fragments
private final java.util.List<BundleRevision> m_fragments
-
m_wires
private volatile java.util.List<BundleWire> m_wires
-
m_importedPkgs
private volatile java.util.Map<java.lang.String,BundleRevision> m_importedPkgs
-
m_requiredPkgs
private final java.util.Map<java.lang.String,java.util.List<BundleRevision>> m_requiredPkgs
-
m_resolvedCaps
private final java.util.List<BundleCapability> m_resolvedCaps
-
m_includedPkgFilters
private final java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> m_includedPkgFilters
-
m_excludedPkgFilters
private final java.util.Map<java.lang.String,java.util.List<java.util.List<java.lang.String>>> m_excludedPkgFilters
-
m_resolvedReqs
private final java.util.List<BundleRequirement> m_resolvedReqs
-
m_resolvedNativeLibs
private final java.util.List<NativeLibrary> m_resolvedNativeLibs
-
m_fragmentContents
private final java.util.List<Content> m_fragmentContents
-
m_wovenReqs
private volatile java.util.List<BundleRequirement> m_wovenReqs
-
m_classLoader
private BundleWiringImpl.BundleClassLoader m_classLoader
-
m_bootClassLoader
private final java.lang.ClassLoader m_bootClassLoader
-
m_defBootClassLoader
private static final java.lang.ClassLoader m_defBootClassLoader
-
m_implicitBootDelegation
private final boolean m_implicitBootDelegation
-
m_useLocalURLs
private final boolean m_useLocalURLs
-
m_sm
private static SecurityManagerEx m_sm
-
m_cycleCheck
private final java.lang.ThreadLocal m_cycleCheck
-
m_deferredActivation
private static final java.lang.ThreadLocal m_deferredActivation
-
m_isPreJava5
private static volatile boolean m_isPreJava5
-
m_isDisposed
private volatile boolean m_isDisposed
-
m_listResourcesCycleCheck
private final java.lang.ThreadLocal m_listResourcesCycleCheck
-
m_dexFileClassConstructor
private static final java.lang.reflect.Constructor m_dexFileClassConstructor
-
m_dexFileClassLoadDex
private static final java.lang.reflect.Method m_dexFileClassLoadDex
-
m_dexFileClassLoadClass
private static final java.lang.reflect.Method m_dexFileClassLoadClass
-
-
Constructor Detail
-
BundleWiringImpl
BundleWiringImpl(Logger logger, java.util.Map configMap, StatefulResolver resolver, BundleRevisionImpl revision, java.util.List<BundleRevision> fragments, java.util.List<BundleWire> wires, java.util.Map<java.lang.String,BundleRevision> importedPkgs, java.util.Map<java.lang.String,java.util.List<BundleRevision>> requiredPkgs) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
parsePkgFilters
private static java.util.List<java.util.List<java.lang.String>> parsePkgFilters(BundleCapability cap, java.lang.String filtername)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
dispose
public void dispose()
-
hasPackageSource
public boolean hasPackageSource(java.lang.String pkgName)
-
getImportedPackageSource
public BundleRevision getImportedPackageSource(java.lang.String pkgName)
-
getFragments
java.util.List<BundleRevision> getFragments()
-
getFragmentContents
java.util.List<Content> getFragmentContents()
-
isCurrent
public boolean isCurrent()
Description copied from interface:BundleWiring
Returnstrue
if this bundle wiring is the current bundle wiring. The bundle wiring for a bundle is the current bundle wiring if it is the most recent bundle wiring for the current bundle revision. All bundles with non-current, in use bundle wirings are consideredremoval pending
.- Specified by:
isCurrent
in interfaceBundleWiring
- Returns:
true
if this bundle wiring is the current bundle wiring;false
otherwise.
-
isInUse
public boolean isInUse()
Description copied from interface:BundleWiring
Returnstrue
if this bundle wiring is in use. A bundle wiring is in use if it is thecurrent
wiring or if some other in use bundle wiring is dependent upon it. Once a bundle wiring is no longer in use, it is considered stale and is discarded by the framework.- Specified by:
isInUse
in interfaceBundleWiring
- Returns:
true
if this bundle wiring is in use;false
otherwise.
-
getResourceCapabilities
public java.util.List<Capability> getResourceCapabilities(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns the capabilities provided by this wiring.Only capabilities considered by the resolver are returned. For example, capabilities with
effective
directive not equal toresolve
are not returned.A capability may not be required by any wiring and thus there may be no
wires
for the capability.A wiring for a non-fragment resource provides a subset of the declared capabilities from the resource and all attached fragment resources†. Not all declared capabilities may be provided since some may be discarded. For example, if a package is declared to be both exported and imported, only one is selected and the other is discarded.
A wiring for a fragment resource with a symbolic name must provide exactly one
osgi.identity
capability.† The
osgi.identity
capability provided by attached fragment resource must not be included in the capabilities of the host wiring.This method returns the same value as
BundleWiring.getCapabilities(String)
.- Specified by:
getResourceCapabilities
in interfaceBundleWiring
- Specified by:
getResourceCapabilities
in interfaceWiring
- Parameters:
namespace
- The namespace of the capabilities to return ornull
to return the capabilities from all namespaces.- Returns:
- A list containing a snapshot of the
Capability
s, or an empty list if this wiring provides no capabilities in the specified namespace. For a given namespace, the list contains the capabilities in the order the capabilities were specified in the manifests of theresource
and the attached fragment resources† of this wiring. There is no ordering defined between capabilities in different namespaces.
-
getCapabilities
public java.util.List<BundleCapability> getCapabilities(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns the capabilities provided by this bundle wiring.Only capabilities considered by the resolver are returned. For example, capabilities with
effective
directive not equal toresolve
are not returned.A capability may not be required by any bundle wiring and thus there may be no
wires
for the capability.A bundle wiring for a non-fragment revision provides a subset of the declared capabilities from the bundle revision and all attached fragment revisions†. Not all declared capabilities may be provided since some may be discarded. For example, if a package is declared to be both exported and imported, only one is selected and the other is discarded.
A bundle wiring for a fragment revision with a symbolic name must provide exactly one
identity
capability.† The
identity
capability provided by attached fragment revisions must not be included in the capabilities of the host bundle wiring.- Specified by:
getCapabilities
in interfaceBundleWiring
- Parameters:
namespace
- The namespace of the capabilities to return ornull
to return the capabilities from all namespaces.- Returns:
- A list containing a snapshot of the
BundleCapability
s, or an empty list if this bundle wiring provides no capabilities in the specified namespace. If this bundle wiring is notin use
,null
will be returned. For a given namespace, the list contains the capabilities in the order the capabilities were specified in the manifests of thebundle revision
and the attached fragments† of this bundle wiring. There is no ordering defined between capabilities in different namespaces.
-
getResourceRequirements
public java.util.List<Requirement> getResourceRequirements(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns the requirements of this wiring.Only requirements considered by the resolver are returned. For example, requirements with
effective
directive not equal toresolve
are not returned.A wiring for a non-fragment resource has a subset of the declared requirements from the resource and all attached fragment resources. Not all declared requirements may be present since some may be discarded. For example, if a package is declared to be optionally imported and is not actually imported, the requirement must be discarded.
This method returns the same value as
BundleWiring.getRequirements(String)
.- Specified by:
getResourceRequirements
in interfaceBundleWiring
- Specified by:
getResourceRequirements
in interfaceWiring
- Parameters:
namespace
- The namespace of the requirements to return ornull
to return the requirements from all namespaces.- Returns:
- A list containing a snapshot of the
Requirement
s, or an empty list if this wiring uses no requirements in the specified namespace. For a given namespace, the list contains the requirements in the order the requirements were specified in the manifests of theresource
and the attached fragment resources of this wiring. There is no ordering defined between requirements in different namespaces.
-
getRequirements
public java.util.List<BundleRequirement> getRequirements(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns the requirements of this bundle wiring.Only requirements considered by the resolver are returned. For example, requirements with
effective
directive not equal toresolve
are not returned.A bundle wiring for a non-fragment revision has a subset of the declared requirements from the bundle revision and all attached fragment revisions. Not all declared requirements may be present since some may be discarded. For example, if a package is declared to be optionally imported and is not actually imported, the requirement must be discarded.
- Specified by:
getRequirements
in interfaceBundleWiring
- Parameters:
namespace
- The namespace of the requirements to return ornull
to return the requirements from all namespaces.- Returns:
- A list containing a snapshot of the
BundleRequirement
s, or an empty list if this bundle wiring uses no requirements in the specified namespace. If this bundle wiring is notin use
,null
will be returned. For a given namespace, the list contains the requirements in the order the requirements were specified in the manifests of thebundle revision
and the attached fragments of this bundle wiring. There is no ordering defined between requirements in different namespaces.
-
getNativeLibraries
public java.util.List<NativeLibrary> getNativeLibraries()
-
asWireList
private static java.util.List<Wire> asWireList(java.util.List wires)
-
getProvidedResourceWires
public java.util.List<Wire> getProvidedResourceWires(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns theWire
s to the providedcapabilities
of this wiring.This method returns the same value as
BundleWiring.getProvidedWires(String)
.- Specified by:
getProvidedResourceWires
in interfaceBundleWiring
- Specified by:
getProvidedResourceWires
in interfaceWiring
- Parameters:
namespace
- The namespace of the capabilities for which to return wires ornull
to return the wires for the capabilities in all namespaces.- Returns:
- A list containing a snapshot of the
Wire
s for thecapabilities
of this wiring, or an empty list if this wiring has no capabilities in the specified namespace. For a given namespace, the list contains the wires in the order the capabilities were specified in the manifests of theresource
and the attached fragment resources of this wiring. There is no ordering defined between capabilities in different namespaces.
-
getProvidedWires
public java.util.List<BundleWire> getProvidedWires(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns theBundleWire
s to the providedcapabilities
of this bundle wiring.- Specified by:
getProvidedWires
in interfaceBundleWiring
- Parameters:
namespace
- The namespace of the capabilities for which to return wires ornull
to return the wires for the capabilities in all namespaces.- Returns:
- A list containing a snapshot of the
BundleWire
s for thecapabilities
of this bundle wiring, or an empty list if this bundle wiring has no capabilities in the specified namespace. If this bundle wiring is notin use
,null
will be returned. For a given namespace, the list contains the wires in the order the capabilities were specified in the manifests of thebundle revision
and the attached fragments of this bundle wiring. There is no ordering defined between capabilities in different namespaces.
-
getRequiredResourceWires
public java.util.List<Wire> getRequiredResourceWires(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns theWire
s to therequirements
in use by this wiring.This method returns the same value as
BundleWiring.getRequiredWires(String)
.- Specified by:
getRequiredResourceWires
in interfaceBundleWiring
- Specified by:
getRequiredResourceWires
in interfaceWiring
- Parameters:
namespace
- The namespace of the requirements for which to return wires ornull
to return the wires for the requirements in all namespaces.- Returns:
- A list containing a snapshot of the
Wire
s for therequirements
of this wiring, or an empty list if this wiring has no requirements in the specified namespace. For a given namespace, the list contains the wires in the order the requirements were specified in the manifests of theresource
and the attached fragment resources of this wiring. There is no ordering defined between requirements in different namespaces.
-
getRequiredWires
public java.util.List<BundleWire> getRequiredWires(java.lang.String namespace)
Description copied from interface:BundleWiring
Returns theBundleWire
s to therequirements
in use by this bundle wiring.This method may return different results if this bundle wiring establishes additional wires to more requirements. For example, dynamically importing a package will establish a new wire to the dynamically imported package.
- Specified by:
getRequiredWires
in interfaceBundleWiring
- Parameters:
namespace
- The namespace of the requirements for which to return wires ornull
to return the wires for the requirements in all namespaces.- Returns:
- A list containing a snapshot of the
BundleWire
s for therequirements
of this bundle wiring, or an empty list if this bundle wiring has no requirements in the specified namespace. If this bundle wiring is notin use
,null
will be returned. For a given namespace, the list contains the wires in the order the requirements were specified in the manifests of thebundle revision
and the attached fragments of this bundle wiring followed by dynamically established wires, if any, in the order they were established. There is no ordering defined between requirements in different namespaces.
-
addDynamicWire
public void addDynamicWire(BundleWire wire)
-
getResource
public BundleRevision getResource()
Description copied from interface:BundleWiring
Returns the resource associated with this wiring.This method returns the same value as
BundleWiring.getRevision()
.- Specified by:
getResource
in interfaceBundleWiring
- Specified by:
getResource
in interfaceWiring
- Returns:
- The resource associated with this wiring.
-
getRevision
public BundleRevision getRevision()
Description copied from interface:BundleWiring
Returns the bundle revision for the bundle in this bundle wiring. Since a bundle update can change the entries in a bundle, different bundle wirings for the same bundle can have different bundle revisions.The bundle object
referenced
by the returnedBundleRevision
may return different information than the returnedBundleRevision
since the returnedBundleRevision
may refer to an older revision of the bundle.- Specified by:
getRevision
in interfaceBundleWiring
- Returns:
- The bundle revision for this bundle wiring.
- See Also:
BundleRevision.getWiring()
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:BundleWiring
Returns the class loader for this bundle wiring. Since a bundle refresh creates a new bundle wiring for a bundle, different bundle wirings for the same bundle will have different class loaders.- Specified by:
getClassLoader
in interfaceBundleWiring
- Returns:
- The class loader for this bundle wiring. If this bundle wiring is
not
in use
or this bundle wiring is for a fragment revision,null
will be returned.
-
getClassLoaderInternal
private java.lang.ClassLoader getClassLoaderInternal()
-
findEntries
public java.util.List<java.net.URL> findEntries(java.lang.String path, java.lang.String filePattern, int options)
Description copied from interface:BundleWiring
Returns entries in this bundle wiring'sbundle revision
and its attached fragment revisions. This bundle wiring's class loader is not used to search for entries. Only the contents of this bundle wiring's bundle revision and its attached fragment revisions are searched for the specified entries.This method takes into account that the "contents" of this bundle wiring can have attached fragments. This "bundle space" is not a namespace with unique members; the same entry name can be present multiple times. This method therefore returns a list of URL objects. These URLs can come from different JARs but have the same path name. This method can either return only entries in the specified path or recurse into subdirectories returning entries in the directory tree beginning at the specified path.
URLs for directory entries must have their path end with "/".
Note: Jar and zip files are not required to include directory entries. URLs to directory entries will not be returned if the bundle contents do not contain directory entries.
- Specified by:
findEntries
in interfaceBundleWiring
- Parameters:
path
- The path name in which to look. The path is always relative to the root of this bundle wiring and may begin with "/". A path value of "/" indicates the root of this bundle wiring.filePattern
- The file name pattern for selecting entries in the specified path. The pattern is only matched against the last element of the entry path. If the entry is a directory then the trailing "/" is not used for pattern matching. Substring matching is supported, as specified in the Filter specification, using the wildcard character ("*"). Ifnull
is specified, this is equivalent to "*" and matches all files.options
- The options for listing resource names. SeeBundleWiring.FINDENTRIES_RECURSE
. The method must ignore unrecognized options.- Returns:
- An unmodifiable list of URL objects for each matching entry, or
an empty list if no matching entry could be found, if this bundle
wiring is for a fragment revision or if the caller does not have
the appropriate
AdminPermission[bundle,RESOURCE]
and the Java Runtime Environment supports permissions. The list is ordered such that entries from thebundle revision
are returned first followed by the entries from attached fragment revisions in attachment order. If this bundle wiring is notin use
,null
must be returned. - See Also:
Bundle.findEntries(String, String, boolean)
-
listResources
public java.util.Collection<java.lang.String> listResources(java.lang.String path, java.lang.String filePattern, int options)
Description copied from interface:BundleWiring
Returns the names of resources visible to this bundle wiring'sclass loader
. The returned names can be used to access the resources via this bundle wiring's class loader.- Only the resource names for resources in bundle wirings will be returned. The names of resources visible to a bundle wiring's parent class loader, such as the bootstrap class loader, must not be included in the result.
- Only established wires will be examined for resources. This method must not cause new wires for dynamic imports to be established.
- Specified by:
listResources
in interfaceBundleWiring
- Parameters:
path
- The path name in which to look. The path is always relative to the root of this bundle wiring's class loader and may begin with "/". A path value of "/" indicates the root of this bundle wiring's class loader.filePattern
- The file name pattern for selecting resource names in the specified path. The pattern is only matched against the last element of the resource path. If the resource is a directory then the trailing "/" is not used for pattern matching. Substring matching is supported, as specified in the Filter specification, using the wildcard character ("*"). Ifnull
is specified, this is equivalent to "*" and matches all files.options
- The options for listing resource names. SeeBundleWiring.LISTRESOURCES_LOCAL
andBundleWiring.LISTRESOURCES_RECURSE
. This method must ignore unrecognized options.- Returns:
- An unmodifiable collection of resource names for each matching
resource, or an empty collection if no matching resource could be
found, if this bundle wiring is for a fragment revision or if the
caller does not have the appropriate
AdminPermission[bundle,RESOURCE]
and the Java Runtime Environment supports permissions. The collection is unordered and must contain no duplicate resource names. If this bundle wiring is notin use
,null
must be returned.
-
listResourcesInternal
private java.util.Collection<BundleWiringImpl.ResourceSource> listResourcesInternal(java.lang.String path, java.util.List<java.lang.String> pattern, int options)
-
calculateRemotePackageResources
private java.util.Collection<BundleWiringImpl.ResourceSource> calculateRemotePackageResources(BundleWire bw, BundleCapability cap, boolean recurse, java.lang.String path, java.util.List<java.lang.String> pattern, java.util.Set<java.lang.String> noMerging)
-
getPathHead
private static java.lang.String getPathHead(java.lang.String resource)
-
getTrailingPath
private static java.lang.String getTrailingPath(java.lang.String resource)
-
matchesPattern
private static boolean matchesPattern(java.util.List<java.lang.String> pattern, java.lang.String resource)
-
getBundle
public Bundle getBundle()
Description copied from interface:BundleReference
Returns theBundle
object associated with thisBundleReference
.- Specified by:
getBundle
in interfaceBundleReference
- Returns:
- The
Bundle
object associated with thisBundleReference
.
-
createURL
private java.net.URL createURL(int port, java.lang.String path)
-
getResourcesByDelegation
public java.util.Enumeration getResourcesByDelegation(java.lang.String name)
-
findResourcesByDelegation
private java.util.Enumeration findResourcesByDelegation(java.lang.String name)
-
determineParentClassLoader
private java.lang.ClassLoader determineParentClassLoader()
-
shouldBootDelegate
boolean shouldBootDelegate(java.lang.String pkgName)
-
getBootDelegationClassLoader
java.lang.ClassLoader getBootDelegationClassLoader()
-
getClassByDelegation
public java.lang.Class getClassByDelegation(java.lang.String name) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
isFiltered
private boolean isFiltered(java.lang.String name)
-
getResourceByDelegation
public java.net.URL getResourceByDelegation(java.lang.String name)
-
findClassOrResourceByDelegation
private java.lang.Object findClassOrResourceByDelegation(java.lang.String name, boolean isClass) throws java.lang.ClassNotFoundException, ResourceNotFoundException
- Throws:
java.lang.ClassNotFoundException
ResourceNotFoundException
-
searchImports
private java.lang.Object searchImports(java.lang.String pkgName, java.lang.String name, boolean isClass) throws java.lang.ClassNotFoundException, ResourceNotFoundException
- Throws:
java.lang.ClassNotFoundException
ResourceNotFoundException
-
searchDynamicImports
private java.lang.Object searchDynamicImports(java.lang.String pkgName, java.lang.String name, boolean isClass) throws java.lang.ClassNotFoundException, ResourceNotFoundException
- Throws:
java.lang.ClassNotFoundException
ResourceNotFoundException
-
doImplicitBootDelegation
private java.lang.Object doImplicitBootDelegation(java.lang.Class[] classes, java.lang.String name, boolean isClass) throws java.lang.ClassNotFoundException, ResourceNotFoundException
- Throws:
java.lang.ClassNotFoundException
ResourceNotFoundException
-
isClassLoadedFromBundleRevision
private boolean isClassLoadedFromBundleRevision(java.lang.Class clazz)
-
isClassExternal
private boolean isClassExternal(java.lang.Class clazz)
Tries to determine whether the given class is part of the framework or not. Framework classes include everything in org.apache.felix.framework.* and org.osgi.framework.*. We also consider ClassLoader and Class to be internal classes, because they are inserted into the stack trace as a result of method overloading. Typically, ClassLoader or Class will be mixed in between framework classes or will be at the point where the class loading request enters the framework class loading mechanism, which will then be followed by either bundle or external code, which will then exit our attempt to determine if we should boot delegate or not. Other standard class loaders, like URLClassLoader, are considered external classes and should trigger boot delegation. This means that bundles can create standard class loaders to get access to boot packages, but this is the standard behavior of class loaders.- Parameters:
clazz
- the class to determine if it is external or not.- Returns:
- true if the class is external, otherwise false.
-
convertToLocalUrl
static java.net.URL convertToLocalUrl(java.net.URL url)
-
diagnoseClassLoadError
private static java.lang.String diagnoseClassLoadError(StatefulResolver resolver, BundleRevision revision, java.lang.String name)
-
-