001/* 002 * (C) Copyright 2006 JBoss. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * JBoss 016 * Nuxeo 017 */ 018 019package org.nuxeo.runtime.launcher; 020 021import java.net.MalformedURLException; 022import java.rmi.server.RMIClassLoader; 023import java.rmi.server.RMIClassLoaderSpi; 024 025/** 026 * Copied from org.jboss.system.JBossRMIClassLoader and modified getClassAnnotation to avoid delegating to default 027 * loader since it has a bug. 028 * 029 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 030 */ 031public class NuxeoRMIClassLoader extends RMIClassLoaderSpi { 032 // Attributes ---------------------------------------------------- 033 034 /** 035 * The JVM implementation (we delegate most work to it) 036 */ 037 RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance(); 038 039 // Constructors -------------------------------------------------- 040 041 /** 042 * Required constructor 043 */ 044 public NuxeoRMIClassLoader() { 045 } 046 047 // RMIClassLoaderSpi Implementation ------------------------------ 048 049 /** 050 * Ignore the JVM, use the thread context classloader for proxy caching 051 */ 052 public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored) 053 throws MalformedURLException, ClassNotFoundException { 054 return delegate.loadProxyClass(codebase, interfaces, Thread.currentThread().getContextClassLoader()); 055 } 056 057 /** 058 * Just delegate 059 */ 060 public Class<?> loadClass(String codebase, String name, ClassLoader ignored) throws MalformedURLException, 061 ClassNotFoundException { 062 return delegate.loadClass(codebase, name, Thread.currentThread().getContextClassLoader()); 063 } 064 065 /** 066 * Just delegate 067 */ 068 public ClassLoader getClassLoader(String codebase) throws MalformedURLException { 069 return delegate.getClassLoader(codebase); 070 } 071 072 /** 073 * Try to delegate an default to the java.rmi.server.codebase on any failure. 074 */ 075 public String getClassAnnotation(Class<?> cl) { 076 return System.getProperty("java.rmi.server.codebase"); 077 } 078}