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.deployment;
023:
024: import java.net.URL;
025: import javax.management.ObjectName;
026: import org.jboss.mx.loading.LoaderRepositoryFactory;
027: import org.jboss.mx.loading.RepositoryClassLoader;
028: import org.jboss.system.ServiceMBeanSupport;
029:
030: /** A service that allows one to add an arbitrary URL to a named LoaderRepository.
031: *
032: * Created: Sun Jun 30 13:17:22 2002
033: *
034: * @author <a href="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
035: * @version $Revision: 57205 $
036: *
037: * @jmx:mbean name="jboss:type=Service,service=ClasspathExtension"
038: * extends="org.jboss.system.ServiceMBean"
039: */
040: public class ClasspathExtension extends ServiceMBeanSupport implements
041: ClasspathExtensionMBean {
042: private String metadataURL;
043: private ObjectName loaderRepository;
044: private RepositoryClassLoader ucl;
045:
046: public ClasspathExtension() {
047:
048: }
049:
050: /**
051: * mbean get-set pair for field metadataURL
052: * Get the value of metadataURL
053: * @return value of metadataURL
054: *
055: * @jmx:managed-attribute
056: */
057: public String getMetadataURL() {
058: return metadataURL;
059: }
060:
061: /**
062: * Set the value of metadataURL
063: * @param metadataURL Value to assign to metadataURL
064: *
065: * @jmx:managed-attribute
066: */
067: public void setMetadataURL(String metadataURL) {
068: this .metadataURL = metadataURL;
069: }
070:
071: /**
072: * mbean get-set pair for field loaderRepository
073: * Get the value of loaderRepository
074: * @return value of loaderRepository
075: *
076: * @jmx:managed-attribute
077: */
078: public ObjectName getLoaderRepository() {
079: return loaderRepository;
080: }
081:
082: /**
083: * Set the value of loaderRepository
084: * @param loaderRepository Value to assign to loaderRepository
085: *
086: * @jmx:managed-attribute
087: */
088: public void setLoaderRepository(ObjectName loaderRepository) {
089: this .loaderRepository = loaderRepository;
090: }
091:
092: protected void createService() throws Exception {
093: if (metadataURL != null) {
094: URL url = new URL(metadataURL);
095: if (loaderRepository == null)
096: loaderRepository = LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY;
097: Object[] args = { url, url, Boolean.TRUE };
098: String[] sig = { "java.net.URL", "java.net.URL", "boolean" };
099: ucl = (RepositoryClassLoader) server.invoke(
100: loaderRepository, "newClassLoader", args, sig);
101: } // end of if ()
102: }
103:
104: protected void destroyService() throws Exception {
105: if (ucl != null)
106: ucl.unregister();
107: }
108:
109: }// ClasspathExtension
|