Interface AtomosContent

  • 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 Detail

      • getAtomosLocation

        String getAtomosLocation()
        The location of the Atomos content. The location always includes the Atomos bundle's layer name. This location plus the prefix 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 a BundleException 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, if null then the prefix "atomos" will be used
        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 returned ConnectContent can be used to lookup entries from the content directly. If possible, it is preferred to used the bundle returned by getBundle() 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 return null 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 or null if no bundle location is connected for this content. A non-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 the install(String) method, this method does not install this content as a connected Bundle. If the specified location is used with the BundleContext.installBundle(String) method then the installed Bundle 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.