001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mx.loading;
023:
024: import java.net.URL;
025:
026: import javax.management.MalformedObjectNameException;
027: import javax.management.ObjectName;
028: import javax.management.loading.MLet;
029:
030: import org.jboss.logging.Logger;
031:
032: /**
033: * A RepositoryClassLoader that wraps an MLet.
034: *
035: * @author <a href="adrian@jboss.com">Adrian Brock</a>
036: * @version $Revision: 57200 $
037: */
038: class MLetRepositoryClassLoader extends RepositoryClassLoader {
039: // Constants -----------------------------------------------------
040:
041: /** The log */
042: private static final Logger log = Logger
043: .getLogger(MLetRepositoryClassLoader.class);
044:
045: // Attributes -----------------------------------------------------
046:
047: /** The MLet */
048: private MLet mlet;
049:
050: // Static --------------------------------------------------------
051:
052: // Constructors --------------------------------------------------
053:
054: /**
055: * Create a new LoaderRepositoryClassLoader
056: *
057: * @param urls the urls
058: * @param parent the parent classloader
059: */
060: protected MLetRepositoryClassLoader(MLet mlet) {
061: super (mlet.getURLs(), mlet);
062: this .mlet = mlet;
063: }
064:
065: // Public --------------------------------------------------------
066:
067: /**
068: * Get the ObjectName
069: *
070: * @return the object name
071: */
072: public ObjectName getObjectName()
073: throws MalformedObjectNameException {
074: throw new UnsupportedOperationException("Not relevent");
075: }
076:
077: /**
078: * This method simply invokes the super.getURLs() method to access the
079: * list of URLs that make up the RepositoryClassLoader classpath.
080: *
081: * @return the urls that make up the classpath
082: */
083: public URL[] getClasspath() {
084: return mlet.getURLs();
085: }
086:
087: /**
088: * Return all library URLs associated with this RepositoryClassLoader
089: *
090: * <p>Do not remove this method without running the WebIntegrationTestSuite
091: */
092: public URL[] getAllURLs() {
093: return repository.getURLs();
094: }
095:
096: // URLClassLoader overrides --------------------------------------
097:
098: public Class loadClassLocally(String name, boolean resolve)
099: throws ClassNotFoundException {
100: boolean trace = log.isTraceEnabled();
101: if (trace)
102: log.trace("loadClassLocally, " + this + " name=" + name);
103: Class result = null;
104: try {
105: result = mlet.loadClass(name, null);
106: return result;
107: } finally {
108: if (trace) {
109: if (result != null)
110: log.trace("loadClassLocally, " + this + " name="
111: + name + " class=" + result + " cl="
112: + result.getClassLoader());
113: else
114: log.trace("loadClassLocally, " + this + " name="
115: + name + " not found");
116: }
117: }
118: }
119:
120: // Object overrides ----------------------------------------------
121:
122: // Protected -----------------------------------------------------
123:
124: // Package Private -----------------------------------------------
125:
126: // Private -------------------------------------------------------
127:
128: // Inner classes -------------------------------------------------
129: }
|