openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1765889 - in /openwebbeans/microwave/trunk: microwave-arquillian/src/main/java/org/apache/microwave/arquillian/ microwave-core/src/main/java/org/apache/catalina/startup/ microwave-core/src/main/java/org/apache/microwave/ microwave-core/src...
Date Thu, 20 Oct 2016 21:33:45 GMT
Author: rmannibucau
Date: Thu Oct 20 21:33:45 2016
New Revision: 1765889

URL: http://svn.apache.org/viewvc?rev=1765889&view=rev
Log:
activating tomcat scanning per default

Added:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/CDIInstanceManager.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/OWBJarScanner.java
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/SomeFilter.java
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherEndpoint.class
  (with props)
    openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherFilter.class
  (with props)
Modified:
    openwebbeans/microwave/trunk/microwave-arquillian/src/main/java/org/apache/microwave/arquillian/MicrowaveConfiguration.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/catalina/startup/MicrowaveContextConfig.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/BundleMetadataDiscovery.java
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.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-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=1765889&r1=1765888&r2=1765889&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
Thu Oct 20 21:33:45 2016
@@ -67,6 +67,7 @@ public class MicrowaveConfiguration impl
     private boolean loggingGlobalSetup = true;
     private String users;
     private String roles;
+    private String cxfServletParams;
     private String loginConfig;
     private String securityConstraints;
     private String realm;
@@ -80,7 +81,7 @@ public class MicrowaveConfiguration impl
         final Microwave.Builder builder = new Microwave.Builder();
         for (final Field field : MicrowaveConfiguration.class.getDeclaredFields()) {
             final String name = field.getName();
-            if ("users".equals(name) || "roles".equals(name)
+            if ("users".equals(name) || "roles".equals(name) || "cxfServletParams".equals(name)
                     || "loginConfig".equals(name) || "securityConstraints".equals(name)
                     || "realm".equals(name)) {
                 continue; // specific syntax
@@ -134,6 +135,16 @@ public class MicrowaveConfiguration impl
             }};
             builder.setRoles(properties.stringPropertyNames().stream().collect(toMap(identity(),
properties::getProperty)));
         }
+        if (cxfServletParams != null) {
+            final Properties properties = new Properties() {{
+                try {
+                    load(new ByteArrayInputStream(cxfServletParams.getBytes(StandardCharsets.UTF_8)));
+                } catch (final IOException e) {
+                    throw new IllegalStateException(e);
+                }
+            }};
+            builder.setCxfServletParams(properties.stringPropertyNames().stream().collect(toMap(identity(),
properties::getProperty)));
+        }
 
         // for other not simple type use the Cli syntax
         final ClassLoader loader = Thread.currentThread().getContextClassLoader();

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/catalina/startup/MicrowaveContextConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/catalina/startup/MicrowaveContextConfig.java?rev=1765889&r1=1765888&r2=1765889&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/catalina/startup/MicrowaveContextConfig.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/catalina/startup/MicrowaveContextConfig.java
Thu Oct 20 21:33:45 2016
@@ -18,24 +18,88 @@
  */
 package org.apache.catalina.startup;
 
+import org.apache.catalina.WebResource;
 import org.apache.microwave.Microwave;
+import org.apache.microwave.logging.tomcat.LogFacade;
+import org.apache.microwave.openwebbeans.BundleMetadataDiscovery;
 import org.apache.tomcat.util.descriptor.web.WebXml;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.corespi.scanner.xbean.CdiArchive;
 
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebListener;
+import javax.servlet.annotation.WebServlet;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Modifier;
 import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.stream.Stream;
 
 public class MicrowaveContextConfig extends ContextConfig {
     private final Microwave.Builder configuration;
+    private final Map<String, Collection<Class<?>>> webClasses = new HashMap<>();
 
     public MicrowaveContextConfig(final Microwave.Builder configuration) {
         this.configuration = configuration;
     }
 
     @Override
+    protected void webConfig() {
+        // eagerly start CDI to scan only once and not twice (tomcat+CDI)
+        final ClassLoader loader = context.getLoader().getClassLoader(); // should already
be started at that point
+        final Thread thread = Thread.currentThread();
+        final ClassLoader old = thread.getContextClassLoader();
+        thread.setContextClassLoader(loader);
+        try {
+            final BundleMetadataDiscovery scannerService = BundleMetadataDiscovery.class.cast(WebBeansContext.getInstance().getScannerService());
+            scannerService.scan();
+            final CdiArchive archive = CdiArchive.class.cast(scannerService.getFinder().getArchive());
+            Stream.of(WebServlet.class, WebFilter.class, WebListener.class)
+                    .forEach(marker -> scannerService.getFinder().findAnnotatedClasses(marker).stream()
+                            .filter(c -> !Modifier.isAbstract(c.getModifiers()) &&
Modifier.isPublic(c.getModifiers()))
+                            .forEach(webComponent -> webClasses.computeIfAbsent(
+                                    archive.classesByUrl().entrySet().stream()
+                                            .filter(e -> e.getValue().getClassNames().contains(webComponent.getName()))
+                                            .findFirst().get().getKey(), k -> new HashSet<>())
+                                    .add(webComponent)));
+        } finally {
+            thread.setContextClassLoader(old);
+        }
+        try {
+            super.webConfig();
+        } finally {
+            webClasses.clear();
+        }
+    }
+
+    @Override
+    protected void processAnnotationsWebResource(final WebResource webResource, final WebXml
fragment,
+                                                 final boolean handlesTypesOnly,
+                                                 final Map<String, JavaClassCacheEntry>
javaClassCache) {
+        if (configuration.isTomcatScanning()) {
+            super.processAnnotationsWebResource(webResource, fragment, handlesTypesOnly,
javaClassCache);
+        }
+    }
+
+    @Override
     protected void processAnnotationsUrl(final URL url, final WebXml fragment, final boolean
handlesTypesOnly,
                                          final Map<String, JavaClassCacheEntry> javaClassCache)
{
         if (configuration.isTomcatScanning()) {
-            super.processAnnotationsUrl(url, fragment, handlesTypesOnly, javaClassCache);
+            final Collection<Class<?>> classes = webClasses.remove(url.toExternalForm());
+            if (classes != null && !classes.isEmpty()) {
+                final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+                classes.forEach(c -> {
+                    try (final InputStream stream = loader.getResourceAsStream(c.getName().replace('.',
'/') + ".class")) {
+                        super.processAnnotationsStream(stream, fragment, handlesTypesOnly,
javaClassCache);
+                    } catch (final IOException e) {
+                        new LogFacade(MicrowaveContextConfig.class.getName()).error("Can't
parse " + c);
+                    }
+                });
+            }
         }
     }
 }

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=1765889&r1=1765888&r2=1765889&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
Thu Oct 20 21:33:45 2016
@@ -36,11 +36,11 @@ import org.apache.catalina.session.Stand
 import org.apache.catalina.startup.Catalina;
 import org.apache.catalina.startup.MicrowaveContextConfig;
 import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.text.StrLookup;
 import org.apache.commons.lang3.text.StrSubstitutor;
 import org.apache.coyote.http2.Http2Protocol;
-import org.apache.cxf.helpers.FileUtils;
 import org.apache.microwave.cxf.CxfCdiAutoSetup;
 import org.apache.microwave.logging.jul.Log4j2Logger;
 import org.apache.microwave.logging.openwebbeans.Log4j2LoggerFactory;
@@ -48,6 +48,8 @@ import org.apache.microwave.logging.tomc
 import org.apache.microwave.logging.tomcat.LogFacade;
 import org.apache.microwave.openwebbeans.OWBAutoSetup;
 import org.apache.microwave.runner.cli.CliOption;
+import org.apache.microwave.tomcat.CDIInstanceManager;
+import org.apache.microwave.tomcat.OWBJarScanner;
 import org.apache.microwave.tomcat.ProvidedLoader;
 import org.apache.tomcat.util.descriptor.web.LoginConfig;
 import org.apache.tomcat.util.descriptor.web.SecurityCollection;
@@ -79,6 +81,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.TreeMap;
 import java.util.function.Consumer;
+import java.util.stream.Stream;
 
 import static java.util.Collections.emptySet;
 import static java.util.Optional.ofNullable;
@@ -115,7 +118,11 @@ public class Microwave implements AutoCl
 
     public Microwave deployClasspath(final DeploymentMeta meta) {
         final File dir = new File(configuration.tempDir, "classpath/fake-" + meta.context.replace("/",
""));
-        FileUtils.mkDir(dir);
+        try {
+            FileUtils.forceMkdir(dir);
+        } catch (final IOException e) {
+            throw new IllegalArgumentException(e);
+        }
         final Consumer<Context> builtInCustomizer = c -> c.setLoader(new ProvidedLoader(Thread.currentThread().getContextClassLoader()));
         return deployWebapp(new DeploymentMeta(meta.context, ofNullable(meta.consumer).map(c
-> (Consumer<Context>) ctx -> {
             builtInCustomizer.accept(ctx);
@@ -155,6 +162,8 @@ public class Microwave implements AutoCl
         final StandardContext ctx = new StandardContext();
         ctx.setPath(meta.context);
         ctx.setName(meta.context);
+        ctx.setJarScanner(new OWBJarScanner());
+        ctx.setInstanceManager(new CDIInstanceManager());
         try {
             ctx.setDocBase(warOrDir.getCanonicalPath());
         } catch (final IOException e) {
@@ -244,12 +253,7 @@ public class Microwave implements AutoCl
         }
 
         { // setup
-            base = new File(getBaseDir());
-            if (base.exists() && configuration.deleteBaseOnStartup) {
-                FileUtils.delete(base);
-            } else if (!base.exists()) {
-                FileUtils.mkDir(base);
-            }
+            base = new File(newBaseDir());
 
             final File conf = createDirectory(base, "conf");
             createDirectory(base, "lib");
@@ -451,7 +455,11 @@ public class Microwave implements AutoCl
         } finally {
             ofNullable(postTask).ifPresent(Runnable::run);
             postTask = null;
-            FileUtils.delete(base);
+            try {
+                FileUtils.deleteDirectory(base);
+            } catch (final IOException e) {
+                // no-op
+            }
         }
     }
 
@@ -510,7 +518,6 @@ public class Microwave implements AutoCl
         if (!dir.exists() && !dir.mkdirs()) {
             throw new IllegalStateException("Unable to make dir " + dir.getAbsolutePath());
         }
-
         return dir;
     }
 
@@ -537,38 +544,40 @@ public class Microwave implements AutoCl
         }
     }
 
-    private String getBaseDir() {
+    private String newBaseDir() {
         File file;
-        try {
 
-            final String dir = configuration.dir;
-            if (dir != null) {
-                final File dirFile = new File(dir);
-                if (dirFile.exists()) {
-                    return dir;
+        final String dir = configuration.dir;
+        if (dir != null) {
+            final File dirFile = new File(dir);
+            if (dirFile.exists()) {
+                if (base.exists() && configuration.deleteBaseOnStartup) {
+                    try {
+                        FileUtils.deleteDirectory(base);
+                    } catch (final IOException e) {
+                        throw new IllegalArgumentException(e);
+                    }
                 }
-                FileUtils.mkDir(dirFile);
-                return dirFile.getAbsolutePath();
+                return dir;
             }
-
             try {
-                final File target = new File("target");
-                file = File.createTempFile("microwave", "-home", target.exists() ? target
: null);
-            } catch (final Exception e) {
-
-                final File tmp = new File(configuration.tempDir);
-                if (!tmp.exists() && !tmp.mkdirs()) {
-                    throw new IOException("Failed to create local tmp directory: " + tmp.getAbsolutePath());
-                }
-
-                file = File.createTempFile("microwave", "-home", tmp);
+                FileUtils.forceMkdir(dirFile);
+            } catch (final IOException e) {
+                throw new IllegalArgumentException(e);
             }
+            return dirFile.getAbsolutePath();
+        }
 
-            return file.getAbsolutePath();
-
+        file = new File(Stream.of("target", "build", ".")
+                .map(File::new)
+                .filter(File::isDirectory)
+                .findFirst().get(), "microwave-" + System.nanoTime());
+        try {
+            FileUtils.forceMkdir(file);
         } catch (final IOException e) {
-            throw new MicrowaveExplosion("Failed to get or create base dir: " + configuration.dir,
e);
+            throw new IllegalArgumentException(e);
         }
+        return file.getAbsolutePath();
     }
 
     public static class Builder {
@@ -675,7 +684,7 @@ public class Microwave implements AutoCl
         private Map<String, String> cxfServletParams;
 
         @CliOption(name = "tomcat-scanning", description = "Should Tomcat scanning be used
(@HandleTypes, @WebXXX)")
-        private boolean tomcatScanning = false;
+        private boolean tomcatScanning = true;
 
         public Builder() { // load defaults
             loadFrom("microwave.properties");

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/BundleMetadataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/BundleMetadataDiscovery.java?rev=1765889&r1=1765888&r2=1765889&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/BundleMetadataDiscovery.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/BundleMetadataDiscovery.java
Thu Oct 20 21:33:45 2016
@@ -32,6 +32,10 @@ import java.util.List;
 import java.util.Set;
 
 public class BundleMetadataDiscovery extends WebScannerService {
+    public OwbAnnotationFinder getFinder() {
+        return OwbAnnotationFinder.class.cast(initFinder());
+    }
+
     @Override
     protected AnnotationFinder initFinder() {
         if (finder != null) {

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/CDIInstanceManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/CDIInstanceManager.java?rev=1765889&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/CDIInstanceManager.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/CDIInstanceManager.java
Thu Oct 20 21:33:45 2016
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.tomcat;
+
+import org.apache.tomcat.InstanceManager;
+import org.apache.webbeans.servlet.WebBeansConfigurationListener;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.CDI;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.naming.NamingException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static java.util.Optional.ofNullable;
+
+public class CDIInstanceManager implements InstanceManager {
+    private final Map<Object, Runnable> destroyables = new ConcurrentHashMap<>();
+
+    @Override
+    public Object newInstance(final Class<?> clazz) throws IllegalAccessException,
InvocationTargetException,
+            NamingException, InstantiationException {
+        final Object newInstance = clazz.newInstance();
+        newInstance(newInstance);
+        return newInstance;
+    }
+
+    @Override
+    public Object newInstance(final String className) throws IllegalAccessException, InvocationTargetException,
+            NamingException, InstantiationException, ClassNotFoundException {
+        return newInstance(className, Thread.currentThread().getContextClassLoader());
+    }
+
+    @Override
+    public Object newInstance(final String fqcn, final ClassLoader classLoader) throws IllegalAccessException,
+            InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
{
+        return newInstance(classLoader.loadClass(fqcn));
+    }
+
+    @Override
+    public void newInstance(final Object o) throws IllegalAccessException, InvocationTargetException,
NamingException {
+        if (WebBeansConfigurationListener.class.isInstance(o)) {
+            return;
+        }
+
+        final BeanManager bm = CDI.current().getBeanManager();
+        final AnnotatedType<?> annotatedType = bm.createAnnotatedType(o.getClass());
+        final InjectionTarget injectionTarget = bm.createInjectionTarget(annotatedType);
+        final CreationalContext<Object> creationalContext = bm.createCreationalContext(null);
+        injectionTarget.inject(o, creationalContext);
+        try {
+            injectionTarget.postConstruct(o);
+        } catch (final RuntimeException e) {
+            creationalContext.release();
+            throw e;
+        }
+        destroyables.put(o, () -> {
+            try {
+                injectionTarget.preDestroy(o);
+            } finally {
+                creationalContext.release();
+            }
+        });
+    }
+
+    @Override
+    public void destroyInstance(final Object o) throws IllegalAccessException, InvocationTargetException
{
+        ofNullable(destroyables.remove(o)).ifPresent(Runnable::run);
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/OWBJarScanner.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/OWBJarScanner.java?rev=1765889&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/OWBJarScanner.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/tomcat/OWBJarScanner.java
Thu Oct 20 21:33:45 2016
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.tomcat;
+
+import org.apache.microwave.openwebbeans.BundleMetadataDiscovery;
+import org.apache.tomcat.Jar;
+import org.apache.tomcat.JarScanFilter;
+import org.apache.tomcat.JarScanType;
+import org.apache.tomcat.JarScanner;
+import org.apache.tomcat.JarScannerCallback;
+import org.apache.tomcat.util.buf.UriUtil;
+import org.apache.tomcat.util.scan.Constants;
+import org.apache.tomcat.util.scan.JarFactory;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.corespi.scanner.xbean.CdiArchive;
+
+import javax.servlet.ServletContext;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+public class OWBJarScanner implements JarScanner {
+    private JarScanFilter filter; // not yet used
+
+    @Override
+    public void scan(final JarScanType jarScanType, final ServletContext servletContext,
final JarScannerCallback callback) {
+        switch (jarScanType) {
+            case PLUGGABILITY:
+                CdiArchive.class.cast(BundleMetadataDiscovery.class.cast(WebBeansContext.getInstance().getScannerService()).getFinder().getArchive())
+                        .classesByUrl().keySet().forEach(u -> {
+                    try {
+                        final URL url = new URL(u);
+                        if ("jar".equals(url.getProtocol()) || url.getPath().endsWith(Constants.JAR_EXT))
{
+                            try (final Jar jar = JarFactory.newInstance(url)) {
+                                callback.scan(jar, u, true);
+                            }
+                        } else if ("file".equals(url.getProtocol())) {
+                            final File f = new File(url.toURI());
+                            if (f.isFile()) {
+                                try (final Jar jar = JarFactory.newInstance(UriUtil.buildJarUrl(f)))
{
+                                    callback.scan(jar, f.getAbsolutePath(), true);
+                                }
+                            } else if (f.isDirectory()) {
+                                callback.scan(f, f.getAbsolutePath(), true);
+                            }
+                        }
+                    } catch (final MalformedURLException e) {
+                        // skip
+                    } catch (final IOException | URISyntaxException ioe) {
+                        throw new IllegalArgumentException(ioe);
+                    }
+                });
+                return;
+
+            case TLD:
+            default:
+        }
+    }
+
+    @Override
+    public JarScanFilter getJarScanFilter() {
+        return filter;
+    }
+
+    @Override
+    public void setJarScanFilter(final JarScanFilter jarScanFilter) {
+        this.filter = jarScanFilter;
+    }
+}

Modified: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java?rev=1765889&r1=1765888&r2=1765889&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/MicrowaveTest.java
Thu Oct 20 21:33:45 2016
@@ -51,9 +51,23 @@ public class MicrowaveTest {
                 fail();
             }
         });
+        Stream.of("OtherEndpoint", "OtherFilter").forEach(name -> { // from classpath
but not classloader to test in webapp deployment
+            final String target = "org/superbiz/app/" + name + ".class";
+            File targetFile = new File(root, "WEB-INF/classes/" + target);
+            FileUtils.mkDir(targetFile.getParentFile());
+            try (final InputStream from = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/superbiz/app-res/"
+ name + ".class");
+                 final OutputStream to = new FileOutputStream(targetFile)) {
+                IOUtils.copy(from, to);
+            } catch (final IOException e) {
+                fail();
+            }
+        });
         try (final Microwave microwave = new Microwave(new Microwave.Builder().randomHttpPort()).start())
{
             microwave.deployWebapp("", root);
             assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
+            assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/other")));
+            assertEquals("simplefiltertrue", IOUtils.toString(new URL("http://localhost:"
+ microwave.getConfiguration().getHttpPort() + "/filter")));
+            assertEquals("filtertrue", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/other")));
         } catch (final IOException e) {
             fail(e.getMessage());
         }
@@ -63,6 +77,7 @@ public class MicrowaveTest {
     public void classpath() {
         try (final Microwave microwave = new Microwave(new Microwave.Builder().randomHttpPort()).bake())
{
             assertEquals("simple", IOUtils.toString(new URL("http://localhost:" + microwave.getConfiguration().getHttpPort()
+ "/api/test")));
+            assertEquals("simplefiltertrue", IOUtils.toString(new URL("http://localhost:"
+ microwave.getConfiguration().getHttpPort() + "/filter")));
         } catch (final IOException e) {
             fail(e.getMessage());
         }

Added: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/SomeFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/SomeFilter.java?rev=1765889&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/SomeFilter.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/SomeFilter.java
Thu Oct 20 21:33:45 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.superbiz.app;
+
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import java.io.IOException;
+
+@WebFilter("/filter")
+public class SomeFilter implements Filter {
+    @Inject
+    private Injectable injectable;
+
+    @Override
+    public void init(final FilterConfig filterConfig) throws ServletException {
+        // no-op
+    }
+
+    @Override
+    public void doFilter(final ServletRequest request, final ServletResponse response, final
FilterChain chain) throws IOException, ServletException {
+        response.getWriter().write("simplefilter" + injectable.injected());
+    }
+
+    @Override
+    public void destroy() {
+        // no-op
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherEndpoint.class
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherEndpoint.class?rev=1765889&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherEndpoint.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherFilter.class
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherFilter.class?rev=1765889&view=auto
==============================================================================
Binary file - no diff available.

Propchange: openwebbeans/microwave/trunk/microwave-core/src/test/resources/org/superbiz/app-res/OtherFilter.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

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=1765889&r1=1765888&r2=1765889&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
Thu Oct 20 21:33:45 2016
@@ -50,7 +50,9 @@ public class MicrowaveExtension {
     private Collection<String> securityConstraints = new LinkedList<>();
     private Map<String, String> users;
     private Map<String, String> roles;
+    private Map<String, String> cxfServletParams;
     private boolean http2;
+    private boolean tomcatScanning = true;
     private String tempDir;
     private boolean webResourceCached = true;
     private String conf;
@@ -61,6 +63,30 @@ public class MicrowaveExtension {
     private boolean jaxrsProviderSetup = true;
     private boolean loggingGlobalSetup = true;
 
+    public Map<String, String> getCxfServletParams() {
+        return cxfServletParams;
+    }
+
+    public void setCxfServletParams(final Map<String, String> cxfServletParams) {
+        this.cxfServletParams = cxfServletParams;
+    }
+
+    public boolean isTomcatScanning() {
+        return tomcatScanning;
+    }
+
+    public void setTomcatScanning(final boolean tomcatScanning) {
+        this.tomcatScanning = tomcatScanning;
+    }
+
+    public boolean isLoggingGlobalSetup() {
+        return loggingGlobalSetup;
+    }
+
+    public void setLoggingGlobalSetup(final boolean loggingGlobalSetup) {
+        this.loggingGlobalSetup = loggingGlobalSetup;
+    }
+
     public boolean isJaxrsProviderSetup() {
         return jaxrsProviderSetup;
     }

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=1765889&r1=1765888&r2=1765889&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
Thu Oct 20 21:33:45 2016
@@ -69,7 +69,7 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
-    protected String dir;
+    private String dir;
 
     @Input
     @Optional
@@ -141,6 +141,10 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
+    private Map<String, String> cxfServletParams;
+
+    @Input
+    @Optional
     private boolean http2;
 
     @Input
@@ -181,6 +185,10 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
+    private boolean tomcatScanning = true;
+
+    @Input
+    @Optional
     private List<File> modules;
 
     @Input
@@ -448,4 +456,323 @@ public class MicrowaveTask extends Defau
         }
     }
 
+    public Configuration getClasspath() {
+        return classpath;
+    }
+
+    public void setClasspath(final Configuration classpath) {
+        this.classpath = classpath;
+    }
+
+    public int getHttpPort() {
+        return httpPort;
+    }
+
+    public void setHttpPort(final int httpPort) {
+        this.httpPort = httpPort;
+    }
+
+    public int getHttpsPort() {
+        return httpsPort;
+    }
+
+    public void setHttpsPort(final int httpsPort) {
+        this.httpsPort = httpsPort;
+    }
+
+    public int getStopPort() {
+        return stopPort;
+    }
+
+    public void setStopPort(final int stopPort) {
+        this.stopPort = stopPort;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(final String host) {
+        this.host = host;
+    }
+
+    public String getDir() {
+        return dir;
+    }
+
+    public void setDir(final String dir) {
+        this.dir = dir;
+    }
+
+    public File getServerXml() {
+        return serverXml;
+    }
+
+    public void setServerXml(final File serverXml) {
+        this.serverXml = serverXml;
+    }
+
+    public boolean isKeepServerXmlAsThis() {
+        return keepServerXmlAsThis;
+    }
+
+    public void setKeepServerXmlAsThis(final boolean keepServerXmlAsThis) {
+        this.keepServerXmlAsThis = keepServerXmlAsThis;
+    }
+
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
+    public void setProperties(final Map<String, String> properties) {
+        this.properties = properties;
+    }
+
+    public boolean isQuickSession() {
+        return quickSession;
+    }
+
+    public void setQuickSession(final boolean quickSession) {
+        this.quickSession = quickSession;
+    }
+
+    public boolean isSkipHttp() {
+        return skipHttp;
+    }
+
+    public void setSkipHttp(final boolean skipHttp) {
+        this.skipHttp = skipHttp;
+    }
+
+    public boolean isSsl() {
+        return ssl;
+    }
+
+    public void setSsl(final boolean ssl) {
+        this.ssl = ssl;
+    }
+
+    public String getKeystoreFile() {
+        return keystoreFile;
+    }
+
+    public void setKeystoreFile(final String keystoreFile) {
+        this.keystoreFile = keystoreFile;
+    }
+
+    public String getKeystorePass() {
+        return keystorePass;
+    }
+
+    public void setKeystorePass(final String keystorePass) {
+        this.keystorePass = keystorePass;
+    }
+
+    public String getKeystoreType() {
+        return keystoreType;
+    }
+
+    public void setKeystoreType(final String keystoreType) {
+        this.keystoreType = keystoreType;
+    }
+
+    public String getClientAuth() {
+        return clientAuth;
+    }
+
+    public void setClientAuth(final String clientAuth) {
+        this.clientAuth = clientAuth;
+    }
+
+    public String getKeyAlias() {
+        return keyAlias;
+    }
+
+    public void setKeyAlias(final String keyAlias) {
+        this.keyAlias = keyAlias;
+    }
+
+    public String getSslProtocol() {
+        return sslProtocol;
+    }
+
+    public void setSslProtocol(final String sslProtocol) {
+        this.sslProtocol = sslProtocol;
+    }
+
+    public String getWebXml() {
+        return webXml;
+    }
+
+    public void setWebXml(final String webXml) {
+        this.webXml = webXml;
+    }
+
+    public String getLoginConfig() {
+        return loginConfig;
+    }
+
+    public void setLoginConfig(final String loginConfig) {
+        this.loginConfig = loginConfig;
+    }
+
+    public Collection<String> getSecurityConstraints() {
+        return securityConstraints;
+    }
+
+    public void setSecurityConstraints(final Collection<String> securityConstraints)
{
+        this.securityConstraints = securityConstraints;
+    }
+
+    public Map<String, String> getUsers() {
+        return users;
+    }
+
+    public void setUsers(final Map<String, String> users) {
+        this.users = users;
+    }
+
+    public Map<String, String> getRoles() {
+        return roles;
+    }
+
+    public void setRoles(final Map<String, String> roles) {
+        this.roles = roles;
+    }
+
+    public Map<String, String> getCxfServletParams() {
+        return cxfServletParams;
+    }
+
+    public void setCxfServletParams(final Map<String, String> cxfServletParams) {
+        this.cxfServletParams = cxfServletParams;
+    }
+
+    public boolean isHttp2() {
+        return http2;
+    }
+
+    public void setHttp2(final boolean http2) {
+        this.http2 = http2;
+    }
+
+    public String getTempDir() {
+        return tempDir;
+    }
+
+    public void setTempDir(final String tempDir) {
+        this.tempDir = tempDir;
+    }
+
+    public boolean isWebResourceCached() {
+        return webResourceCached;
+    }
+
+    public void setWebResourceCached(final boolean webResourceCached) {
+        this.webResourceCached = webResourceCached;
+    }
+
+    public String getConf() {
+        return conf;
+    }
+
+    public void setConf(final String conf) {
+        this.conf = conf;
+    }
+
+    public boolean isDeleteBaseOnStartup() {
+        return deleteBaseOnStartup;
+    }
+
+    public void setDeleteBaseOnStartup(final boolean deleteBaseOnStartup) {
+        this.deleteBaseOnStartup = deleteBaseOnStartup;
+    }
+
+    public String getJaxrsMapping() {
+        return jaxrsMapping;
+    }
+
+    public void setJaxrsMapping(final String jaxrsMapping) {
+        this.jaxrsMapping = jaxrsMapping;
+    }
+
+    public boolean isJaxrsProviderSetup() {
+        return jaxrsProviderSetup;
+    }
+
+    public void setJaxrsProviderSetup(final boolean jaxrsProviderSetup) {
+        this.jaxrsProviderSetup = jaxrsProviderSetup;
+    }
+
+    public boolean isLoggingGlobalSetup() {
+        return loggingGlobalSetup;
+    }
+
+    public void setLoggingGlobalSetup(final boolean loggingGlobalSetup) {
+        this.loggingGlobalSetup = loggingGlobalSetup;
+    }
+
+    public boolean isCdiConversation() {
+        return cdiConversation;
+    }
+
+    public void setCdiConversation(final boolean cdiConversation) {
+        this.cdiConversation = cdiConversation;
+    }
+
+    public boolean isSkip() {
+        return skip;
+    }
+
+    public void setSkip(final boolean skip) {
+        this.skip = skip;
+    }
+
+    public boolean isTomcatScanning() {
+        return tomcatScanning;
+    }
+
+    public void setTomcatScanning(final boolean tomcatScanning) {
+        this.tomcatScanning = tomcatScanning;
+    }
+
+    public List<File> getModules() {
+        return modules;
+    }
+
+    public void setModules(final List<File> modules) {
+        this.modules = modules;
+    }
+
+    public Collection<String> getApplicationScopes() {
+        return applicationScopes;
+    }
+
+    public void setApplicationScopes(final Collection<String> applicationScopes) {
+        this.applicationScopes = applicationScopes;
+    }
+
+    public Collection<String> getClassloaderFilteredPackages() {
+        return classloaderFilteredPackages;
+    }
+
+    public void setClassloaderFilteredPackages(final Collection<String> classloaderFilteredPackages)
{
+        this.classloaderFilteredPackages = classloaderFilteredPackages;
+    }
+
+    public String getContext() {
+        return context;
+    }
+
+    public void setContext(final String context) {
+        this.context = context;
+    }
+
+    public File getWebapp() {
+        return webapp;
+    }
+
+    public void setWebapp(final File webapp) {
+        this.webapp = webapp;
+    }
 }

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=1765889&r1=1765888&r2=1765889&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
Thu Oct 20 21:33:45 2016
@@ -76,9 +76,15 @@ public class MicrowaveRunMojo extends Ab
     @Parameter
     private Map<String, String> properties;
 
+    @Parameter
+    private Map<String, String> cxfServletParams;
+
     @Parameter(property = "microwave.quickSession", defaultValue = "true")
     private boolean quickSession;
 
+    @Parameter(property = "microwave.tomcatScanning", defaultValue = "true")
+    private boolean tomcatScanning;
+
     @Parameter(property = "microwave.skipHttp")
     private boolean skipHttp;
 




Mime
View raw message