[weld-commits] Weld SVN: r6212 - in core/trunk: tests/src/main/java/org/jboss/weld/mock/cluster and 1 other directory.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Mon May 3 15:31:26 EDT 2010
Author: dallen6
Date: 2010-05-03 15:31:26 -0400 (Mon, 03 May 2010)
New Revision: 6212
Added:
core/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/ClusterClassLoader.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java
Log:
Changed the way class loaders are retrieved...experimental and needs testing in JBoss AS
Modified: 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 2010-05-03 13:40:20 UTC (rev 6211)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SimpleProxyServices.java 2010-05-03 19:31:26 UTC (rev 6212)
@@ -18,6 +18,7 @@
package org.jboss.weld.bean.proxy.util;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.ProtectionDomain;
@@ -39,14 +40,24 @@
public ClassLoader getClassLoader(Class<?> type)
{
- if (type.getName().startsWith("java"))
- {
- return this.getClass().getClassLoader();
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ } else {
+ return Thread.currentThread().getContextClassLoader();
}
- else
- {
- return type.getClassLoader();
- }
+// if (type.getName().startsWith("java"))
+// {
+// return this.getClass().getClassLoader();
+// }
+// else
+// {
+// return type.getClassLoader();
+// }
}
public ProtectionDomain getProtectionDomain(Class<?> type)
@@ -81,7 +92,8 @@
{
public Object run() throws Exception
{
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ //ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = getClassLoader(this.getClass());
return Class.forName(className, true, cl);
}
});
Added: core/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/ClusterClassLoader.java
===================================================================
--- core/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/ClusterClassLoader.java (rev 0)
+++ core/trunk/tests/src/main/java/org/jboss/weld/mock/cluster/ClusterClassLoader.java 2010-05-03 19:31:26 UTC (rev 6212)
@@ -0,0 +1,33 @@
+/*
+ * 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.mock.cluster;
+
+/**
+ * Class loader (CL) used during cluster tests so that proxies are not loaded into the
+ * CL being used by the test framework.
+ *
+ * @author David Allen
+ *
+ */
+public class ClusterClassLoader extends ClassLoader
+{
+ public ClusterClassLoader(ClassLoader parentClassLoader)
+ {
+ super(parentClassLoader);
+ }
+}
More information about the weld-commits
mailing list