org.apache.felix.example.servicebased.host
Class Activator

java.lang.Object
  extended by org.apache.felix.example.servicebased.host.Activator
All Implemented Interfaces:
java.lang.Runnable, org.osgi.framework.BundleActivator

public class Activator
extends java.lang.Object
implements org.osgi.framework.BundleActivator, java.lang.Runnable

The activator of the host application bundle. The activator creates the main application JFrame and starts tracking SimpleShape services. All activity is performed on the Swing event thread to avoid synchronization and repainting issues. Closing the application window will result in Bundle.stop() being called on the system bundle, which will cause the framework to shutdown and the JVM to exit.

This class also provides a static main() method so that it can be run as a stand-alone host application. In such a scenario, the application creates its own embedded Felix framework instance and interacts with the internal services to providing drawing functionality. To successfully launch the stand-alone application, it must be run from this bundle's installation directory using "java -jar".


Constructor Summary
Activator()
           
 
Method Summary
static void main(java.lang.String[] argv)
          Enables the bundle to run as a stand-alone application.
 void run()
          This method actually performs the creation of the application window.
 void start(org.osgi.framework.BundleContext context)
          Displays the applications window and starts service tracking; everything is done on the Swing event thread to avoid synchronization and repainting issues.
 void stop(org.osgi.framework.BundleContext context)
          Stops service tracking and disposes of the application window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Activator

public Activator()
Method Detail

start

public void start(org.osgi.framework.BundleContext context)
Displays the applications window and starts service tracking; everything is done on the Swing event thread to avoid synchronization and repainting issues.

Specified by:
start in interface org.osgi.framework.BundleActivator
Parameters:
context - The context of the bundle.

stop

public void stop(org.osgi.framework.BundleContext context)
Stops service tracking and disposes of the application window.

Specified by:
stop in interface org.osgi.framework.BundleActivator
Parameters:
context - The context of the bundle.

run

public void run()
This method actually performs the creation of the application window. It is intended to be called by the Swing event thread and should not be called directly.

Specified by:
run in interface java.lang.Runnable

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Enables the bundle to run as a stand-alone application. When this static main() method is invoked, the application creates its own embedded Felix framework instance and interacts with the internal services to provide drawing functionality. To successfully launch as a stand-alone application, this method should be invoked from the bundle's installation directory using "java -jar".

Parameters:
argv - The command-line arguments.
Throws:
java.lang.Exception - If anything goes wrong.