Interface RuntimeContext

All Known Implementing Classes:
DefaultRuntimeContext, OSGiRuntimeContext

public interface RuntimeContext
The runtime context.

Runtime contexts are used to create components. They provides custom methods to load classes and find resources.

Runtime contexts are generally attached to a bundle context (or module deployment context) Note that all undeploy methods are deprectaed! see DefaultRuntimeContext for more information

Author:
Bogdan Stefanescu
  • Method Details

    • getRuntime

      RuntimeService getRuntime()
      Gets the current runtime service.
      Returns:
      the runtime service
    • getBundle

      org.osgi.framework.Bundle getBundle()
      Gets the container bundle or null if we are not running in an OSGi environment.
    • getComponents

      ComponentName[] getComponents()
      Get the component names deployed by this context
      Returns:
      the list of components. Return an empty array if no components where deployed.
      Since:
      9.2
    • loadClass

      Class<?> loadClass(String className) throws ClassNotFoundException
      Loads the class given its name.
      Parameters:
      className - the class name
      Returns:
      the class object
      Throws:
      ClassNotFoundException - if no such class were found
      See Also:
    • getResource

      URL getResource(String name)
      Finds a resource having the given name.
      Parameters:
      name - the resource name
      Returns:
      an URL to the resource having that name or null if not was found
      See Also:
    • getLocalResource

      URL getLocalResource(String name)
      Finds a local resource having the given name.

      Only the current bundle should be searched for the resource.

      Parameters:
      name - the local resource name
      Returns:
      an URL to the resource having that name or null if not was found
      See Also:
    • deploy

      RegistrationInfo deploy(URL url) throws IOException
      Deploys a component XML descriptor given its URL.

      Do nothing if component is already deployed.

      Returns the registration info of the new deployed component or null if the component was not deployed.

      Parameters:
      url - the url of the XML descriptor
      Returns:
      the component registration info or null if registration failed for some reason
      Throws:
      IOException
    • deploy

      Same as deploy(URL) but using a StreamRef as argument.
      Throws:
      IOException
    • undeploy

      void undeploy(URL url) throws IOException
      Undeploys a component XML descriptor given its URL.

      Do nothing if no component was registered for the given URL.

      Parameters:
      url - the URL of the XML descriptor
      Throws:
      IOException
    • undeploy

      void undeploy(StreamRef ref) throws IOException
      Same as undeploy(URL) but using a StreamRef as stream reference.
      Throws:
      IOException
    • isDeployed

      boolean isDeployed(URL url)
      Checks whether the component XML file at given URL was deployed.
      Parameters:
      url - the URL to check
      Returns:
      true it deployed, false otherwise
    • isDeployed

      boolean isDeployed(StreamRef ref)
      Checks whether the component XML file given by the StreamRef argument was deployed.
    • deploy

      RegistrationInfo deploy(String location)
      Deploys the component whose XML descriptor is at the given location.

      If the component is already deployed do nothing.

      The location is interpreted as a relative path inside the bundle (jar) containing the component - and will be loaded using getLocalResource(String).

      Returns the registration info of the new deployed component or null if the component was not deployed.

      Parameters:
      location - the location
      Returns:
      the component registration info or null if registration failed for some reason
    • undeploy

      void undeploy(String location)
      Undeploys the component at the given location if any was deployed.

      If the component was not deployed do nothing.

      Parameters:
      location - the location of the component to undeploy
    • isDeployed

      boolean isDeployed(String location)
      Checks if the component at the given location is deployed.
      Parameters:
      location - the component location to check
      Returns:
      true if deployed, false otherwise
    • destroy

      void destroy()
      Destroys this context.