svn commit: r1594701 - in /axis/axis2/java/core/trunk/modules: osgi-tests/src/test/java/OSGiTest.java osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java

2014-05-14 Thread veithen
Author: veithen
Date: Wed May 14 20:20:43 2014
New Revision: 1594701

URL: http://svn.apache.org/r1594701
Log:
AXIS2-5646: Fixed an IllegalStateException triggered during shutdown of the 
Axis2 OSGi module:
* Applied the patch submitted by Andy Schmidt (with some minor formatting 
changes).
* Enabled the regression test for this issue.

Modified:
axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java

axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java

Modified: 
axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java?rev=1594701&r1=1594700&r2=1594701&view=diff
==
--- axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
(original)
+++ axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
Wed May 14 20:20:43 2014
@@ -113,10 +113,8 @@ public class OSGiTest {
 serviceClient.setOptions(options);
 OMElement result = serviceClient.sendReceive(payload);
 assertEquals("getVersionResponse", result.getLocalName());
-// Stop the Axis2 bundle explicitly here so that we can test that 
it cleanly shuts down
-getAxis2Bundle(container).stop();
-// TODO: Test for AXIS2-5646
-//stopBundle(getAxis2Bundle(container));
+// Stop the Axis2 bundle explicitly here so that we can test that 
it cleanly shuts down (see AXIS2-5646)
+stopBundle(getAxis2Bundle(container));
 } finally {
 container.stop();
 }

Modified: 
axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java?rev=1594701&r1=1594700&r2=1594701&view=diff
==
--- 
axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
 Wed May 14 20:20:43 2014
@@ -56,6 +56,8 @@ public class OSGiConfigurationContextFac
 
 private ServiceRegistration mngServiceRegistration;
 
+private ServiceRegistration transportServiceRegistration;
+
 private ConfigurationContext configCtx;
 
 private ServiceRegistration configCtxServiceRegistration;
@@ -72,6 +74,14 @@ public class OSGiConfigurationContextFac
 }
 
 public synchronized void stop() {
+if (configCtxServiceRegistration != null) {
+configCtxServiceRegistration.unregister();
+}
+
+if (transportServiceRegistration != null) {
+transportServiceRegistration.unregister();
+}
+
 if (mngServiceRegistration != null) {
 mngServiceRegistration.unregister();
 }
@@ -120,7 +130,7 @@ public class OSGiConfigurationContextFac
 Dictionary prop = new Properties();
 prop.put(PROTOCOL, "http");
 //adding the default listener
-context.registerService(TransportListener.class.getName(), new 
HttpListener(context),
+transportServiceRegistration = 
context.registerService(TransportListener.class.getName(), new 
HttpListener(context),
 prop);
 log.info("Axis2 environment has started.");
 } catch (AxisFault e) {




svn commit: r1593690 - /axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java

2014-05-14 Thread veithen
Author: veithen
Date: Sat May 10 12:04:58 2014
New Revision: 1593690

URL: http://svn.apache.org/r1593690
Log:
AXIS2-5646: Added some infrastructure to OSGiTest to test that the Axis2 bundle 
stops cleanly.

Modified:
axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java

Modified: 
axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java?rev=1593690&r1=1593689&r2=1593690&view=diff
==
--- axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
(original)
+++ axis/axis2/java/core/trunk/modules/osgi-tests/src/test/java/OSGiTest.java 
Sat May 10 12:04:58 2014
@@ -41,6 +41,7 @@ import org.junit.Test;
 import org.ops4j.pax.exam.ExamSystem;
 import org.ops4j.pax.exam.nat.internal.NativeTestContainer;
 import org.ops4j.pax.exam.spi.DefaultExamSystem;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 
 public class OSGiTest {
@@ -105,8 +106,20 @@ public class OSGiTest {
 serviceClient.setOptions(options);
 OMElement result = serviceClient.sendReceive(payload);
 assertEquals("getVersionResponse", result.getLocalName());
+// Stop the Axis2 bundle explicitly here so that we can test that 
it cleanly shuts down
+// TODO: doesn't work yet; see AXIS2-5646
+//getAxis2Bundle(container).stop();
 } finally {
 container.stop();
 }
 }
+
+private static Bundle getAxis2Bundle(NativeTestContainer container) {
+for (Bundle bundle : 
container.getSystemBundle().getBundleContext().getBundles()) {
+if (bundle.getSymbolicName().equals("org.apache.axis2.osgi")) {
+return bundle;
+}
+}
+throw new Error("Axis2 bundle not found");
+}
 }