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:bs@nuxeo.com">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 @Override 053 public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored) 054 throws MalformedURLException, ClassNotFoundException { 055 return delegate.loadProxyClass(codebase, interfaces, Thread.currentThread().getContextClassLoader()); 056 } 057 058 /** 059 * Just delegate 060 */ 061 @Override 062 public Class<?> loadClass(String codebase, String name, ClassLoader ignored) throws MalformedURLException, 063 ClassNotFoundException { 064 return delegate.loadClass(codebase, name, Thread.currentThread().getContextClassLoader()); 065 } 066 067 /** 068 * Just delegate 069 */ 070 @Override 071 public ClassLoader getClassLoader(String codebase) throws MalformedURLException { 072 return delegate.getClassLoader(codebase); 073 } 074 075 /** 076 * Try to delegate an default to the java.rmi.server.codebase on any failure. 077 */ 078 @Override 079 public String getClassAnnotation(Class<?> cl) { 080 return System.getProperty("java.rmi.server.codebase"); 081 } 082}