openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1765946 - in /openwebbeans/microwave/trunk: microwave-arquillian/src/main/java/org/apache/microwave/arquillian/ microwave-core/ microwave-core/src/main/java/org/apache/microwave/ microwave-gradle-plugin/src/main/java/org/apache/microwave/g...
Date Fri, 21 Oct 2016 08:32:33 GMT
Author: rmannibucau
Date: Fri Oct 21 08:32:33 2016
New Revision: 1765946

URL: http://svn.apache.org/viewvc?rev=1765946&view=rev
Log:
option to use or not the shutdown hooks

Modified:
    openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java
    openwebbeans/microwave/trunk/microwave-core/pom.xml
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
    openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
    openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
    openwebbeans/microwave/trunk/microwave-junit/src/main/java/org/apache/microwave/junit/MonoMicrowave.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java

Modified: openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java
(original)
+++ openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java
Fri Oct 21 08:32:33 2016
@@ -73,6 +73,7 @@ public class MicrowaveConfiguration impl
     private String realm;
     private boolean tomcatScanning = true;
     private boolean tomcatAutoSetup = true;
+    private boolean useShutdownHook = false /*arquillian*/;
 
     @Override
     public void validate() throws ConfigurationException {
@@ -476,4 +477,12 @@ public class MicrowaveConfiguration impl
     public void setRealm(final String realm) {
         this.realm = realm;
     }
+
+    public boolean isUseShutdownHook() {
+        return useShutdownHook;
+    }
+
+    public void setUseShutdownHook(final boolean useShutdownHook) {
+        this.useShutdownHook = useShutdownHook;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/pom.xml?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-core/pom.xml Fri Oct 21 08:32:33 2016
@@ -138,6 +138,14 @@
           <groupId>javax.annotation</groupId>
           <artifactId>javax.annotation-api</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>org.codehaus.woodstox</groupId>
+          <artifactId>woodstox-core-asl</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.ws.xmlschema</groupId>
+          <artifactId>xmlschema-core</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Fri Oct 21 08:32:33 2016
@@ -450,11 +450,13 @@ public class Microwave implements AutoCl
         } catch (final LifecycleException e) {
             throw new IllegalStateException(e);
         }
-        hook = new Thread(() -> {
-            hook = null; // prevent close to remove the hook which would throw an exception
-            close();
-        }, "microwave-stop-hook");
-        Runtime.getRuntime().addShutdownHook(hook);
+        if (configuration.isUseShutdownHook()) {
+            hook = new Thread(() -> {
+                hook = null; // prevent close to remove the hook which would throw an exception
+                close();
+            }, "microwave-stop-hook");
+            Runtime.getRuntime().addShutdownHook(hook);
+        }
         return this;
     }
 
@@ -722,6 +724,9 @@ public class Microwave implements AutoCl
         @CliOption(name = "tomcat-default-setup", description = "Add default servlet")
         private boolean tomcatAutoSetup = true;
 
+        @CliOption(name = "use-shutdown-hook", description = "Use shutdown hook to automatically
stop the container on Ctrl+C")
+        private boolean useShutdownHook = true;
+
         public Builder() { // load defaults
             loadFrom("microwave.properties");
         }
@@ -1080,7 +1085,7 @@ public class Microwave implements AutoCl
             configurationCustomizer.customize(this);
         }
 
-        public void loadFromProperties(final Properties config) {
+        public void loadFromProperties(final Properties config) { // TODO: parse @OptionCli
instead?
             // filtering properties with system properties or themself
             final StrSubstitutor strSubstitutor = new StrSubstitutor(new StrLookup<String>()
{
                 @Override
@@ -1213,6 +1218,10 @@ public class Microwave implements AutoCl
             if (tomcatAutoSetup != null) {
                 this.tomcatAutoSetup = Boolean.parseBoolean(tomcatAutoSetup);
             }
+            final String useShutdownHook = config.getProperty("useShutdownHook");
+            if (useShutdownHook != null) {
+                this.useShutdownHook = Boolean.parseBoolean(useShutdownHook);
+            }
             for (final String prop : config.stringPropertyNames()) {
                 if (prop.startsWith("properties.")) {
                     property(prop.substring("properties.".length()), config.getProperty(prop));
@@ -1279,6 +1288,19 @@ public class Microwave implements AutoCl
         public void setTomcatAutoSetup(final boolean tomcatAutoSetup) {
             this.tomcatAutoSetup = tomcatAutoSetup;
         }
+
+        public boolean isUseShutdownHook() {
+            return useShutdownHook;
+        }
+
+        public void setUseShutdownHook(final boolean useShutdownHook) {
+            this.useShutdownHook = useShutdownHook;
+        }
+
+        public Builder noShutdownHook() {
+            setUseShutdownHook(false);
+            return this;
+        }
     }
 
     public static class LoginConfigBuilder {

Modified: openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
(original)
+++ openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
Fri Oct 21 08:32:33 2016
@@ -32,7 +32,7 @@ public class MicrowaveExtension {
     private int httpsPort = 8443;
     private int stopPort = -1;
     private String host = "localhost";
-    protected String dir;
+    private String dir;
     private File serverXml;
     private boolean keepServerXmlAsThis;
     private Map<String, String> properties;
@@ -63,6 +63,15 @@ public class MicrowaveExtension {
     private boolean skip;
     private boolean jaxrsProviderSetup = true;
     private boolean loggingGlobalSetup = true;
+    private boolean useShutdownHook = true;
+
+    public boolean isUseShutdownHook() {
+        return useShutdownHook;
+    }
+
+    public void setUseShutdownHook(final boolean useShutdownHook) {
+        this.useShutdownHook = useShutdownHook;
+    }
 
     public Map<String, String> getCxfServletParams() {
         return cxfServletParams;

Modified: openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
(original)
+++ openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
Fri Oct 21 08:32:33 2016
@@ -193,6 +193,10 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
+    private boolean useShutdownHook = true;
+
+    @Input
+    @Optional
     private List<File> modules;
 
     @Input
@@ -787,4 +791,12 @@ public class MicrowaveTask extends Defau
     public void setTomcatAutoSetup(final boolean tomcatAutoSetup) {
         this.tomcatAutoSetup = tomcatAutoSetup;
     }
+
+    public boolean isUseShutdownHook() {
+        return useShutdownHook;
+    }
+
+    public void setUseShutdownHook(final boolean useShutdownHook) {
+        this.useShutdownHook = useShutdownHook;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-junit/src/main/java/org/apache/microwave/junit/MonoMicrowave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-junit/src/main/java/org/apache/microwave/junit/MonoMicrowave.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-junit/src/main/java/org/apache/microwave/junit/MonoMicrowave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-junit/src/main/java/org/apache/microwave/junit/MonoMicrowave.java
Fri Oct 21 08:32:33 2016
@@ -109,7 +109,7 @@ public class MonoMicrowave {
     }
 
     private static void doBoot() {
-        final Microwave.Builder configuration = new Microwave.Builder().randomHttpPort();
+        final Microwave.Builder configuration = new Microwave.Builder().randomHttpPort().noShutdownHook(/*the
rule does*/);
         StreamSupport.stream(ServiceLoader.load(Microwave.ConfigurationCustomizer.class).spliterator(),
false)
                 .forEach(c -> c.customize(configuration));
         CONFIGURATION.compareAndSet(null, configuration);

Modified: openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java?rev=1765946&r1=1765945&r2=1765946&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
(original)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
Fri Oct 21 08:32:33 2016
@@ -157,6 +157,9 @@ public class MicrowaveRunMojo extends Ab
     @Parameter(property = "microwave.logging-global-setup", defaultValue = "true")
     private boolean loggingGlobalSetup;
 
+    @Parameter(property = "microwave.shutdown-hook", defaultValue = "true")
+    private boolean useShutdownHook;
+
     @Parameter
     private List<String> jsCustomizers;
 



Mime
View raw message