class ExtensionManager extends java.net.URLStreamHandler implements Content
First, a private instance is added (as URL with the instance as URLStreamHandler) to the classloader that loaded the class. It is assumed that this is an instance of URLClassloader (if not extension bundles will not work). Subsequently, extension bundles can be managed by instances of this class (their will be one instance per framework instance).
Second, it is used as module definition of the systembundle. Added extension bundles with exported packages will contribute their exports to the systembundle export.
Third, it is used as content loader of the systembundle. Added extension bundles exports will be available via this loader.
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
ExtensionManager.ExtensionManagerRevision |
(package private) class |
ExtensionManager.ExtensionManagerWiring |
private static class |
ExtensionManager.ExtensionTuple |
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<BundleCapability> |
m_capabilities |
private java.util.Map |
m_configMap |
private java.util.Set<java.lang.String> |
m_exportNames |
(package private) static ExtensionManager |
m_extensionManager |
private java.util.List |
m_extensions |
private Bundle[] |
m_extensionsCache |
private java.util.List<ExtensionManager.ExtensionTuple> |
m_extensionTuples |
private java.util.Map |
m_headerMap |
private Logger |
m_logger |
private java.util.Set |
m_names |
private java.lang.Object |
m_securityContext |
private java.util.Map |
m_sourceToExtensions |
private BundleRevisionImpl |
m_systemBundleRevision |
| Modifier | Constructor and Description |
|---|---|
private |
ExtensionManager() |
(package private) |
ExtensionManager(Logger logger,
java.util.Map configMap,
Felix felix)
This constructor is used to create one instance per framework instance.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
_add(java.lang.String name,
Bundle extension) |
private void |
_removeExtensions(java.lang.Object source) |
private void |
addExtension(java.lang.Object source,
Bundle extension) |
(package private) void |
addExtensionBundle(Felix felix,
BundleImpl bundle)
Add an extension bundle.
|
private static java.util.List<BundleCapability> |
aliasSymbolicName(java.util.List<BundleCapability> caps) |
private void |
appendCapabilities(java.util.List<BundleCapability> caps) |
protected BundleCapability |
buildNativeCapabilites() |
void |
close()
This method must be called when the content is no longer needed so
that any resourses being used (e.g., open files) can be closed.
|
private java.lang.String |
convertCapabilitiesToHeaders(java.util.Map headers) |
private java.util.List<BundleCapability> |
getCapabilities(java.lang.String namespace) |
java.util.Enumeration |
getEntries()
Returns an enumeration of entry names as String objects.
|
byte[] |
getEntryAsBytes(java.lang.String name)
This method returns the named entry as an array of bytes.
|
Content |
getEntryAsContent(java.lang.String name)
This method returns the named entry as an IContent Typically,
this method only makes sense for entries that correspond to some form
of aggregated resource (e.g., an embedded JAR file or directory), but
implementations are free to interpret this however makes sense.
|
java.lang.String |
getEntryAsNativeLibrary(java.lang.String name)
This method returns the named entry as a file in the file system for
use as a native library.
|
java.io.InputStream |
getEntryAsStream(java.lang.String name)
This method returns the named entry as an input stream.
|
java.net.URL |
getEntryAsURL(java.lang.String name)
This method allows retrieving an entry as a local URL.
|
protected java.net.InetAddress |
getHostAddress(java.net.URL u) |
BundleRevisionImpl |
getRevision() |
java.lang.Object |
getSecurityContext() |
boolean |
hasEntry(java.lang.String name)
This method determines if the specified named entry is contained in
the associated content.
|
java.net.URLConnection |
openConnection(java.net.URL url) |
(package private) void |
removeExtensions(Felix felix)
Remove all extension registered by the given framework instance.
|
void |
setSecurityContext(java.lang.Object securityContext) |
(package private) void |
startExtensionBundle(Felix felix,
BundleImpl bundle)
This is a Felix specific extension mechanism that allows extension bundles
to have activators and be started via this method.
|
(package private) void |
startPendingExtensionBundles(Felix felix) |
(package private) void |
stopExtensionBundles(Felix felix) |
static final ExtensionManager m_extensionManager
private final Logger m_logger
private final java.util.Map m_configMap
private final java.util.Map m_headerMap
private final BundleRevisionImpl m_systemBundleRevision
private volatile java.util.List<BundleCapability> m_capabilities
private volatile java.util.Set<java.lang.String> m_exportNames
private volatile java.lang.Object m_securityContext
private final java.util.List m_extensions
private volatile Bundle[] m_extensionsCache
private final java.util.Set m_names
private final java.util.Map m_sourceToExtensions
private final java.util.List<ExtensionManager.ExtensionTuple> m_extensionTuples
private ExtensionManager()
ExtensionManager(Logger logger, java.util.Map configMap, Felix felix)
logger - the logger to use.config - the configuration to read properties from.systemBundleInfo - the info to change if we need to add exports.protected BundleCapability buildNativeCapabilites()
private static java.util.List<BundleCapability> aliasSymbolicName(java.util.List<BundleCapability> caps)
public BundleRevisionImpl getRevision()
public java.lang.Object getSecurityContext()
public void setSecurityContext(java.lang.Object securityContext)
void addExtensionBundle(Felix felix, BundleImpl bundle) throws java.lang.SecurityException, BundleException, java.lang.Exception
felix - the framework instance the given extension bundle comes from.bundle - the extension bundle to add.BundleException - if extension bundles are not supported or this is
not a framework extension.java.lang.SecurityException - if the caller does not have the needed
AdminPermission.EXTENSIONLIFECYCLE and security is enabled.java.lang.Exception - in case something goes wrong.void startExtensionBundle(Felix felix, BundleImpl bundle)
felix - the framework instance the extension bundle is installed in.bundle - the extension bundle to start if it has a Felix specific activator.void startPendingExtensionBundles(Felix felix)
void stopExtensionBundles(Felix felix)
void removeExtensions(Felix felix)
felix - the framework instance whose extensions need to be unregistered.private java.util.List<BundleCapability> getCapabilities(java.lang.String namespace)
private void appendCapabilities(java.util.List<BundleCapability> caps)
private java.lang.String convertCapabilitiesToHeaders(java.util.Map headers)
public java.net.URLConnection openConnection(java.net.URL url)
throws java.io.IOException
openConnection in class java.net.URLStreamHandlerjava.io.IOExceptionprotected java.net.InetAddress getHostAddress(java.net.URL u)
getHostAddress in class java.net.URLStreamHandlerprivate void addExtension(java.lang.Object source,
Bundle extension)
private void _removeExtensions(java.lang.Object source)
private void _add(java.lang.String name,
Bundle extension)
public void close()
ContentThis method must be called when the content is no longer needed so that any resourses being used (e.g., open files) can be closed. Once this method is called, the content is no longer usable. If the content is already closed, then calls on this method should have no effect.
public java.util.Enumeration getEntries()
ContentReturns an enumeration of entry names as String objects. An entry name is a path constructed with '/' as path element separators and is relative to the root of the content. Entry names for entries that represent directories should end with the '/' character.
getEntries in interface Contentpublic boolean hasEntry(java.lang.String name)
ContentThis method determines if the specified named entry is contained in the associated content. The entry name is a relative path with '/' separators.
public byte[] getEntryAsBytes(java.lang.String name)
ContentThis method returns the named entry as an array of bytes.
getEntryAsBytes in interface Contentname - The name of the entry to retrieve as a byte array.public java.io.InputStream getEntryAsStream(java.lang.String name)
throws java.io.IOException
ContentThis method returns the named entry as an input stream.
getEntryAsStream in interface Contentname - The name of the entry to retrieve as an input stream.java.io.IOExceptionpublic Content getEntryAsContent(java.lang.String name)
ContentThis method returns the named entry as an IContent Typically, this method only makes sense for entries that correspond to some form of aggregated resource (e.g., an embedded JAR file or directory), but implementations are free to interpret this however makes sense. This method should return a new IContent instance for every invocation and the caller is responsible for opening and closing the returned content object.
getEntryAsContent in interface Contentname - The name of the entry to retrieve as an IContent.public java.lang.String getEntryAsNativeLibrary(java.lang.String name)
ContentThis method returns the named entry as a file in the file system for use as a native library. It may not be possible for all content implementations (e.g., memory only) to implement this method, in which case it is acceptable to return null. Since native libraries can only be associated with a single class loader, this method should return a unique file per request.
getEntryAsNativeLibrary in interface Contentname - The name of the entry to retrieve as a file.public java.net.URL getEntryAsURL(java.lang.String name)
ContentThis method allows retrieving an entry as a local URL.
getEntryAsURL in interface Contentname - The name of the entry to retrieve as a URL