-
- All Superinterfaces:
Comparable<AtomosContent>
@ProviderType public interface AtomosContent extends Comparable<AtomosContent>
Atomos Content provides information about content discovered by the Atomos runtime which can be installed as a connected bundle into an OSGi Framework.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> Optional<T>
adapt(Class<T> type)
Adapt this Atomos content to the specified type.void
connect(String bundleLocation)
Connects the specified bundle location to this Atomos content.void
disconnect()
Disconnects this Atomos content from the bundle location, if the bundle location is set.AtomosLayer
getAtomosLayer()
The Atomos layer this Atomos content is in.String
getAtomosLocation()
The location of the Atomos content.Bundle
getBundle()
Returns the OSGi bundle installed which is connected with this Atomos content.ConnectContent
getConnectContent()
Returns the connect content for this Atomos content.String
getConnectLocation()
Returns the connected bundle location for this Atomos content ornull
if no bundle location is connected for this content.String
getSymbolicName()
The symbolic name of the Atomos content.Version
getVersion()
The version of the Atomos content.default Bundle
install()
Same asinstall(String)
using a null prefix.Bundle
install(String prefix)
Installs this Atomos content as a connected bundle using the specified location prefix.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Method Detail
-
getAtomosLocation
String getAtomosLocation()
The location of the Atomos content. The location always includes the Atomos bundle's layername
. This location plus theprefix
can be used as the install location of a connected bundle.- Returns:
- the location of the Atomos content.
- See Also:
install(String)
-
getSymbolicName
String getSymbolicName()
The symbolic name of the Atomos content.- Returns:
- the symbolic name.
-
getVersion
Version getVersion()
The version of the Atomos content.- Returns:
- the version
-
adapt
<T> Optional<T> adapt(Class<T> type)
Adapt this Atomos content to the specified type. For example, if running in a module layer then the module of the Atomos content is returned in the optional value.- Type Parameters:
T
- The type to which this Atomos content is to be adapted.- Parameters:
type
- Class object for the type to which this Atomos content is to be adapted.- Returns:
- The object, of the specified type, to which this Atomos content has been
adapted or
empty
if this content cannot be adapted to the specified type.
-
getAtomosLayer
AtomosLayer getAtomosLayer()
The Atomos layer this Atomos content is in.- Returns:
- the Atomos layer
-
install
Bundle install(String prefix) throws BundleException
Installs this Atomos content as a connected bundle using the specified location prefix. If the Atomos content is already installed then the existing bundle is returned if the existing bundle location is equal to the location this method calculates to install the bundle; otherwise aBundleException
is thrown. This is a convenience method that is equivalent to the following:AtomosContent atomosContent = getAtomosContent(); BundleContext bc = getBundleContext(); String osgiLocation = prefix + ":" + atomosContent.getAtomosLocation(); Bundle b = bc.getBundle(osgiLocation); if (b != null) { if (!b.getLocation().equals(osgiLocation)) { throw new BundleException(); } } atomosContent.disconnect(); atomosContent.connect(osgiLocation); b = bc.installBundle(osgiLocation);
- Parameters:
prefix
- the prefix to use, ifnull
then the prefix "atomos" will be used- Returns:
- the installed connected bundle.
- Throws:
BundleException
- if an error occurs installing the Atomos content
-
install
default Bundle install() throws BundleException
Same asinstall(String)
using a null prefix.- Returns:
- the installed connected bundle
- Throws:
BundleException
- if an error occurs installing the Atomos content
-
getConnectContent
ConnectContent getConnectContent()
Returns the connect content for this Atomos content. The returnedConnectContent
can be used to lookup entries from the content directly. If possible, it is preferred to used the bundle returned bygetBundle()
instead to access entries from the content. Using the bundle avoids issues with accessing the content at the same time the OSGi Framework is managing the associated content.If the ConnectContent is not managed by a framework,
getBundle()
will returnnull
and this method can be called as a way to access the associated content. The caller is responsible for opening and closing the ConnectContent as appropriate.- Returns:
- ConnectContent associated with this Atomos content.
-
getConnectLocation
String getConnectLocation()
Returns the connected bundle location for this Atomos content ornull
if no bundle location is connected for this content. Anon-null
value is only an indication that this content#connect(String)
has been called to set the connect bundle location. A connected bundle may still need to be installed into the framework using this bundle location.- Returns:
- the bundle location or
null
-
connect
void connect(String bundleLocation)
Connects the specified bundle location to this Atomos content. Unlike theinstall(String)
method, this method does not install this content as a connectedBundle
. If the specified location is used with theBundleContext.installBundle(String)
method then the installedBundle
will be connected to this content. This method does nothing if this content is already using the specified location as its connect location.- Parameters:
bundleLocation
- the bundle location- Throws:
IllegalStateException
- if the connect location is already being used as a connect location or if this content already has a different connect location set
-
disconnect
void disconnect()
Disconnects this Atomos content from the bundle location, if the bundle location is set. This method does nothing if this content is not connected.
-
getBundle
Bundle getBundle()
Returns the OSGi bundle installed which is connected with this Atomos content.- Returns:
- the OSGi bundle or
null
if there is no bundle connected with this content or if there is no OSGi Framework initialized with the Atomos Runtime.
-
-