[weld-commits] Weld SVN: r6194 - in core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy: util and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Apr 29 13:01:41 EDT 2010


Author: dallen6
Date: 2010-04-29 13:01:41 -0400 (Thu, 29 Apr 2010)
New Revision: 6194

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Log:
ProxyFactory now uses new ProxyServices to get the classloader and protection domains.

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java	2010-04-29 17:00:11 UTC (rev 6193)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java	2010-04-29 17:01:41 UTC (rev 6194)
@@ -39,9 +39,11 @@
 
 import org.jboss.interceptor.proxy.LifecycleMixin;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
+import org.jboss.weld.Container;
 import org.jboss.weld.bean.proxy.util.ClassloaderClassPath;
 import org.jboss.weld.exceptions.DefinitionException;
 import org.jboss.weld.exceptions.WeldException;
+import org.jboss.weld.serialization.spi.ProxyServices;
 import org.slf4j.cal10n.LocLogger;
 
 /**
@@ -84,16 +86,8 @@
    public ProxyFactory(Class<?> proxiedBeanType)
    {
       this.beanType = proxiedBeanType;
-      if (beanType.getName().startsWith("java"))
-      {
-         this.classLoader = this.getClass().getClassLoader();
-         this.protectionDomain = this.getClass().getProtectionDomain();
-      }
-      else
-      {
-         this.classLoader = beanType.getClassLoader();
-         this.protectionDomain = beanType.getProtectionDomain();
-      }
+      this.classLoader = Container.instance().services().get(ProxyServices.class).getClassLoader(beanType);
+      this.protectionDomain = Container.instance().services().get(ProxyServices.class).getProtectionDomain(beanType);
       this.classPool = new ClassPool();
       this.classPool.appendClassPath(new ClassloaderClassPath(classLoader));
       addDefaultAdditionalInterfaces();

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java	2010-04-29 17:01:41 UTC (rev 6194)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.bean.proxy.util;
+
+import java.security.ProtectionDomain;
+
+import org.jboss.weld.serialization.spi.ProxyServices;
+
+/**
+ * A default implementation of the {@link ProxyServices} which simply use the
+ * corresponding information from the proxy type.  An exception is made for
+ * {@code java.*} and {@code javax.*} packages which are often associated
+ * with the system classloader and a more privileged ProtectionDomain.
+ * 
+ * @author David Allen
+ *
+ */
+public class SimpleProxyServices implements ProxyServices
+{
+
+   /* (non-Javadoc)
+    * @see org.jboss.weld.serialization.spi.ProxyServices#getClassLoader(java.lang.Class)
+    */
+   public ClassLoader getClassLoader(Class<?> type)
+   {
+      if (type.getName().startsWith("java"))
+      {
+         return this.getClass().getClassLoader();
+      }
+      else
+      {
+         return type.getClassLoader();
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.weld.serialization.spi.ProxyServices#getProtectionDomain(java.lang.Class)
+    */
+   public ProtectionDomain getProtectionDomain(Class<?> type)
+   {
+      if (type.getName().startsWith("java"))
+      {
+         return this.getClass().getProtectionDomain();
+      }
+      else
+      {
+         return type.getProtectionDomain();
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.weld.bootstrap.api.Service#cleanup()
+    */
+   public void cleanup()
+   {
+      // This implementation requires no cleanup
+
+   }
+
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the weld-commits mailing list