KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployment > ClasspathExtension


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.deployment;
23
24 import java.net.URL JavaDoc;
25 import javax.management.ObjectName JavaDoc;
26 import org.jboss.mx.loading.LoaderRepositoryFactory;
27 import org.jboss.mx.loading.RepositoryClassLoader;
28 import org.jboss.system.ServiceMBeanSupport;
29
30
31 /** A service that allows one to add an arbitrary URL to a named LoaderRepository.
32  *
33  * Created: Sun Jun 30 13:17:22 2002
34  *
35  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
36  * @version $Revision: 57108 $
37  *
38  * @jmx:mbean name="jboss:type=Service,service=ClasspathExtension"
39  * extends="org.jboss.system.ServiceMBean"
40  */

41 public class ClasspathExtension
42    extends ServiceMBeanSupport
43    implements ClasspathExtensionMBean
44 {
45    private String JavaDoc metadataURL;
46    private ObjectName JavaDoc loaderRepository;
47    private RepositoryClassLoader ucl;
48
49    public ClasspathExtension()
50    {
51       
52    }
53
54    /**
55     * mbean get-set pair for field metadataURL
56     * Get the value of metadataURL
57     * @return value of metadataURL
58     *
59     * @jmx:managed-attribute
60     */

61    public String JavaDoc getMetadataURL()
62    {
63       return metadataURL;
64    }
65
66    /**
67     * Set the value of metadataURL
68     * @param metadataURL Value to assign to metadataURL
69     *
70     * @jmx:managed-attribute
71     */

72    public void setMetadataURL(String JavaDoc metadataURL)
73    {
74       this.metadataURL = metadataURL;
75    }
76
77    /**
78     * mbean get-set pair for field loaderRepository
79     * Get the value of loaderRepository
80     * @return value of loaderRepository
81     *
82     * @jmx:managed-attribute
83     */

84    public ObjectName JavaDoc getLoaderRepository()
85    {
86       return loaderRepository;
87    }
88    
89    
90    /**
91     * Set the value of loaderRepository
92     * @param loaderRepository Value to assign to loaderRepository
93     *
94     * @jmx:managed-attribute
95     */

96    public void setLoaderRepository(ObjectName JavaDoc loaderRepository)
97    {
98       this.loaderRepository = loaderRepository;
99    }
100
101    protected void createService() throws Exception JavaDoc
102    {
103       if (metadataURL != null)
104       {
105          URL JavaDoc url = new URL JavaDoc(metadataURL);
106          if( loaderRepository == null )
107             loaderRepository = LoaderRepositoryFactory.DEFAULT_LOADER_REPOSITORY;
108          Object JavaDoc[] args = {url, url, Boolean.TRUE};
109          String JavaDoc[] sig = {"java.net.URL", "java.net.URL", "boolean"};
110          ucl = (RepositoryClassLoader) server.invoke(loaderRepository,
111             "newClassLoader",args, sig);
112       } // end of if ()
113
}
114
115    protected void destroyService() throws Exception JavaDoc
116    {
117       if (ucl != null)
118          ucl.unregister();
119    }
120
121 }// ClasspathExtension
122
Popular Tags