openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1641609 - in /openwebbeans/branches/owb_1.2.x: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/ webbeans-impl/src/main/java/org/apache/webbeans/portable/ webbeans-impl/src/...
Date Tue, 25 Nov 2014 12:40:39 GMT
Author: struberg
Date: Tue Nov 25 12:40:39 2014
New Revision: 1641609

URL: http://svn.apache.org/r1641609
Log:
OWB-972 OWB-931 implement ApplicationBoundaryService

and also fix the setup of OpenWebBeansConfiguration

Added:
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
    openwebbeans/branches/owb_1.2.x/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
Modified:
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractProducer.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
    openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Tue Nov 25 12:40:39 2014
@@ -132,6 +132,9 @@ public class OpenWebBeansConfiguration
      */
     public OpenWebBeansConfiguration(Properties properties)
     {
+        this();
+
+        // and override all settings with the given properties
         configProperties.putAll(properties);
     }
 

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
Tue Nov 25 12:40:39 2014
@@ -46,6 +46,7 @@ import org.apache.webbeans.proxy.Subclas
 import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 import org.apache.webbeans.proxy.NormalScopeProxyFactory;
 import org.apache.webbeans.service.DefaultLoaderService;
+import org.apache.webbeans.spi.ApplicationBoundaryService;
 import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.spi.LoaderService;
 import org.apache.webbeans.spi.ScannerService;
@@ -92,6 +93,8 @@ public class WebBeansContext
     private final DeploymentValidationService deploymentValidationService = new DeploymentValidationService(this);
     private ScannerService scannerService;
     private ContextsService contextsService;
+    private final ApplicationBoundaryService applicationBoundaryService;
+
 
     public WebBeansContext()
     {
@@ -105,7 +108,7 @@ public class WebBeansContext
 
     private WebBeansContext(Map<Class<?>, Object> initialServices, OpenWebBeansConfiguration
openWebBeansConfiguration)
     {
-        this.openWebBeansConfiguration = openWebBeansConfiguration;
+        this.openWebBeansConfiguration = openWebBeansConfiguration != null ? openWebBeansConfiguration
: new OpenWebBeansConfiguration();
 
         //pluggable service-loader
         if (initialServices == null || !initialServices.containsKey(LoaderService.class))
@@ -135,6 +138,7 @@ public class WebBeansContext
         }
         loaderService = getService(LoaderService.class);
         securityService = getService(SecurityService.class);
+        applicationBoundaryService = getService(ApplicationBoundaryService.class);
 
 
         // Allow the WebBeansContext itself to be looked up
@@ -437,4 +441,9 @@ public class WebBeansContext
     {
         return deploymentValidationService;
     }
+
+    public ApplicationBoundaryService getApplicationBoundaryService()
+    {
+        return applicationBoundaryService;
+    }
 }

Added: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java?rev=1641609&view=auto
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
(added)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultApplicationBoundaryService.java
Tue Nov 25 12:40:39 2014
@@ -0,0 +1,46 @@
+/*
+ * 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.webbeans.corespi.se;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.webbeans.spi.ApplicationBoundaryService;
+
+/**
+ * Really simple default impl of the ApplicationBoundaryService.
+ * Assumes that there is a pretty easy ClassLoader structure in place.
+ */
+public class DefaultApplicationBoundaryService implements ApplicationBoundaryService
+{
+    private final ClassLoader appCL = BeanManager.class.getClassLoader();
+
+
+    @Override
+    public ClassLoader getApplicationClassLoader()
+    {
+        return appCL;
+    }
+
+    @Override
+    public ClassLoader getBoundaryClassLoader(Class classToProxy)
+    {
+        return classToProxy.getClassLoader();
+    }
+
+}

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
Tue Nov 25 12:40:39 2014
@@ -44,7 +44,7 @@ public class AbstractDecoratorInjectionT
     {
         // create proxy subclass
         Class<T> classToProxy = annotatedType.getJavaClass();
-        ClassLoader classLoader = classToProxy.getClassLoader();
+        ClassLoader classLoader = webBeansContext.getApplicationBoundaryService().getBoundaryClassLoader(classToProxy);
         if (classLoader == null)
         {
             classLoader = Thread.currentThread().getContextClassLoader();

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractProducer.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractProducer.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractProducer.java
Tue Nov 25 12:40:39 2014
@@ -129,7 +129,7 @@ public abstract class AbstractProducer<T
             // we only need to create a proxy class for intercepted or decorated Beans
             InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
 
-            ClassLoader classLoader = annotatedType.getJavaClass().getClassLoader();
+            ClassLoader classLoader = webBeansContext.getApplicationBoundaryService().getBoundaryClassLoader(annotatedType.getJavaClass());
 
             Method[] businessMethods = methodInterceptors.keySet().toArray(new Method[methodInterceptors.size()]);
             Method[] nonInterceptedMethods = interceptorInfo.getNonInterceptedMethods().toArray(new
Method[interceptorInfo.getNonInterceptedMethods().size()]);

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
Tue Nov 25 12:40:39 2014
@@ -53,7 +53,6 @@ public abstract class AbstractProxyFacto
 
     protected WebBeansContext webBeansContext;
 
-
     /**
      * contains the instance of sun.misc.Unsafe.
      * We use it for creating the proxy instance without fully
@@ -77,6 +76,11 @@ public abstract class AbstractProxyFacto
         initializeUnsafe();
     }
 
+    protected ClassLoader getProxyClassLoader(Class<?> beanClass)
+    {
+        return webBeansContext.getApplicationBoundaryService().getBoundaryClassLoader(beanClass);
+    }
+
     /**
      * @return the marker interface which should be used for this proxy.
      */

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/InterceptorDecoratorProxyFactory.java
Tue Nov 25 12:40:39 2014
@@ -169,7 +169,7 @@ public class InterceptorDecoratorProxyFa
      *
      *
      * @param bean the bean the proxy serves for. Needed for caching and serialisation.
-     * @param classLoader to use for creating the class in
+     * @param classLoader to use for creating the class
      * @param classToProxy the class for which a subclass will get generated
      * @param interceptedMethods the list of intercepted or decorated business methods.
      * @param nonInterceptedMethods all methods which are <b>not</b> intercepted
nor decorated and shall get delegated directly

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
Tue Nov 25 12:40:39 2014
@@ -119,11 +119,11 @@ public class NormalScopeProxyFactory ext
         final ClassLoader classLoader;
         if (bean.getBeanClass() != null)
         {
-            classLoader = bean.getBeanClass().getClassLoader();
+            classLoader = getProxyClassLoader(bean.getBeanClass());
         }
         else if (OwbBean.class.isInstance(bean) && OwbBean.class.cast(bean).getReturnType()
!= null)
         {
-            classLoader = OwbBean.class.cast(bean).getReturnType().getClassLoader();
+            classLoader = getProxyClassLoader(OwbBean.class.cast(bean).getReturnType());
         }
         else
         {

Modified: openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1641609&r1=1641608&r2=1641609&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/branches/owb_1.2.x/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Tue Nov 25 12:40:39 2014
@@ -40,6 +40,11 @@ org.apache.webbeans.spi.ContainerLifecyc
 org.apache.webbeans.spi.JNDIService=org.apache.webbeans.corespi.se.DefaultJndiService
 ################################################################################################
 
+########################### Default ApplicationBoundary Service ################################
+#Default implementation of org.apache.webbeans.corespi.JNDIService.
+org.apache.webbeans.spi.ApplicationBoundaryService=org.apache.webbeans.corespi.se.DefaultApplicationBoundaryService
+################################################################################################
+
 ################################### Default Scanner Service ####################################
 #Default implementation of org.apache.webbeans.corespi.ScannerService.
 org.apache.webbeans.spi.ScannerService=org.apache.webbeans.corespi.se.DefaultScannerService

Added: openwebbeans/branches/owb_1.2.x/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.2.x/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java?rev=1641609&view=auto
==============================================================================
--- openwebbeans/branches/owb_1.2.x/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
(added)
+++ openwebbeans/branches/owb_1.2.x/webbeans-spi/src/main/java/org/apache/webbeans/spi/ApplicationBoundaryService.java
Tue Nov 25 12:40:39 2014
@@ -0,0 +1,42 @@
+/*
+ * 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.webbeans.spi;
+
+/**
+ * This service allows EE containers to define an 'outer boundary' for their applications.
+ *
+ * E.g. if the class EntityManager resides in a shared container lib folder then any
+ * CDI proxy for it should still at maximum use the Applications ClassLoader to load the
proxy for it.
+ * This needs to be done to ensure that we don't create a class leak by loading the class
with the
+ * container ClassLoader but are not able to throw this CL away.
+ */
+public interface ApplicationBoundaryService
+{
+    /**
+     *
+     * @return The 'outermost' ClassLoader of that Application
+     */
+    ClassLoader getApplicationClassLoader();
+
+    /**
+     * @return the ClassLoader which shall get used to e.g. proxy that very class.
+     */
+    ClassLoader getBoundaryClassLoader(Class classToProxy);
+
+}



Mime
View raw message