openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1766443 - in /openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf: CxfCdiAutoSetup.java MicrowaveBus.java
Date Mon, 24 Oct 2016 20:40:24 GMT
Author: rmannibucau
Date: Mon Oct 24 20:40:24 2016
New Revision: 1766443

URL: http://svn.apache.org/viewvc?rev=1766443&view=rev
Log:
simpler setup for openjpa bus now we have our own bean and config in cdi

Modified:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/MicrowaveBus.java

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java?rev=1766443&r1=1766442&r2=1766443&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/CxfCdiAutoSetup.java
Mon Oct 24 20:40:24 2016
@@ -19,21 +19,15 @@
 package org.apache.microwave.cxf;
 
 import org.apache.cxf.cdi.CXFCdiServlet;
-import org.apache.cxf.common.util.ClassHelper;
-import org.apache.cxf.common.util.ClassUnwrapper;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 import org.apache.cxf.jaxrs.model.ApplicationInfo;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.MethodDispatcher;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
 import org.apache.cxf.transport.ChainInitiationObserver;
 import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.servlet.ServletDestination;
-import org.apache.johnzon.jaxrs.DelegateProvider;
-import org.apache.johnzon.jaxrs.JohnzonProvider;
-import org.apache.johnzon.jaxrs.JsrProvider;
 import org.apache.microwave.Microwave;
 import org.apache.microwave.logging.tomcat.LogFacade;
 
@@ -64,7 +58,6 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Stream;
 
-import static java.util.Arrays.asList;
 import static java.util.Optional.ofNullable;
 
 // this look a bit complicated but it just:
@@ -76,7 +69,7 @@ public class CxfCdiAutoSetup implements
     @Override
     public void onStartup(final Set<Class<?>> c, final ServletContext ctx) throws
ServletException {
         final Microwave.Builder builder = Microwave.Builder.class.cast(ctx.getAttribute("microwave.configuration"));
-        final MicrowaveCXFCdiServlet delegate = new MicrowaveCXFCdiServlet(!builder.isJaxrsProviderSetup());
+        final MicrowaveCXFCdiServlet delegate = new MicrowaveCXFCdiServlet();
         final FilterRegistration.Dynamic jaxrs = ctx.addFilter(NAME, new Filter() {
             private final String servletPath = builder.getJaxrsMapping().endsWith("/*") ?
                     builder.getJaxrsMapping().substring(0, builder.getJaxrsMapping().length()
- 2) : builder.getJaxrsMapping();
@@ -308,38 +301,8 @@ public class CxfCdiAutoSetup implements
     }
 
     private static class MicrowaveCXFCdiServlet extends CXFCdiServlet {
-        private final boolean noProviderSetup;
         private String[] prefixes;
 
-        private MicrowaveCXFCdiServlet(final boolean noProviderSetup) {
-            this.noProviderSetup = noProviderSetup;
-        }
-
-        @Override
-        protected void loadBus(final ServletConfig servletConfig) {
-            super.loadBus(servletConfig);
-
-            if (noProviderSetup) {
-                return;
-            }
-
-            final List<DelegateProvider<?>> providers = asList(new JohnzonProvider<>(),
new JsrProvider());
-
-            // client
-            if (bus.getProperty("org.apache.cxf.jaxrs.bus.providers") == null) {
-                bus.setProperty("skip.default.json.provider.registration", "true");
-                bus.setProperty("org.apache.cxf.jaxrs.bus.providers", providers);
-            }
-
-            // server
-            getDestinationRegistryFromBus().getDestinations()
-                    .forEach(d -> {
-                        final ChainInitiationObserver observer = ChainInitiationObserver.class.cast(d.getMessageObserver());
-                        final ServerProviderFactory providerFactory = ServerProviderFactory.class.cast(observer.getEndpoint().get(ServerProviderFactory.class.getName()));
-                        providerFactory.setUserProviders(providers);
-                    });
-        }
-
         @Override
         public void init(final ServletConfig sc) throws ServletException {
             super.init(sc);

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/MicrowaveBus.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/MicrowaveBus.java?rev=1766443&r1=1766442&r2=1766443&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/MicrowaveBus.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/cxf/MicrowaveBus.java
Mon Oct 24 20:40:24 2016
@@ -2,24 +2,36 @@ package org.apache.microwave.cxf;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.common.util.ClassUnwrapper;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Message;
+import org.apache.johnzon.jaxrs.DelegateProvider;
+import org.apache.johnzon.jaxrs.JohnzonProvider;
+import org.apache.johnzon.jaxrs.JsrProvider;
+import org.apache.microwave.Microwave;
 
 import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
 import javax.inject.Named;
+import javax.servlet.ServletContext;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import static java.util.Arrays.asList;
+
 @Named("cxf")
 @ApplicationScoped
 public class MicrowaveBus implements Bus {
     private final Bus delegate = new ExtensionManagerBus();
 
-    public MicrowaveBus() {
+    protected MicrowaveBus() {
+        // no-op: for proxies
+    }
+
+    @Inject
+    public MicrowaveBus(final ServletContext context) {
         setProperty(ClassUnwrapper.class.getName(), (ClassUnwrapper) o -> {
             final Class<?> aClass = o.getClass();
             if (aClass.getName().contains("$$")) {
@@ -27,6 +39,17 @@ public class MicrowaveBus implements Bus
             }
             return aClass;
         });
+
+        final Microwave.Builder builder = Microwave.Builder.class.cast(context.getAttribute("microwave.configuration"));
+        if (builder.isJaxrsProviderSetup()) {
+            final List<DelegateProvider<?>> providers = asList(new JohnzonProvider<>(),
new JsrProvider());
+
+            // client
+            if (getProperty("org.apache.cxf.jaxrs.bus.providers") == null) {
+                setProperty("skip.default.json.provider.registration", "true");
+                setProperty("org.apache.cxf.jaxrs.bus.providers", providers);
+            }
+        }
     }
 
     @Override



Mime
View raw message