OSGI HengSin/Using Extensions

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

PostgreSQL as Plugin

  • As you should know, a plugin here is similar to an OSGI bundle, or component. With that, we mean that now any class object can be made into a component, called as a loosely coupled Extension.
  • In the Eclipse Project workspace shown below you can see on the Package Explorer panel on the left-side that the ADempiere project is now separated into such plugins.
The Plugin Manifest has an Extension defined to call the org.compiere.db.DB_PostgreSQL class
Database Type wasn't having the usual Postgres option
  • Note of the PostgreSQL provider plugin project below the Oracle provider plugin.
  • Originally that plugin did not have the Manifest details as now shown in the Editor's space.
  • Thus during login, at the Database Connection dialog box I do not see the PostgreSQL option, as shown on the right.
  • After the usual panic screams, i managed to control back my mouse and and peek into the Oracle plugin.xml.
  • Then after some staring at it, i made the PostgreSQL to have a corresponding entry as shown below:
<plugin>
   <extension
         point="org.compiere.db.AdempiereDatabase">
      <database
            class="org.compiere.db.DB_PostgreSQL"
            id="PostgreSQL">
      </database>
   </extension>

LaunchTime Selection

  • With OSGI, we can now select what components to deploy or not to deploy without further work at the code.
Note the highlighted plugin was unchecked. Therefore when launched, the Oracle bundle won't be active and won't appear in DB selection nor work with Oracle.
  • Even after launching you can still stop and start again any bundle from the list. In this way there is more componentisation in your business application opening to the very latest in software modernity.
  • For example lets say this is the status of your PG bundle (type 'ss' in your OSGI console, and note the bundle ID):
121	ACTIVE      org.compiere.db.postgresql.provider_1.0.0.qualifier
  • When we type in 'stop 121', and then try to select it, this is what happens:
osgi> Failed to acquire new connection. Status=null
===========> CConnection.getDatabase: java.lang.NullPointerException [11]
  • By reissuing the following:
OSGI>start 121
  • Now it can work:
osgi> [INFO] MLog clients using com.mchange.v2.log.FallbackMLog logging.
[INFO] Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
  • You can also uninstall it completely and it will disappear from the console:
osgi>uninstall 121
  • But to reinstall you have to give the full URL of that bundle and it will reappear with a new ID. In my case it is:
osgi>install file:/Applications/adempiere-client/plugins/org.compiere.db.postgresql.provider_1.0.0.qualifier.jar

See Also