Difference between revisions of "Database Tutorial DB Application"

From RifidiWiki

Jump to: navigation, search
(New page: This page explains a few aspects of the DBApp class and it could be extended =Activator= The Activator is a class that implements the <tt>BundleActivator</tt> interface. It has two methods...)
 
(Dependency Injection)
Line 22: Line 22:
 
</pre>
 
</pre>
 
=Dependency Injection=
 
=Dependency Injection=
 +
The DBApp class
 +
 
=Esper Query=
 
=Esper Query=
 
=Esper Listener=
 
=Esper Listener=

Revision as of 19:38, 3 December 2009

This page explains a few aspects of the DBApp class and it could be extended

Activator

The Activator is a class that implements the BundleActivator interface. It has two methods: start and stop. These methods are called by the OSGi runtime when the bundle is started and stopped. One thing to keep in mind about the DBApp is that we need to some clean up when the DBApp bundle is stopped. Therefore in the constructor of the the DBApp class, we give a reference to the Activator:

	/**
	 * The constructor
	 */
	public DBApp() {
		Activator.myApp = this;
	}

Then in the Activator, we can call the stop method of the DBApp when the bundle's stop method is called:

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
		myApp.stop();
	}

Dependency Injection

The DBApp class

Esper Query

Esper Listener

Personal tools