org.apache.tuscany.sca.osgi.runtime
Class OSGiRuntime

java.lang.Object
  extended by org.apache.tuscany.sca.osgi.runtime.OSGiRuntime
Direct Known Subclasses:
EquinoxRuntime, FelixRuntime, KnopflerfishRuntime

public abstract class OSGiRuntime
extends java.lang.Object

Base OSGiRuntime implementation.


Constructor Summary
OSGiRuntime()
           
 
Method Summary
 Bundle findBundle(java.lang.String bundleLocation)
           
 Bundle findBundle(java.lang.String bundleSymbolicName, java.lang.String bundleVersion)
           
static Bundle findInstalledBundle(java.lang.String bundleLocation)
           
static Bundle findInstalledBundle(java.net.URL bundleURL)
           
static OSGiRuntime findRuntime()
          System property org.apache.tuscany.implementation.osgi.runtime.OSGiRuntime can be set to the name of the OSGiRuntime class (eg.
abstract  BundleContext getBundleContext()
           
 java.lang.ClassLoader getContextClassLoader()
           
static OSGiRuntime getRuntime()
           
static OSGiRuntime getRuntime(boolean tuscanyRunningInOSGiContainer)
           
protected  void initialize()
           
 Bundle installBundle(java.lang.String bundleLocation, java.io.InputStream inputStream)
           
protected  void setBundleContext(BundleContext bundleContext)
           
protected  void setContextClassLoader(java.lang.ClassLoader contextClassLoader)
           
 void shutdown()
           
protected abstract  BundleContext startRuntime(boolean tuscanyRunningInOSGiContainer)
           
static void stop()
          Stops the OSGi instance.
abstract  boolean supportsBundleFragments()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSGiRuntime

public OSGiRuntime()
Method Detail

getBundleContext

public abstract BundleContext getBundleContext()

supportsBundleFragments

public abstract boolean supportsBundleFragments()

startRuntime

protected abstract BundleContext startRuntime(boolean tuscanyRunningInOSGiContainer)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

findRuntime

public static OSGiRuntime findRuntime()
                               throws java.lang.Exception
System property org.apache.tuscany.implementation.osgi.runtime.OSGiRuntime can be set to the name of the OSGiRuntime class (eg. EquinoxRuntime). If set, start this runtime and return the system bundlecontext. If not set, start Equinox/Felix/Knopflerfish (in that order) from the classpath.

Throws:
BundleException
java.lang.Exception

getRuntime

public static OSGiRuntime getRuntime()
                              throws java.lang.Exception
Throws:
java.lang.Exception

getRuntime

public static OSGiRuntime getRuntime(boolean tuscanyRunningInOSGiContainer)
                              throws java.lang.Exception
Throws:
java.lang.Exception

shutdown

public void shutdown()
              throws java.lang.Exception
Throws:
java.lang.Exception

setBundleContext

protected void setBundleContext(BundleContext bundleContext)

getContextClassLoader

public java.lang.ClassLoader getContextClassLoader()

setContextClassLoader

protected void setContextClassLoader(java.lang.ClassLoader contextClassLoader)

initialize

protected void initialize()

findBundle

public Bundle findBundle(java.lang.String bundleSymbolicName,
                         java.lang.String bundleVersion)

findInstalledBundle

public static Bundle findInstalledBundle(java.lang.String bundleLocation)

findInstalledBundle

public static Bundle findInstalledBundle(java.net.URL bundleURL)

findBundle

public Bundle findBundle(java.lang.String bundleLocation)

installBundle

public Bundle installBundle(java.lang.String bundleLocation,
                            java.io.InputStream inputStream)

stop

public static void stop()
                 throws java.lang.Exception
Stops the OSGi instance.

Throws:
java.lang.Exception - Failed to shutdown the OSGi instance.