openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1767566 - in /openwebbeans/microwave/trunk: microwave-arquillian/src/main/java/org/apache/microwave/arquillian/ microwave-core/ microwave-core/src/main/java/org/apache/catalina/startup/ microwave-core/src/main/java/org/apache/microwave/ mi...
Date Tue, 01 Nov 2016 20:27:47 GMT
Author: rmannibucau
Date: Tue Nov  1 20:27:46 2016
New Revision: 1767566

URL: http://svn.apache.org/viewvc?rev=1767566&view=rev
Log:
adding shared libraries features for automatic extensions activation or provided API

Added:
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/SharedLibTest.java
      - copied, changed from r1767534, openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/PrincipalTest.java
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/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/KnownJarsFilter.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/MicrowaveSecurityService.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/OWBTomcatWebScannerService.java
    openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/Endpoint.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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -79,6 +79,7 @@ public class MicrowaveConfiguration impl
     private boolean jaxrsLogProviders;
     private boolean tomcatWrapLoader = true;
     private String jaxrsDefaultProviders;
+    private String sharedLibraries;
 
     @Override
     public void validate() throws ConfigurationException {
@@ -530,4 +531,12 @@ public class MicrowaveConfiguration impl
     public void setJaxrsDefaultProviders(final String jaxrsDefaultProviders) {
         this.jaxrsDefaultProviders = jaxrsDefaultProviders;
     }
+
+    public String getSharedLibraries() {
+        return sharedLibraries;
+    }
+
+    public void setSharedLibraries(final String sharedLibraries) {
+        this.sharedLibraries = sharedLibraries;
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/pom.xml?rev=1767566&r1=1767565&r2=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-core/pom.xml Tue Nov  1 20:27:46 2016
@@ -201,6 +201,40 @@
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>2.10</version>
+        <executions>
+          <execution>
+            <id>copy</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.deltaspike.core</groupId>
+                  <artifactId>deltaspike-core-api</artifactId>
+                  <version>1.7.1</version>
+                  <type>jar</type>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${project.build.directory}/shared-test</outputDirectory>
+                </artifactItem>
+                <artifactItem>
+                  <groupId>org.apache.deltaspike.core</groupId>
+                  <artifactId>deltaspike-core-impl</artifactId>
+                  <version>1.7.1</version>
+                  <type>jar</type>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${project.build.directory}/shared-test</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.5.1</version>
         <executions>

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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -76,6 +76,7 @@ public class MicrowaveContextConfig exte
             final OWBTomcatWebScannerService scannerService = OWBTomcatWebScannerService.class.cast(WebBeansContext.getInstance().getScannerService());
             ofNullable(context.getJarScanner()).ifPresent(s -> scannerService.setFilter(s.getJarScanFilter()));
             scannerService.setDocBase(context.getDocBase());
+            scannerService.setShared(configuration.getSharedLibraries());
             scannerService.scan();
             finder = scannerService.getFinder();
             finder.link();

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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -71,8 +71,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.reflect.Field;
+import java.net.MalformedURLException;
 import java.net.ServerSocket;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -84,8 +86,10 @@ import java.util.TreeMap;
 import java.util.function.Consumer;
 import java.util.stream.Stream;
 
+import static java.util.Collections.emptyList;
 import static java.util.Collections.emptySet;
 import static java.util.Optional.ofNullable;
+import static java.util.stream.Collectors.toList;
 
 public class Microwave implements AutoCloseable {
     private final Builder configuration;
@@ -125,8 +129,14 @@ public class Microwave implements AutoCl
     }
 
     public Microwave deployClasspath(final DeploymentMeta meta) {
-        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        final Consumer<Context> builtInCustomizer = c -> c.setLoader(new ProvidedLoader(classLoader,
configuration.isTomcatWrapLoader()));
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        final ClassLoader parentLoader = tomcat.getServer().getParentClassLoader();
+        if (parentLoader.getParent() == classLoader) {
+            classLoader = parentLoader;
+        }
+
+        final ProvidedLoader loader = new ProvidedLoader(classLoader, configuration.isTomcatWrapLoader());
+        final Consumer<Context> builtInCustomizer = c -> c.setLoader(loader);
         return deployWebapp(new DeploymentMeta(meta.context, meta.docBase, ofNullable(meta.consumer).map(c
-> (Consumer<Context>) ctx -> {
             builtInCustomizer.accept(ctx);
             c.accept(ctx);
@@ -379,6 +389,25 @@ public class Microwave implements AutoCl
             initialized = false;
         }
 
+        ofNullable(configuration.getSharedLibraries()).map(File::new).filter(File::isDirectory).ifPresent(libRoot
-> {
+            final Collection<URL> libs = new ArrayList<>();
+            try {
+                libs.add(libRoot.toURI().toURL());
+            } catch (final MalformedURLException e) {
+                throw new IllegalStateException(e);
+            }
+            libs.addAll(ofNullable(libRoot.listFiles((dir, name) -> name.endsWith(".jar")
|| name.endsWith(".zip")))
+                    .map(Stream::of).map(s -> s.map(f -> {
+                        try {
+                            return f.toURI().toURL();
+                        } catch (final MalformedURLException e) {
+                            throw new IllegalStateException(e);
+                        }
+                    }).collect(toList()))
+                    .orElse(emptyList()));
+            tomcat.getServer().setParentClassLoader(new MicrowaveContainerLoader(libs.toArray(new
URL[libs.size()]), Thread.currentThread().getContextClassLoader()));
+        });
+
         if (!initialized) {
             tomcat.setHostname(configuration.host);
             tomcat.getEngine().setDefaultHost(configuration.host);
@@ -504,6 +533,13 @@ public class Microwave implements AutoCl
             this.hook = null;
         }
         beforeStop();
+        if (MicrowaveContainerLoader.class.isInstance(tomcat.getServer().getParentClassLoader()))
{
+            try {
+                MicrowaveContainerLoader.class.cast(tomcat.getServer().getParentClassLoader()).close();
+            } catch (final IOException e) {
+                new LogFacade(Microwave.class.getName()).error(e.getMessage(), e);
+            }
+        }
         try {
             contexts.values().forEach(Runnable::run);
         } finally {
@@ -765,10 +801,26 @@ public class Microwave implements AutoCl
                 "should microwave wrap the loader to define another loader identity but still
use the same classes and resources.")
         private boolean tomcatWrapLoader = false;
 
+        @CliOption(name = "shared-librariries", description = "A folder containing shared
libraries.")
+        private String sharedLibraries;
+
         public Builder() { // load defaults
             loadFrom("microwave.properties");
         }
 
+        public String getSharedLibraries() {
+            return sharedLibraries;
+        }
+
+        public Builder sharedLibraries(final String sharedLibraries) {
+            setSharedLibraries(sharedLibraries);
+            return this;
+        }
+
+        public void setSharedLibraries(final String sharedLibraries) {
+            this.sharedLibraries = sharedLibraries;
+        }
+
         public boolean isJaxrsLogProviders() {
             return jaxrsLogProviders;
         }
@@ -1609,4 +1661,10 @@ public class Microwave implements AutoCl
     // just to type it and allow some extensions to use a ServiceLoader
     public interface ConfigurationCustomizer extends Consumer<Microwave.Builder> {
     }
+
+    private static final class MicrowaveContainerLoader extends URLClassLoader {
+        private MicrowaveContainerLoader(final URL[] urls, final ClassLoader parent) {
+            super(urls, parent);
+        }
+    }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/KnownJarsFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/KnownJarsFilter.java?rev=1767566&r1=1767565&r2=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/KnownJarsFilter.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/KnownJarsFilter.java
Tue Nov  1 20:27:46 2016
@@ -172,6 +172,7 @@ public class KnownJarsFilter implements
         add("johnzon-");
         add("jruby-");
         add("jsoup-");
+        add("jsonb-api");
         add("jsp-api");
         add("jsr299-");
         add("jsr311-");

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/MicrowaveSecurityService.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/MicrowaveSecurityService.java?rev=1767566&r1=1767565&r2=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/MicrowaveSecurityService.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/MicrowaveSecurityService.java
Tue Nov  1 20:27:46 2016
@@ -18,101 +18,27 @@
  */
 package org.apache.microwave.openwebbeans;
 
-import org.apache.webbeans.corespi.security.ManagedSecurityService;
-import org.apache.webbeans.spi.SecurityService;
+import org.apache.webbeans.corespi.security.SimpleSecurityService;
 
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.CDI;
 import javax.servlet.http.HttpServletRequest;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.security.Principal;
-import java.security.PrivilegedActionException;
-import java.util.Properties;
-
-public class MicrowaveSecurityService implements SecurityService {
-    private final SecurityService securityService = new ManagedSecurityService();
 
+public class MicrowaveSecurityService extends SimpleSecurityService {
     @Override // reason of that class
     public Principal getCurrentPrincipal() {
         return new MicrowavePrincipal();
     }
 
-    @Override
-    public <T> Constructor<T> doPrivilegedGetDeclaredConstructor(final Class<T>
aClass, final Class<?>... classes) {
-        return securityService.doPrivilegedGetDeclaredConstructor(aClass, classes);
-    }
-
-    @Override
-    public <T> Constructor<T> doPrivilegedGetConstructor(final Class<T>
aClass, final Class<?>... classes) {
-        return securityService.doPrivilegedGetConstructor(aClass, classes);
-    }
-
-    @Override
-    public <T> Constructor<?>[] doPrivilegedGetDeclaredConstructors(final Class<T>
aClass) {
-        return securityService.doPrivilegedGetDeclaredConstructors(aClass);
-    }
-
-    @Override
-    public <T> Method doPrivilegedGetDeclaredMethod(final Class<T> aClass, final
String s, final Class<?>... classes) {
-        return securityService.doPrivilegedGetDeclaredMethod(aClass, s, classes);
-    }
-
-    @Override
-    public <T> Method[] doPrivilegedGetDeclaredMethods(final Class<T> aClass)
{
-        return securityService.doPrivilegedGetDeclaredMethods(aClass);
-    }
-
-    @Override
-    public <T> Field doPrivilegedGetDeclaredField(final Class<T> aClass, final
String s) {
-        return securityService.doPrivilegedGetDeclaredField(aClass, s);
-    }
-
-    @Override
-    public <T> Field[] doPrivilegedGetDeclaredFields(final Class<T> aClass) {
-        return securityService.doPrivilegedGetDeclaredFields(aClass);
-    }
-
-    @Override
-    public void doPrivilegedSetAccessible(final AccessibleObject accessibleObject, final
boolean b) {
-        securityService.doPrivilegedSetAccessible(accessibleObject, b);
-    }
-
-    @Override
-    public boolean doPrivilegedIsAccessible(final AccessibleObject accessibleObject) {
-        return securityService.doPrivilegedIsAccessible(accessibleObject);
-    }
-
-    @Override
-    public <T> T doPrivilegedObjectCreate(final Class<T> aClass) throws PrivilegedActionException,
IllegalAccessException, InstantiationException {
-        return securityService.doPrivilegedObjectCreate(aClass);
-    }
-
-    @Override
-    public void doPrivilegedSetSystemProperty(final String s, final String s1) {
-        securityService.doPrivilegedSetSystemProperty(s, s1);
-    }
-
-    @Override
-    public String doPrivilegedGetSystemProperty(final String s, final String s1) {
-        return securityService.doPrivilegedGetSystemProperty(s, s1);
-    }
-
-    @Override
-    public Properties doPrivilegedGetSystemProperties() {
-        return securityService.doPrivilegedGetSystemProperties();
-    }
-
     // ensure it is contextual
-    public static class MicrowavePrincipal implements Principal {
+    private static class MicrowavePrincipal implements Principal {
         @Override
         public String getName() {
             return unwrap().getName();
         }
 
-        public /*ensure user can cast it to get the actual instance*/ Principal unwrap()
{
+        private Principal unwrap() {
             final BeanManager beanManager = CDI.current().getBeanManager();
             return HttpServletRequest.class.cast(
                     beanManager.getReference(

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/OWBTomcatWebScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/OWBTomcatWebScannerService.java?rev=1767566&r1=1767565&r2=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/OWBTomcatWebScannerService.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/openwebbeans/OWBTomcatWebScannerService.java
Tue Nov  1 20:27:46 2016
@@ -25,11 +25,10 @@ import org.apache.webbeans.web.scanner.W
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.HashSet;
 import java.util.Set;
 
+import static java.util.Optional.of;
 import static java.util.Optional.ofNullable;
 import static org.apache.tomcat.JarScanType.PLUGGABILITY;
 
@@ -40,8 +39,9 @@ public class OWBTomcatWebScannerService
     private String jreBase;
 
     // just for logging (== temp)
-    private final List<String> urls = new ArrayList<>(8);
+    private final Set<String> urls = new HashSet<>();
     private String docBase;
+    private String shared;
 
     @Override
     public void scan() {
@@ -50,11 +50,11 @@ public class OWBTomcatWebScannerService
         }
         super.scan();
         if (!urls.isEmpty()) {
-            Collections.sort(urls);
             logger.info("OpenWebBeans scanning:");
             final String m2 = new File(System.getProperty("user.home", "."), ".m2/repository").getAbsolutePath();
             final String base = ofNullable(docBase).orElse("$$$");
-            urls.forEach(u -> {
+            final String sharedBase = ofNullable(shared).orElse("$$$");
+            urls.stream().map(u -> {
                 String shownValue = u
                         // protocol
                         .replace("file://", "")
@@ -71,14 +71,17 @@ public class OWBTomcatWebScannerService
                     shownValue = "${maven}/" + shownValue.substring(shownValue.replace(File.separatorChar,
'/').lastIndexOf('/') + 1);
                 } else if (shownValue.startsWith(base)) {
                     shownValue = "${app}" + shownValue.replace(base, "");
+                } else if (sharedBase != null && shownValue.startsWith(sharedBase))
{
+                    shownValue = "${shared}" + shownValue.replace(sharedBase, "");
                 }
 
-                // finally log
-                logger.info("    " + shownValue);
-            });
-            urls.clear(); // no more needed
+                return shownValue;
+            }).sorted().forEach(v -> logger.info("    " + v));
         }
+        urls.clear(); // no more needed
         filter = null;
+        docBase = null;
+        shared = null;
     }
 
     @Override
@@ -118,9 +121,16 @@ public class OWBTomcatWebScannerService
 
     @Override
     protected void addWebBeansXmlLocation(final URL beanArchiveUrl) {
-        urls.add(beanArchiveUrl.toExternalForm());
-        // we just customize the logging
-        super.doAddWebBeansXmlLocation(beanArchiveUrl);
+        final String url = beanArchiveUrl.toExternalForm();
+        if (urls.add(of(url)
+                .map(s -> s.startsWith("jar:") && s.endsWith("!/META-INF/beans.xml")
? s.substring("jar:".length(), s.length() - "!/META-INF/beans.xml".length()) : s)
+                .get())) {
+            super.doAddWebBeansXmlLocation(beanArchiveUrl);
+        }
+    }
+
+    public void setShared(final String shared) {
+        this.shared = ofNullable(shared).map(File::new).filter(File::isDirectory).map(File::getAbsolutePath).orElse(null);
     }
 
     public void setDocBase(final String docBase) {

Copied: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/SharedLibTest.java
(from r1767534, openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/PrincipalTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/SharedLibTest.java?p2=openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/SharedLibTest.java&p1=openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/PrincipalTest.java&r1=1767534&r2=1767566&rev=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/PrincipalTest.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/apache/microwave/SharedLibTest.java
Tue Nov  1 20:27:46 2016
@@ -18,70 +18,29 @@
  */
 package org.apache.microwave;
 
-import org.apache.catalina.realm.RealmBase;
 import org.apache.microwave.io.IO;
 import org.junit.Test;
 
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.StandardCharsets;
-import java.security.Principal;
 
-import static javax.xml.bind.DatatypeConverter.printBase64Binary;
 import static org.junit.Assert.assertEquals;
 
-public class PrincipalTest {
+public class SharedLibTest {
     @Test
     public void run() throws IOException {
         try (final Microwave container = new Microwave(new Microwave.Builder()
                 .randomHttpPort()
-                .realm(new RealmBase() {
-                    @Override
-                    protected String getName() {
-                        return "test";
-                    }
-
-                    @Override
-                    protected String getPassword(final String username) {
-                        return "foo".equals(username) ? "pwd" : null;
-                    }
-
-                    @Override
-                    protected Principal getPrincipal(final String username) {
-                        return new MyPrincipal(username);
-                    }
-                }).loginConfig(new Microwave.LoginConfigBuilder()
-                        .basic()
-                        .realmName("basic realm"))
-                .securityConstraints(new Microwave.SecurityConstaintBuilder()
-                        .authConstraint(true)
-                        .addAuthRole("**")
-                        .addCollection("secured", "/*")))
+                .sharedLibraries("target/shared-test"))
                 .bake()) {
             assertEquals(
-                    "org.apache.microwave.PrincipalTest$MyPrincipal_foo  org.apache.webbeans.custom.security.Principal_foo",
-                    slurp(new URL("http://localhost:" + container.getConfiguration().getHttpPort()
+ "/api/test/principal")));
+                    "org.apache.deltaspike.core.api.config.ConfigProperty",
+                    slurp(new URL("http://localhost:" + container.getConfiguration().getHttpPort()
+ "/api/test/load/org.apache.deltaspike.core.api.config.ConfigProperty")));
         }
     }
 
     private String slurp(final URL url) throws IOException {
-        final URLConnection is = HttpURLConnection.class.cast(url.openConnection());
-        is.setRequestProperty("Authorization", "Basic " + printBase64Binary("foo:pwd".getBytes(StandardCharsets.UTF_8)));
-        return IO.toString(is.getInputStream());
-    }
-
-    private static class MyPrincipal implements Principal {
-        private final String name;
-
-        private MyPrincipal(final String username) {
-            this.name = username;
-        }
-
-        @Override
-        public String getName() {
-            return name;
-        }
+        return IO.toString(HttpURLConnection.class.cast(url.openConnection()).getInputStream());
     }
 }

Modified: openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/Endpoint.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/Endpoint.java?rev=1767566&r1=1767565&r2=1767566&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/Endpoint.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/test/java/org/superbiz/app/Endpoint.java
Tue Nov  1 20:27:46 2016
@@ -19,16 +19,19 @@
 package org.superbiz.app;
 
 import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.BeanManager;
 import javax.inject.Inject;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import java.security.Principal;
 
 import static java.util.Optional.ofNullable;
+import static org.junit.Assert.assertNotNull;
 
 @Path("test")
 @ApplicationScoped
@@ -42,6 +45,9 @@ public class Endpoint {
     @Inject
     private HttpServletRequest request;
 
+    @Inject
+    private BeanManager bm;
+
     @GET
     @Produces(MediaType.TEXT_PLAIN)
     public String simple(@QueryParam("checkcustom") final String query) {
@@ -55,7 +61,6 @@ public class Endpoint {
         return new Simple("test");
     }
 
-
     @GET
     @Path("principal")
     @Produces(MediaType.TEXT_PLAIN)
@@ -64,6 +69,23 @@ public class Endpoint {
                 pcp.getClass().getName().replaceAll("\\$\\$OwbNormalScopeProxy[0-9]+", "")
+ "_" + pcp.getName();
     }
 
+    @GET
+    @Path("load/{name}")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String load(@PathParam("name") final String fqn) {
+        try {
+            final ClassLoader loader = Thread.currentThread().getContextClassLoader(); //
if sharedlib is set should be MicrowaveClassloader
+            if (fqn.contains("deltaspike")) {
+                final Class<?> ce = loader.loadClass("org.apache.deltaspike.core.impl.config.ConfigurationExtension");
+                final Object extensionBeanInstance = bm.getReference(bm.resolve(bm.getBeans(ce)),
ce, bm.createCreationalContext(null));
+                assertNotNull(extensionBeanInstance);
+            }
+            return loader.loadClass(fqn).getName();
+        } catch (final ClassNotFoundException cnfe) {
+            return "oops";
+        }
+    }
+
     public static class Simple {
         private String name;
 

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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -69,6 +69,15 @@ public class MicrowaveExtension {
     private boolean jaxrsLogProviders = false;
     private boolean tomcatWrapLoader = false;
     private String jaxrsDefaultProviders;
+    private String sharedLibraries;
+
+    public String getSharedLibraries() {
+        return sharedLibraries;
+    }
+
+    public void setSharedLibraries(final String sharedLibraries) {
+        this.sharedLibraries = sharedLibraries;
+    }
 
     public String getJaxrsDefaultProviders() {
         return jaxrsDefaultProviders;

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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -73,6 +73,10 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
+    private String sharedLibraries;
+
+    @Input
+    @Optional
     private File serverXml;
 
     @Input
@@ -858,4 +862,12 @@ public class MicrowaveTask extends Defau
     public void setJaxrsDefaultProviders(final String jaxrsDefaultProviders) {
         this.jaxrsDefaultProviders = jaxrsDefaultProviders;
     }
+
+    public String getSharedLibraries() {
+        return sharedLibraries;
+    }
+
+    public void setSharedLibraries(final String sharedLibraries) {
+        this.sharedLibraries = sharedLibraries;
+    }
 }

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=1767566&r1=1767565&r2=1767566&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
Tue Nov  1 20:27:46 2016
@@ -190,6 +190,10 @@ public class MicrowaveRunMojo extends Ab
     @Parameter(property = "microwave.context", defaultValue = "")
     private String context;
 
+    // we don't need to resolve from maven coordinates cause can be added to the plugin deps,
just here to reproduce manual deployments
+    @Parameter(property = "microwave.shared-libraries")
+    private String sharedLibraries;
+
     @Parameter(property = "microwave.webapp")
     private File webapp;
 



Mime
View raw message