Author: rmannibucau
Date: Sun Feb 18 16:59:30 2018
New Revision: 1824676

URL: http://svn.apache.org/viewvc?rev=1824676&view=rev
Log:
creating a configurable bus set the global default bus so do it lazily + reset 
it after all cleanup callacbks to avoid to create another default without our 
providers

Modified:
    
openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.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=1824676&r1=1824675&r2=1824676&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
 Sun Feb 18 16:59:30 2018
@@ -156,7 +156,6 @@ public class Meecrowave implements AutoC
     public Meecrowave(final Builder builder) {
         this.configuration = builder;
         this.ownedTempDir = new File(configuration.tempDir, "meecrowave_" + 
System.nanoTime());
-        this.clientBus = new ConfigurableBus();
     }
 
     public Builder getConfiguration() {
@@ -653,9 +652,9 @@ public class Meecrowave implements AutoC
 
 
         if (configuration.initializeClientBus && 
BusFactory.getDefaultBus(false) == null) {
+            clientBus = new ConfigurableBus();
             clientBus.initProviders(configuration,
                     
ofNullable(Thread.currentThread().getContextClassLoader()).orElseGet(ClassLoader::getSystemClassLoader));
-            BusFactory.setDefaultBus(clientBus);
         }
 
         try {
@@ -867,9 +866,6 @@ public class Meecrowave implements AutoC
                 new 
LogFacade(Meecrowave.class.getName()).error(e.getMessage(), e);
             }
         }
-        if (BusFactory.getDefaultBus(false) == clientBus) {
-            BusFactory.setDefaultBus(null);
-        }
         try {
             contexts.values().forEach(Runnable::run);
         } finally {
@@ -879,6 +875,9 @@ public class Meecrowave implements AutoC
             } catch (final LifecycleException e) {
                 throw new IllegalStateException(e);
             } finally {
+                if (BusFactory.getDefaultBus(false) == clientBus) { // after 
if runnables or listeners trigger CXF
+                    BusFactory.setDefaultBus(null);
+                }
                 tomcat = null; // ensure we can call close() N times and not 
have side effects
                 contexts.clear();
                 if (clearCatalinaSystemProperties) {
@@ -1240,7 +1239,7 @@ public class Meecrowave implements AutoC
         private String defaultSSLHostConfigName;
 
         @CliOption(name = "cxf-initialize-client-bus", description = "Should 
the client bus be set. If false the server one will likely be reused.")
-        private boolean initializeClientBus;
+        private boolean initializeClientBus = true;
 
         private final Map<Class<?>, Object> extensions = new HashMap<>();
         private final Collection<Consumer<Tomcat>> instanceCustomizers = new 
ArrayList<>();


Reply via email to