openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1862453 - in /openwebbeans/meecrowave/trunk/meecrowave-core/src: main/java/org/apache/meecrowave/Meecrowave.java main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
Date Wed, 03 Jul 2019 08:21:52 GMT
Author: rmannibucau
Date: Wed Jul  3 08:21:52 2019
New Revision: 1862453

URL: http://svn.apache.org/viewvc?rev=1862453&view=rev
Log:
MEECROWAVE-201 ensure client and server buses can be shared

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java
    openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java?rev=1862453&r1=1862452&r2=1862453&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
Wed Jul  3 08:21:52 2019
@@ -276,6 +276,9 @@ public class Meecrowave implements AutoC
 
         final AtomicReference<Runnable> releaseSCI = new AtomicReference<>();
         final ServletContainerInitializer meecrowaveInitializer = (c, ctx1) -> {
+            ctx1.setAttribute("meecrowave.configuration", configuration);
+            ctx1.setAttribute("meecrowave.instance", Meecrowave.this);
+
             new OWBAutoSetup().onStartup(c, ctx1);
             if (Cxfs.IS_PRESENT) {
                 new CxfCdiAutoSetup().onStartup(c, ctx1);
@@ -355,8 +358,6 @@ public class Meecrowave implements AutoC
                     ctx.getResources().setCachingAllowed(configuration.webResourceCached);
                     break;
                 case Lifecycle.BEFORE_INIT_EVENT:
-                    ctx.getServletContext().setAttribute("meecrowave.configuration", configuration);
-                    ctx.getServletContext().setAttribute("meecrowave.instance", Meecrowave.this);
                     if (configuration.loginConfig != null) {
                         ctx.setLoginConfig(configuration.loginConfig.build());
                     }
@@ -808,6 +809,10 @@ public class Meecrowave implements AutoC
         }
     }
 
+    public ConfigurableBus getClientBus() {
+        return clientBus;
+    }
+
     /**
      * Store away the current system property for restoring it later
      * during shutdown.

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java?rev=1862453&r1=1862452&r2=1862453&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/cxf/MeecrowaveBus.java
Wed Jul  3 08:21:52 2019
@@ -39,23 +39,32 @@ import org.apache.meecrowave.Meecrowave;
 @Typed({MeecrowaveBus.class, Bus.class})
 @ApplicationScoped
 public class MeecrowaveBus implements Bus, ClassUnwrapper {
-    private final ConfigurableBus delegate = new ConfigurableBus();
+    private final ConfigurableBus delegate;
 
     protected MeecrowaveBus() {
-        // no-op: for proxies
+        delegate= null;
     }
 
     @Inject
     public MeecrowaveBus(final ServletContext context) {
-        setProperty(ClassUnwrapper.class.getName(), this);
-
         final ClassLoader appLoader = context.getClassLoader();
-        setExtension(appLoader, ClassLoader.class); // ServletController locks on the classloader
otherwise
 
+        final Meecrowave meecrowave = Meecrowave.class.cast(context.getAttribute("meecrowave.instance"));
         final Meecrowave.Builder builder = Meecrowave.Builder.class.cast(context.getAttribute("meecrowave.configuration"));
-        if (builder != null && builder.isJaxrsProviderSetup()) {
-            delegate.initProviders(builder, appLoader);
+        if (meecrowave.getClientBus() == null) {
+            delegate = new ConfigurableBus();
+            if (builder != null && builder.isJaxrsProviderSetup()) {
+                delegate.initProviders(builder, appLoader);
+            }
+        } else {
+            delegate = meecrowave.getClientBus();
+            if (builder != null && !builder.isInitializeClientBus() && builder.isJaxrsProviderSetup())
{
+                delegate.initProviders(builder, appLoader);
+            }
         }
+
+        setProperty(ClassUnwrapper.class.getName(), this);
+        setExtension(appLoader, ClassLoader.class); // ServletController locks on the classloader
otherwise
     }
 
 

Modified: openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java?rev=1862453&r1=1862452&r2=1862453&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-core/src/test/java/org/apache/meecrowave/johnzon/JohnzonBufferTest.java
Wed Jul  3 08:21:52 2019
@@ -40,7 +40,7 @@ public class JohnzonBufferTest {
                         .request(MediaType.APPLICATION_JSON)
                         .get(String.class);
                 assertEquals("{\"isbn\":\"dummyisbn\"}", jsonResponse);
-                //X TODO work in progress! assertEquals(1, DebugJohnzonBufferStrategy.getCounter());
+                assertEquals(3, DebugJohnzonBufferStrategy.getCounter()); // reader fact
-> parser fact (2 buffers) + writer -> generator (1 buffer)
             } finally {
                 client.close();
             }



Mime
View raw message