You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by di...@apache.org on 2005/10/21 05:05:32 UTC

svn commit: r327078 - in /webservices/wss4j/trunk/src/org/apache/ws/security: handler/WSHandler.java util/Loader.java

Author: dims
Date: Thu Oct 20 20:05:28 2005
New Revision: 327078

URL: http://svn.apache.org/viewcvs?rev=327078&view=rev
Log:
Enhance Loader and WSHandler to be able to override the classloader used to load the classes for PWCallback

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
    webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java?rev=327078&r1=327077&r2=327078&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java Thu Oct 20 20:05:28 2005
@@ -554,7 +554,7 @@
         Class cbClass = null;
         CallbackHandler cbHandler = null;
         try {
-            cbClass = Loader.loadClass(callback);
+            cbClass = Loader.loadClass(getClassLoader(), callback);
         } catch (ClassNotFoundException e) {
             throw new WSSecurityException("WSHandler: cannot load password callback class: "
                     + callback,
@@ -759,7 +759,7 @@
         if (callback != null) {
             Class cbClass = null;
             try {
-                cbClass = Loader.loadClass(callback);
+                cbClass = Loader.loadClass(getClassLoader(), callback);
             } catch (ClassNotFoundException e) {
                 throw new WSSecurityException(
                        "WSHandler: cannot load password callback class: "
@@ -1014,6 +1014,19 @@
 	}
     }
 
+	/**
+	 * Returns the classloader to be used for loading the callback class
+	 * 
+	 * @return class loader
+	 */
+	public ClassLoader getClassLoader() {
+		try {
+			return Loader.getTCL();
+		} catch (Throwable t) {
+			return null;
+		}
+	}
+	
     public abstract Object getOption(String key);
     public abstract Object getProperty(Object msgContext, String key);
 

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java?rev=327078&r1=327077&r2=327078&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/util/Loader.java Thu Oct 20 20:05:28 2005
@@ -84,8 +84,29 @@
      * @throws IllegalAccessException
      * @throws InvocationTargetException
      */
-    private static ClassLoader getTCL() throws IllegalAccessException, InvocationTargetException {
+    static public ClassLoader getTCL() throws IllegalAccessException, InvocationTargetException {
         return Thread.currentThread().getContextClassLoader();
+    }
+
+    /**
+     * Try the specified classloader and then fall back to the loadClass
+     * <p/>
+     *
+     * @param cl
+     * @param clazz
+     * @return Class
+     * @throws ClassNotFoundException
+     */
+    static public Class loadClass(ClassLoader loader, String clazz) throws ClassNotFoundException {
+        try {
+            if(loader != null) {
+                Class c = loader.loadClass(clazz);
+                if (c != null)
+                    return c;
+            }
+        } catch (Throwable e) {
+        }
+        return loadClass(clazz);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org