openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1853377 - in /openwebbeans/meecrowave/trunk: meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/ meecrowave-core/src/main/java/org/apache/meecrowave/ meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/ me...
Date Mon, 11 Feb 2019 14:15:22 GMT
Author: rmannibucau
Date: Mon Feb 11 14:15:22 2019
New Revision: 1853377

URL: http://svn.apache.org/viewvc?rev=1853377&view=rev
Log:
MEECROWAVE-182 MEECROWAVE-181 antijarlocking and global context customizers

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/MeecrowaveConfiguration.java
    openwebbeans/meecrowave/trunk/meecrowave-core/src/main/java/org/apache/meecrowave/Meecrowave.java
    openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveExtension.java
    openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveTask.java
    openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveRunMojo.java

Modified: openwebbeans/meecrowave/trunk/meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/MeecrowaveConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/MeecrowaveConfiguration.java?rev=1853377&r1=1853376&r2=1853377&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/MeecrowaveConfiguration.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-arquillian/src/main/java/org/apache/meecrowave/arquillian/MeecrowaveConfiguration.java
Mon Feb 11 14:15:22 2019
@@ -109,6 +109,7 @@ public class MeecrowaveConfiguration imp
     private Integer webSessionTimeout;
     private String webSessionCookieConfig;
     private boolean tomcatJspDevelopment;
+    private boolean antiJarLocking;
 
     // configurable cause when set to Local arquillian bypass some protocol configuration
cause of container default
     private String arquillianProtocol = "Servlet 3.1";
@@ -811,4 +812,12 @@ public class MeecrowaveConfiguration imp
     public void setWebSessionCookieConfig(final String webSessionCookieConfig) {
         this.webSessionCookieConfig = webSessionCookieConfig;
     }
+
+    public boolean isAntiJarLocking() {
+        return antiJarLocking;
+    }
+
+    public void setAntiJarLocking(final boolean antiJarLocking) {
+        this.antiJarLocking = antiJarLocking;
+    }
 }

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=1853377&r1=1853376&r2=1853377&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
Mon Feb 11 14:15:22 2019
@@ -51,6 +51,7 @@ import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Base64;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -97,7 +98,6 @@ import org.apache.catalina.core.Standard
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.session.StandardManager;
 import org.apache.catalina.startup.Catalina;
-import org.apache.meecrowave.tomcat.MeecrowaveContextConfig;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.coyote.http2.Http2Protocol;
 import org.apache.meecrowave.api.StartListening;
@@ -118,6 +118,7 @@ import org.apache.meecrowave.runner.cli.
 import org.apache.meecrowave.service.ValueTransformer;
 import org.apache.meecrowave.tomcat.CDIInstanceManager;
 import org.apache.meecrowave.tomcat.LoggingAccessLogPattern;
+import org.apache.meecrowave.tomcat.MeecrowaveContextConfig;
 import org.apache.meecrowave.tomcat.NoDescriptorRegistry;
 import org.apache.meecrowave.tomcat.OWBJarScanner;
 import org.apache.meecrowave.tomcat.ProvidedLoader;
@@ -190,7 +191,11 @@ public class Meecrowave implements AutoC
         final ProvidedLoader loader = new ProvidedLoader(classLoader, configuration.isTomcatWrapLoader());
         final Consumer<Context> builtInCustomizer = c -> {
             c.setLoader(loader);
+            if (configuration.antiJarLocking && StandardContext.class.isInstance(c))
{
+                StandardContext.class.cast(c).setAntiResourceLocking(true);
+            }
             configuration.getInitializers().forEach(i -> c.addServletContainerInitializer(i,
emptySet()));
+            configuration.getGlobalContextConfigurers().forEach(it -> it.accept(c));
         };
         return deployWebapp(new DeploymentMeta(meta.context, meta.docBase, ofNullable(meta.consumer).map(c
-> (Consumer<Context>) ctx -> {
             builtInCustomizer.accept(ctx);
@@ -719,6 +724,14 @@ public class Meecrowave implements AutoC
                 .forEach(c -> c.accept(tomcat));
         configuration.instanceCustomizers.forEach(c -> c.accept(tomcat));
 
+        StreamSupport.stream(ServiceLoader.load(Meecrowave.ContextCustomizer.class).spliterator(),
false)
+                .peek(i -> {
+                    if (MeecrowaveAwareContextCustomizer.class.isInstance(i)) {
+                        MeecrowaveAwareContextCustomizer.class.cast(i).setMeecrowave(this);
+                    }
+                })
+                .forEach(configuration::addGlobalContextCustomizer);
+
         beforeStart();
 
 
@@ -1381,6 +1394,12 @@ public class Meecrowave implements AutoC
         @CliOption(name = "servlet-container-initializer", description = "ServletContainerInitializer
instances.")
         private Collection<ServletContainerInitializer> initializers = new ArrayList<>();
 
+        @CliOption(name = "tomcat-antijarlocking", description = "Should anti-jar-locking
be activated on StandardContext.")
+        private boolean antiJarLocking;
+
+        @CliOption(name = "tomcat-context-configurer", description = "Configurers for all
webapps. The Consumer<Context> instances will be applied to all deployments.")
+        private Collection<Consumer<Context>> contextConfigurers;
+
         public Builder() { // load defaults
             extensions.put(ValueTransformers.class, new ValueTransformers());
             StreamSupport.stream(ServiceLoader.load(Meecrowave.ConfigurationCustomizer.class).spliterator(),
false)
@@ -1400,6 +1419,18 @@ public class Meecrowave implements AutoC
             }));
         }
 
+        public boolean isAntiJarLocking() {
+            return antiJarLocking;
+        }
+
+        public void setAntiJarLocking(final boolean antiJarLocking) {
+            this.antiJarLocking = antiJarLocking;
+        }
+
+        public Collection<Consumer<Context>> getGlobalContextConfigurers() {
+            return ofNullable(contextConfigurers).orElseGet(Collections::emptySet);
+        }
+
         public boolean isTomcatJspDevelopment() {
             return tomcatJspDevelopment;
         }
@@ -2116,6 +2147,13 @@ public class Meecrowave implements AutoC
             configurationCustomizer.accept(this);
         }
 
+        public void addGlobalContextCustomizer(final Consumer<Context> contextConfigurer)
{
+            if (contextConfigurers == null) {
+                contextConfigurers = new ArrayList<>();
+            }
+            contextConfigurers.add(contextConfigurer);
+        }
+
         public void addServletContextInitializer(final ServletContainerInitializer initializer)
{
             initializers.add(initializer);
         }
@@ -2654,6 +2692,13 @@ public class Meecrowave implements AutoC
     public interface InstanceCustomizer extends Consumer<Tomcat> {
     }
 
+    public interface ContextCustomizer extends Consumer<Context> {
+    }
+
+    public interface MeecrowaveAwareContextCustomizer extends ContextCustomizer {
+        void setMeecrowave(Meecrowave meecrowave);
+    }
+
     // since it is too early to have CDI and lookup the instance we must set it manually
     public interface MeecrowaveAwareInstanceCustomizer extends InstanceCustomizer {
         void setMeecrowave(Meecrowave meecrowave);

Modified: openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveExtension.java?rev=1853377&r1=1853376&r2=1853377&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveExtension.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveExtension.java
Mon Feb 11 14:15:22 2019
@@ -100,6 +100,15 @@ public class MeecrowaveExtension {
     private Integer webSessionTimeout;
     private String webSessionCookieConfig;
     private boolean tomcatJspDevelopment;
+    private boolean antiJarLocking;
+
+    public boolean isAntiJarLocking() {
+        return antiJarLocking;
+    }
+
+    public void setAntiJarLocking(final boolean antiJarLocking) {
+        this.antiJarLocking = antiJarLocking;
+    }
 
     public boolean isTomcatJspDevelopment() {
         return tomcatJspDevelopment;

Modified: openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveTask.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveTask.java?rev=1853377&r1=1853376&r2=1853377&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveTask.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-gradle-plugin/src/main/java/org/apache/meecrowave/gradle/MeecrowaveTask.java
Mon Feb 11 14:15:22 2019
@@ -246,6 +246,10 @@ public class MeecrowaveTask extends Defa
 
     @Input
     @Optional
+    private boolean antiJarLocking = true;
+
+    @Input
+    @Optional
     private List<File> modules;
 
     @Input
@@ -1232,4 +1236,12 @@ public class MeecrowaveTask extends Defa
     public void setTomcatJspDevelopment(final boolean tomcatJspDevelopment) {
         this.tomcatJspDevelopment = tomcatJspDevelopment;
     }
+
+    public boolean isAntiJarLocking() {
+        return antiJarLocking;
+    }
+
+    public void setAntiJarLocking(final boolean antiJarLocking) {
+        this.antiJarLocking = antiJarLocking;
+    }
 }

Modified: openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveRunMojo.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveRunMojo.java?rev=1853377&r1=1853376&r2=1853377&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveRunMojo.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveRunMojo.java
Mon Feb 11 14:15:22 2019
@@ -91,6 +91,9 @@ public class MeecrowaveRunMojo extends A
     @Parameter(property = "meecrowave.useTomcatDefaults", defaultValue = "true")
     private boolean useTomcatDefaults;
 
+    @Parameter(property = "meecrowave.antiJarLocking", defaultValue = "false")
+    private boolean antiJarLocking;
+
     @Parameter
     private Map<String, String> properties;
 



Mime
View raw message