Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
EclipseLink/Development/DBWS/OSGi/ModifyActivator
< EclipseLink | Development | DBWS | OSGi
Modifying Activator to implement javax.xml.ws.Provider
Change the Activator to extend org.eclipse.persistence.internal.dbws.ProviderHelper
(NB - will show errors):
In order to correct the errors, 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:
The Activator needs to be annotated to support a (dynamic) Web services Endpoint:
public class Constants { //DBWS Properties public static final String TEST_PROJECT = "simpletable"; //JAX-WS properties public static final String TEST_NAMESPACE = "urn:" + TEST_PROJECT; public static final String TEST_SERVICE = TEST_PROJECT + "Service"; public static final String TEST_SERVICE_NAMESPACE = "urn:" + TEST_SERVICE; public static final String TEST_PORT = TEST_SERVICE + "Port"; public static final String ENDPOINT_ADDRESS = "http://localhost:9999/" + TEST_PROJECT; } package simpletable; //java eXtension imports import javax.xml.namespace.QName; import javax.xml.soap.SOAPMessage; import javax.xml.ws.Endpoint; import javax.xml.ws.Provider; import javax.xml.ws.Service; import javax.xml.ws.WebServiceProvider; import javax.xml.ws.ServiceMode; import static javax.xml.ws.Service.Mode.MESSAGE; import static javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING; //EclipseLink imports import org.eclipse.persistence.internal.dbws.ProviderHelper; import org.eclipse.persistence.sessions.Session; //OSGi/PDE imports import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; //test imports import static simpletable.Constants.ENDPOINT_ADDRESS; import static simpletable.Constants.TEST_PORT; import static simpletable.Constants.TEST_SERVICE_NAMESPACE; import static simpletable.Constants.TEST_SERVICE; @WebServiceProvider( targetNamespace = TEST_SERVICE_NAMESPACE, serviceName = TEST_SERVICE, portName = TEST_PORT ) @ServiceMode(MESSAGE) public class Activator extends ProviderHelper implements BundleActivator, Provider<SOAPMessage> { private static BundleContext context; private static Endpoint endpoint = null; private static QName portQName = null; private static Service testService = null; 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; super.init(getClass().getClassLoader(), null, false); endpoint = Endpoint.create(this); endpoint.publish(ENDPOINT_ADDRESS); QName serviceQName = new QName(TEST_SERVICE_NAMESPACE, TEST_SERVICE); portQName = new QName(TEST_SERVICE_NAMESPACE, TEST_PORT); testService = Service.create(serviceQName); testService.addPort(portQName, SOAP11HTTP_BINDING, ENDPOINT_ADDRESS); System.out.println("Hello, " + testService.toString()); } /* * (non-Javadoc) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; if (endpoint != null) { endpoint.stop(); } super.destroy(); System.out.println("Goodbye"); } }