Database Tutorial DB Application

From RifidiWiki

Revision as of 19:38, 3 December 2009 by Kyle (Talk | contribs)

Jump to: navigation, search

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