Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EclipseLink/Examples/DBWS/AdvancedOSGi
DBWS in an OSGi Environment
An Eclipselink DBWS service can be run in an OSGi environment using Javase 6's 'containerless' javax.xml.ws.Endpoint API.
Environment Setup
Download a version of the Eclipse IDE that includes the Plug-in Development Environment (PDE) (Eclipse IDE for Java EE Developers, Eclipse Classic 3.6.0 or
Eclipse for RCP and RAP Developers).
Install an OSGi-friendly JDBC driver - use Derby bundle:
- Download Apache Derby (org.apache.derby) bundle from Orbit.
- Place the org.apache.derby bundle into your $ECLIPSE_HOME/dropins folder.
- Install the EclipseLink and Jetty target Components:
Accept the license and proceed through the prompts for re-starting Eclipse ...
{NB - later, a set of updated EclipseLink bundles will be required}
Under 'Preferences' -> 'Plug-in Development' -> 'Target Platform', reload the Running Platform (Active)
Create a new Plug-in project
From the 'Plug-in Development' Perspective, create a new Plug-in project SimpleTable:
{Note the choice of 'standard' for OSGi framework}
Proceed to the next panel of the wizard where the (OSGi bundle) Activator for SimpleTable is defined:
Click 'Finish' and open the generated Activator:
package simpletable; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { private static BundleContext context; static BundleContext getContext() { return context; } /* * (non-Javadoc) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext bundleContext) throws Exception { Activator.context = bundleContext; } /* * (non-Javadoc) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; } }
Modifying Activator to implement javax.xml.ws.Provider
In order for our Activator to 'provide' Web service, we need to update the EclipseLink bundles. Builds after
2.1.1.v20100805-r7986 have EclipseLink DBWS packaged as a 'fragment' bundle that extends the core
org.eclipse.persistence
bundle. Download the updated bundles and extract the following 6 bundles:
directory:
$ ls updatedBundles/ org.eclipse.persistence.asm.source_2.1.1.v20100805-r7986.jar org.eclipse.persistence.asm_2.1.1.v20100805-r7986.jar org.eclipse.persistence.core.source_2.1.1.v20100805-r7986.jar org.eclipse.persistence.core_2.1.1.v20100805-r7986.jar org.eclipse.persistence.dbws.source_2.1.1.v20100805-r7986.jar org.eclipse.persistence.dbws_2.1.1.v20100805-r7986.jar
Edit the Target Platform, adding the directory with the above bundles:
Change the Activator to extend org.eclipse.persistence.internal.dbws.ProviderHelper
(NB - will show error):
In order to correct the error, the SimpleTable project needs to update its list of required bundles. Open the MANIFEST.MF file in the 'Plug-in Manifest Editor' and select the 'Dependencies' tab and add the following bundles:
Note: you do not have to directly reference the DBWS bundle since its 'host' bundle org.eclipse.persistence.core is included in the list of 'Required Plug-ins'