org/objectweb/proactive/core/classloader/ProActiveRMIClassLoaderSpi.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.classloader;
00032 
00033 import java.net.MalformedURLException;
00034 import java.rmi.server.RMIClassLoader;
00035 import java.rmi.server.RMIClassLoaderSpi;
00036 
00037 
00055 public class ProActiveRMIClassLoaderSpi extends RMIClassLoaderSpi {
00056     private ClassLoader proActiveClassLoader = null;
00057     RMIClassLoaderSpi rmiClassLoaderSpi = RMIClassLoader.getDefaultProviderInstance();
00058     private boolean useProActiveClassLoader = ClassLoader.getSystemClassLoader()
00059                                                          .toString().startsWith("org.objectweb.proactive.core.classloader.ProActiveClassLoader");
00060 
00061     public ProActiveRMIClassLoaderSpi() {
00062         if (useProActiveClassLoader) {
00063             // enforce defaultLoader
00064             proActiveClassLoader = ClassLoader.getSystemClassLoader();
00065         }
00066     }
00067 
00073     public Class<?> loadClass(String codebase, String name,
00074         ClassLoader defaultLoader)
00075         throws MalformedURLException, ClassNotFoundException {
00076         return rmiClassLoaderSpi.loadClass(codebase, name,
00077             ((proActiveClassLoader != null) ? proActiveClassLoader : defaultLoader));
00078     }
00079 
00085     public Class<?> loadProxyClass(String codebase, String[] interfaces,
00086         ClassLoader defaultLoader)
00087         throws MalformedURLException, ClassNotFoundException {
00088         return rmiClassLoaderSpi.loadProxyClass(codebase, interfaces,
00089             ((proActiveClassLoader != null) ? proActiveClassLoader : defaultLoader));
00090     }
00091 
00092     /*
00093      * @see RMIClassLoaderSpi#getClassLoader(java.lang.String)
00094      */
00095     public ClassLoader getClassLoader(String codebase)
00096         throws MalformedURLException {
00097         if (proActiveClassLoader != null) {
00098             return proActiveClassLoader;
00099         } else {
00100             return rmiClassLoaderSpi.getClassLoader(codebase);
00101         }
00102     }
00103 
00104     /*
00105      * @see RMIClassLoaderSpi#getClassAnnotation(java.lang.Class)
00106      */
00107     public String getClassAnnotation(Class arg0) {
00108         return rmiClassLoaderSpi.getClassAnnotation(arg0);
00109     }
00110 }

Generated on Mon Jan 22 15:16:06 2007 for ProActive by  doxygen 1.5.1