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-1444 basic cxf rs events
Date Fri, 14 Nov 2014 16:24:11 GMT
Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x 6a3b67c42 -> 3c20f2fea


TOMEE-1444 basic cxf rs events


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

Branch: refs/heads/tomee-1.7.x
Commit: 3c20f2fea3347a8992c16cb901d47af57ab31315
Parents: 6a3b67c
Author: Romain Manni-Bucau <rmannibucau@apache.org>
Authored: Fri Nov 14 17:24:02 2014 +0100
Committer: Romain Manni-Bucau <rmannibucau@apache.org>
Committed: Fri Nov 14 17:24:02 2014 +0100

----------------------------------------------------------------------
 .../openejb/monitoring/DynamicMBeanWrapper.java |  2 +-
 .../server/cxf/rs/CxfRsHttpListener.java        | 29 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/3c20f2fe/container/openejb-core/src/main/java/org/apache/openejb/monitoring/DynamicMBeanWrapper.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/monitoring/DynamicMBeanWrapper.java
b/container/openejb-core/src/main/java/org/apache/openejb/monitoring/DynamicMBeanWrapper.java
index d4d113c..459c0a3 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/monitoring/DynamicMBeanWrapper.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/monitoring/DynamicMBeanWrapper.java
@@ -491,7 +491,7 @@ public class DynamicMBeanWrapper implements DynamicMBean, MBeanRegistration
{
     private static class AnnotationHandler implements InvocationHandler {
         private final Object delegate;
 
-        public AnnotationHandler(final Object javaxAnnotation) {
+        public AnnotationHandler(final  Object javaxAnnotation) {
             delegate = javaxAnnotation;
         }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/3c20f2fe/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
index c30888a..ad1d427 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
@@ -52,12 +52,16 @@ import org.apache.openejb.api.jmx.ManagedOperation;
 import org.apache.openejb.assembler.classic.ServiceInfo;
 import org.apache.openejb.assembler.classic.util.ServiceConfiguration;
 import org.apache.openejb.assembler.classic.util.ServiceInfos;
+import org.apache.openejb.core.WebContext;
 import org.apache.openejb.dyni.DynamicSubclass;
 import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.monitoring.LocalMBeanServer;
 import org.apache.openejb.monitoring.ObjectNameBuilder;
 import org.apache.openejb.rest.ThreadLocalContextManager;
+import org.apache.openejb.server.cxf.rs.event.ExtensionProviderRegistration;
+import org.apache.openejb.server.cxf.rs.event.ServerCreated;
+import org.apache.openejb.server.cxf.rs.event.ServerDestroyed;
 import org.apache.openejb.server.cxf.transport.util.CxfUtil;
 import org.apache.openejb.server.httpd.HttpRequest;
 import org.apache.openejb.server.httpd.HttpRequestImpl;
@@ -359,6 +363,7 @@ public class CxfRsHttpListener implements RsHttpListener {
 
             server = factory.create();
             destination = (AbstractHTTPDestination) server.getDestination();
+            fireServerCreated(oldLoader);
         } finally {
             if (oldLoader != null) {
                 CxfUtil.clearBusLoader(oldLoader);
@@ -366,6 +371,26 @@ public class CxfRsHttpListener implements RsHttpListener {
         }
     }
 
+    private void fireServerCreated(final ClassLoader oldLoader) {
+        final Object ctx = AppFinder.findAppContextOrWeb(oldLoader, new AppFinder.Transformer<Object>()
{
+            @Override
+            public Object from(final AppContext appCtx) {
+                return appCtx;
+            }
+
+            @Override
+            public Object from(final WebContext webCtx) {
+                return webCtx;
+            }
+        });
+        final AppContext appCtx = AppContext.class.isInstance(ctx) ? AppContext.class.cast(ctx)
: WebContext.class.cast(ctx).getAppContext();
+        WebContext webContext = appCtx == ctx ? null : WebContext.class.cast(ctx);
+        if (webContext == null && appCtx.getWebContexts().size() == 1 &&
appCtx.getWebContexts().get(0).getClassLoader() == oldLoader) {
+            webContext = appCtx.getWebContexts().get(0);
+        }
+        SystemInstance.get().fireEvent(new ServerCreated(server, appCtx, webContext));
+    }
+
     private List<Object> providers(final Collection<ServiceInfo> services, final
Collection<Object> additionalProviders, final WebBeansContext ctx) {
         final List<Object> instances = new ArrayList<Object>();
         final BeanManagerImpl bm = ctx == null ? null : ctx.getBeanManagerImpl();
@@ -446,6 +471,7 @@ public class CxfRsHttpListener implements RsHttpListener {
         Thread.currentThread().setContextClassLoader(CxfUtil.initBusLoader());
         try {
             server.destroy();
+            SystemInstance.get().fireEvent(new ServerDestroyed(server));
         } catch (final RuntimeException ise) {
             LOGGER.warning("Can't stop correctly the endpoint " + server);
             if (LOGGER.isDebugEnabled()) {
@@ -517,6 +543,7 @@ public class CxfRsHttpListener implements RsHttpListener {
             }
             try {
                 server = factory.create();
+                fireServerCreated(oldLoader);
             } finally {
                 try {
                     SERVER_IMPL_LOGGER.setLevel(level);
@@ -767,6 +794,8 @@ public class CxfRsHttpListener implements RsHttpListener {
             addMandatoryProviders(providers);
         }
 
+        SystemInstance.get().fireEvent(new ExtensionProviderRegistration(providers));
+
         LOGGER.info("Using providers:");
         for (final Object provider : providers) {
             LOGGER.info("     " + provider);


Mime
View raw message