tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1486 ServerCreated ServerDestroyed events for jaxws
Date Tue, 06 Jan 2015 14:39:11 GMT
Repository: tomee
Updated Branches:
  refs/heads/develop 9fef82d3d -> 74dd0462b


TOMEE-1486 ServerCreated ServerDestroyed events for jaxws


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/74dd0462
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/74dd0462
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/74dd0462

Branch: refs/heads/develop
Commit: 74dd0462b6e2bf3a99c0dd328ca93ab04cd2d0d4
Parents: 9fef82d
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Tue Jan 6 15:38:55 2015 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Tue Jan 6 15:38:55 2015 +0100

----------------------------------------------------------------------
 .../apache/openejb/server/cxf/CxfService.java   | 10 +++
 .../openejb/server/cxf/CxfWsContainer.java      |  4 +-
 .../openejb/server/cxf/event/ServerCreated.java | 47 +++++++++++
 .../server/cxf/event/ServerDestroyed.java       | 38 +++++++++
 .../apache/openejb/server/cxf/EventTest.java    | 89 ++++++++++++++++++++
 tck/cdi-embedded/src/test/resources/failing.xml |  2 +-
 6 files changed, 188 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
index a3fa5a5..0b97de8 100644
--- a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
@@ -28,10 +28,13 @@ import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.cxf.client.SaajInterceptor;
 import org.apache.openejb.server.cxf.client.WebServiceInjectionConfigurator;
 import org.apache.openejb.server.cxf.ejb.EjbWsContainer;
+import org.apache.openejb.server.cxf.event.ServerCreated;
+import org.apache.openejb.server.cxf.event.ServerDestroyed;
 import org.apache.openejb.server.cxf.pojo.PojoWsContainer;
 import org.apache.openejb.server.cxf.transport.util.CxfUtil;
 import org.apache.openejb.server.httpd.HttpListener;
 import org.apache.openejb.server.webservices.WsService;
+import org.apache.openejb.util.AppFinder;
 
 import javax.naming.Context;
 import java.net.URL;
@@ -80,6 +83,9 @@ public class CxfService extends WsService {
             final EjbWsContainer container = new EjbWsContainer(bus, transportFactory, port,
beanContext, config);
             container.start();
             wsContainers.put(beanContext.getDeploymentID().toString(), container);
+            SystemInstance.get().fireEvent(new ServerCreated(
+                    container.getEndpoint().getServer(),
+                    beanContext.getModuleContext().getAppContext()));
             return container;
         } finally {
             if (oldLoader != null) {
@@ -99,6 +105,9 @@ public class CxfService extends WsService {
             PojoWsContainer container = new PojoWsContainer(loader, transportFactory, bus,
port, context, target, bdgs, services);
             container.start();
             wsContainers.put(serviceId, container);
+            SystemInstance.get().fireEvent(new ServerCreated(
+                    container.getEndpoint().getServer(),
+                    AppFinder.findAppContextOrWeb(loader, AppFinder.AppContextTransformer.INSTANCE)));
             return container;
         } finally {
             if (oldLoader != null) {
@@ -122,6 +131,7 @@ public class CxfService extends WsService {
             Thread.currentThread().setContextClassLoader(CxfUtil.initBusLoader());
             try {
                 container.destroy();
+                SystemInstance.get().fireEvent(new ServerDestroyed(container.getEndpoint().getServer()));
             } finally {
                 if (oldLoader != null) {
                     CxfUtil.clearBusLoader(oldLoader);

http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
index b74ab00..08e94ac 100644
--- a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
@@ -70,7 +70,6 @@ public abstract class CxfWsContainer implements HttpListener {
 
         if (endpoint != null) {
             endpoint.stop();
-            endpoint = null;
         }
     }
 
@@ -91,4 +90,7 @@ public abstract class CxfWsContainer implements HttpListener {
         }
     }
 
+    public CxfEndpoint getEndpoint() {
+        return endpoint;
+    }
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerCreated.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerCreated.java
b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerCreated.java
new file mode 100644
index 0000000..5fdfa88
--- /dev/null
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerCreated.java
@@ -0,0 +1,47 @@
+/*
+ *     Licensed to the Apache Software Foundation (ASF) under one or more
+ *     contributor license agreements.  See the NOTICE file distributed with
+ *     this work for additional information regarding copyright ownership.
+ *     The ASF licenses this file to You under the Apache License, Version 2.0
+ *     (the "License"); you may not use this file except in compliance with
+ *     the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ */
+package org.apache.openejb.server.cxf.event;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.openejb.AppContext;
+import org.apache.openejb.observer.Event;
+
+@Event
+public class ServerCreated {
+    private final Server server;
+    private final AppContext appContext;
+
+    public ServerCreated(final Server server, final AppContext appContext) {
+        this.server = server;
+        this.appContext = appContext;
+    }
+
+    public Server getServer() {
+        return server;
+    }
+
+    public AppContext getAppContext() {
+        return appContext;
+    }
+
+    @Override
+    public String toString() {
+        return "ServerCreated{" +
+                "appContext=" + appContext.getId() +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerDestroyed.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerDestroyed.java
b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerDestroyed.java
new file mode 100644
index 0000000..5761262
--- /dev/null
+++ b/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/event/ServerDestroyed.java
@@ -0,0 +1,38 @@
+/*
+ *     Licensed to the Apache Software Foundation (ASF) under one or more
+ *     contributor license agreements.  See the NOTICE file distributed with
+ *     this work for additional information regarding copyright ownership.
+ *     The ASF licenses this file to You under the Apache License, Version 2.0
+ *     (the "License"); you may not use this file except in compliance with
+ *     the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *     Unless required by applicable law or agreed to in writing, software
+ *     distributed under the License is distributed on an "AS IS" BASIS,
+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *     See the License for the specific language governing permissions and
+ *     limitations under the License.
+ */
+package org.apache.openejb.server.cxf.event;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.openejb.observer.Event;
+
+@Event
+public class ServerDestroyed {
+    private final Server server;
+
+    public ServerDestroyed(final Server server) {
+        this.server = server;
+    }
+
+    public Server getServer() {
+        return server;
+    }
+
+    @Override
+    public String toString() {
+        return "ServerCreated{}";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/EventTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/EventTest.java
b/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/EventTest.java
new file mode 100644
index 0000000..554fe27
--- /dev/null
+++ b/server/openejb-cxf/src/test/java/org/apache/openejb/server/cxf/EventTest.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.server.cxf;
+
+import org.apache.openejb.jee.WebApp;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.observer.Observes;
+import org.apache.openejb.server.cxf.event.ServerCreated;
+import org.apache.openejb.server.cxf.event.ServerDestroyed;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.Module;
+import org.apache.openejb.testing.RandomPort;
+import org.apache.openejb.testng.PropertiesBuilder;
+import org.junit.AfterClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.jws.WebService;
+import java.util.Properties;
+
+import static org.junit.Assert.assertNotNull;
+
+@EnableServices("jaxws")
+@RunWith(ApplicationComposer.class)
+public class EventTest {
+    @Module
+    @Classes(innerClassesAsBean = true)
+    public WebApp app() {
+        return new WebApp();
+    }
+
+    @RandomPort("http")
+    private int port;
+
+    @Configuration
+    public Properties config() {
+        return new PropertiesBuilder().p("listener", "new://Service?class-name=" + Observer.class.getName()).build();
+    }
+
+    @Test
+    public void run() {
+        assertNotNull(Observer.created);
+        assertNotNull(Observer.created.getServer());
+        assertNotNull(Observer.created.getServer().getEndpoint());
+    }
+
+    @AfterClass
+    public static void destroy() {
+        assertNotNull(Observer.destroyed);
+        assertNotNull(Observer.destroyed.getServer());
+        assertNotNull(Observer.destroyed.getServer().getEndpoint());
+    }
+
+    @WebService
+    public static class End {
+        public String get() {
+            return "end";
+        }
+    }
+
+    public static class Observer {
+        private static ServerCreated created;
+        private static ServerDestroyed destroyed;
+
+        public void created(@Observes final ServerCreated created) {
+            Observer.created = created;
+        }
+
+        public void destroyed(@Observes final ServerDestroyed destroyed) {
+            Observer.destroyed = destroyed;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/74dd0462/tck/cdi-embedded/src/test/resources/failing.xml
----------------------------------------------------------------------
diff --git a/tck/cdi-embedded/src/test/resources/failing.xml b/tck/cdi-embedded/src/test/resources/failing.xml
index 5ca42d2..ad0858d 100644
--- a/tck/cdi-embedded/src/test/resources/failing.xml
+++ b/tck/cdi-embedded/src/test/resources/failing.xml
@@ -26,7 +26,7 @@
     -Dopenejb.deploymentId.format={appId}/{ejbJarId}/{ejbName}
     -->
     <classes>
-      <class name="org.jboss.cdi.tck.tests.implementation.enterprise.newBean.NewEnterpriseBeanTest"
/>
+      <class name="org.jboss.cdi.tck.tests.context.conversation.ClientConversationContextTest"
/>
     </classes>
   </test>
 </suite>


Mime
View raw message