You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2008/07/06 10:52:44 UTC
svn commit: r674275 - in /webservices/axis2/trunk/java/modules/osgi: ./
src/org/apache/axis2/osgi/ src/org/apache/axis2/osgi/deployment/
src/org/apache/axis2/osgi/internal/
Author: saminda
Date: Sun Jul 6 01:52:44 2008
New Revision: 674275
URL: http://svn.apache.org/viewvc?rev=674275&view=rev
Log:
Making OCCF a ManagedService and removing unncessary servlets
Removed:
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/InitServlet.java
Modified:
webservices/axis2/trunk/java/modules/osgi/pom.xml
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java
webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/internal/Activator.java
Modified: webservices/axis2/trunk/java/modules/osgi/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/pom.xml?rev=674275&r1=674274&r2=674275&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/osgi/pom.xml Sun Jul 6 01:52:44 2008
@@ -71,6 +71,7 @@
org.osgi.service.http; version=1.2.0,
org.osgi.util.tracker; version=1.3.1,
org.osgi.service.log; version=1.3,
+ org.osgi.service.cm; version=1.2.0,
com.ibm.wsdl.util.xml,
javax.activation;version="1.1",
javax.jws;version="2.0",
@@ -116,7 +117,6 @@
org.apache.axis2.osgi.internal.Activator
</Bundle-Activator>
<Export-Service>
- org.apache.axis2.engine.AxisConfiguration,
org.apache.axis2.context.ConfigurationContext
</Export-Service>
<Bundle-RequiredExecutionEnvironment>
Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java?rev=674275&r1=674274&r2=674275&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java Sun Jul 6 01:52:44 2008
@@ -31,6 +31,8 @@
import org.apache.axis2.transport.MessageFormatter;
import org.apache.axis2.transport.TransportSender;
import org.osgi.framework.*;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ConfigurationException;
import java.util.Dictionary;
import java.util.Iterator;
@@ -39,18 +41,36 @@
import java.util.concurrent.locks.ReentrantLock;
/**
- *
+ * OSGiConfigurationContextFactory creates ConfigurationContext, which is the ultimate Axis2 environment.
+ * This creation is handled as a ManagedService service, thus, Configuraiton Admin has control over it.
*/
-public class OSGiConfigurationContextFactory {
+public class OSGiConfigurationContextFactory implements ManagedService {
- public static ConfigurationContext createConfigurationContext(
- AxisConfigurator axisConfigurator, BundleContext context) throws AxisFault {
+ private BundleContext context;
+
+ private ServiceRegistration registration;
+
+ public synchronized void start(BundleContext context) {
+ this.context = context;
+ Dictionary props = new Properties();
+ props.put(Constants.SERVICE_PID, "org.apache.axis2.osgi");
+ registration = context.registerService(ManagedService.class.getName(), this, props);
+ }
+
+ public synchronized void stop() {
+ registration.unregister();
+ }
+
+ public synchronized void startConfigurationContext(Dictionary dictionary) throws AxisFault {
+ AxisConfigurator configurator = new OSGiServerConfigurator(context);
ConfigurationContext configCtx =
- ConfigurationContextFactory.createConfigurationContext(axisConfigurator);
+ ConfigurationContextFactory.createConfigurationContext(configurator);
ListenerManager listenerManager = new ListenerManager();
listenerManager.init(configCtx);
listenerManager.start();
ListenerManager.defaultConfigurationContext = configCtx;
+ //register ConfigurationContext as a OSGi serivce
+ context.registerService(ConfigurationContext.class.getName(), configCtx, null);
// first check (bundlestarts at the end or partially) {
// // loop and add axis*
@@ -85,8 +105,15 @@
prop.put(PROTOCOL, "http");
//adding the default listener
context.registerService(TransportListener.class.getName(), new HttpListener(context), prop);
+ }
- return configCtx;
+ public void updated(Dictionary dictionary) throws ConfigurationException {
+ try {
+ startConfigurationContext(dictionary);
+ } catch (AxisFault e) {
+ String msg = "Error while creating ConfigurationContext";
+ throw new ConfigurationException(msg, msg, e);
+ }
}
@@ -237,7 +264,7 @@
/**
* TODO: TBD, purpose of this listener is to listen to OSGi services that needed to be set as WS
*/
- private static class WSListener implements ServiceListener {
+ private static class WSListener implements ServiceListener {
private ConfigurationContext configCtx;
Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java?rev=674275&r1=674274&r2=674275&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java (original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServerConfigurator.java Sun Jul 6 01:52:44 2008
@@ -30,7 +30,7 @@
/**
* This is the heart of the OSGi deployment.
- * TODO: TBD
+ *
*/
public class OSGiServerConfigurator extends DeploymentEngine implements AxisConfigurator {
@@ -59,7 +59,6 @@
try {
InputStream inputStream = axis2XmlUrl.openStream();
populateAxisConfiguration(inputStream);
- //TODO: DeploymentEngine should be scalable enough
axisConfig.validateSystemPredefinedPhases();
return axisConfig;
} catch (IOException e) {
@@ -87,8 +86,6 @@
throw new DeploymentException(msg, e);
}
//TODO: if module deployer neede to set it should be set here.
- //set the AxisConfiguration as a service.
- context.registerService(AxisConfiguration.class.getName(), axisConfig, null);
return axisConfig;
}
Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/internal/Activator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/internal/Activator.java?rev=674275&r1=674274&r2=674275&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/internal/Activator.java (original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/internal/Activator.java Sun Jul 6 01:52:44 2008
@@ -16,10 +16,9 @@
package org.apache.axis2.osgi.internal;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisConfigurator;
-import org.apache.axis2.osgi.InitServlet;
import org.apache.axis2.osgi.OSGiAxisServlet;
+import static org.apache.axis2.osgi.deployment.OSGiAxis2Constants.AXIS2_OSGi_ROOT_CONTEXT;
+import org.apache.axis2.osgi.deployment.OSGiConfigurationContextFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -29,30 +28,31 @@
import javax.servlet.ServletException;
-import static org.apache.axis2.osgi.deployment.OSGiAxis2Constants.*;
-
/**
* Activator will set the necessary parameters that initiate Axis2 OSGi integration
- * TODO: TBD; yet the structure is being formed
*/
public class Activator implements BundleActivator {
private HttpServiceTracker tracker;
+ private final OSGiConfigurationContextFactory managedService;
+
+ public Activator() {
+ managedService = new OSGiConfigurationContextFactory();
+ }
+
public void start(BundleContext context) throws Exception {
+ managedService.start(context);
+ managedService.updated(null);
tracker = new HttpServiceTracker(context);
tracker.open();
}
public void stop(BundleContext context) throws Exception {
tracker.close();
- //ungetService
- ServiceReference axisConfigRef =
- context.getServiceReference(AxisConfigurator.class.getName());
- if (axisConfigRef != null) {
- context.ungetService(axisConfigRef);
- }
+ managedService.stop();
+ //ungetService ConfigurationContext.class.getName()
ServiceReference configCtxRef =
context.getServiceReference(ConfigurationContext.class.getName());
if (configCtxRef != null) {
@@ -60,9 +60,9 @@
}
}
- //service trackers
+ //HttpServiceTracker
- private static class HttpServiceTracker extends ServiceTracker {
+ class HttpServiceTracker extends ServiceTracker {
public HttpServiceTracker(BundleContext context) {
super(context, HttpService.class.getName(), null);
@@ -72,8 +72,6 @@
HttpService httpService = (HttpService) context.getService(serviceReference);
try {
- InitServlet initServlet = new InitServlet(context);
- httpService.registerServlet("/init_servlet_not_public", initServlet, null, null);
OSGiAxisServlet axisServlet = new OSGiAxisServlet(context);
ServiceReference configCtxRef =
context.getServiceReference(ConfigurationContext.class.getName());