From: Juha L. <juh...@us...> - 2002-05-02 11:43:21
|
User: juhalindfors Date: 02/05/02 04:43:11 Modified: src/main/javax/management/loading MLet.java Log: VERSION tag handling (F. Minamoto) Revision Changes Path 1.9 +33 -15 jmx/src/main/javax/management/loading/MLet.java Index: MLet.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/loading/MLet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MLet.java 17 Mar 2002 10:35:55 -0000 1.8 +++ MLet.java 2 May 2002 11:43:04 -0000 1.9 @@ -6,9 +6,10 @@ */ package javax.management.loading; -import javax.management.ObjectName; -import javax.management.MBeanServer; + import javax.management.MBeanRegistration; +import javax.management.MBeanServer; +import javax.management.ObjectName; import javax.management.ServiceNotFoundException; import java.net.URL; @@ -37,6 +38,7 @@ import org.jboss.mx.loading.UnifiedLoaderRepository; import org.jboss.mx.server.ServerConstants; +import org.jboss.mx.util.MBeanInstaller; /** * URL classloader capable of parsing an MLet text file adhering to the file @@ -45,7 +47,7 @@ * @see javax.management.loading.MLetMBean * * @author <a href="mailto:ju...@jb...">Juha Lindfors</a>. - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ * * <p><b>Revisions:</b> * @@ -68,6 +70,11 @@ * in case of ULR this classloader is never used to load classes. The ULR * has a set of Unified CLs that match the URLs added to this CL. </li> * </ul> + * + * <p><b>20020501 Fusayuki Minamoto:</b> + * <ul> + * <li> Added MLet text file VERSION tag support </li> + * </ul> */ public class MLet extends URLClassLoader @@ -86,7 +93,9 @@ private MBeanServer server = null; /** Object name of this loader. */ private ObjectName objectName = null; - + /** MBean installer based on MLet version. */ + private MBeanInstaller installer = null; + // Constructors -------------------------------------------------- public MLet() { @@ -116,7 +125,8 @@ this.objectName = name; this.server = server; - + this.installer = new MBeanInstaller(server, this, name); + return name; } @@ -171,7 +181,7 @@ Iterator archives = element.getArchives().iterator(); String codebaseURL = null; - while(archives.hasNext()) + while (archives.hasNext()) { try { @@ -193,6 +203,7 @@ // of createMBean() call will not delegate to DLR even though // the javadoc requires it. Therefore the findClass() should // be overridden to delegate to the repository. + /* mbeans.add(server.createMBean( element.getCode(), (element.getName() != null) ? new ObjectName(element.getName()) : null, @@ -200,22 +211,27 @@ element.getConstructorValues(), element.getConstructorTypes()) ); + */ + + // installer creates or upgrades this mbean based on the MLet version + mbeans.add(installer.installMBean(element)); } catch (Throwable t) { // if mbean can't be created, throwable is added to the return set mbeans.add(t); - + // FIXME: log it System.out.println("MLET ERROR: can't create MBean: " + t.toString()); - } + t.printStackTrace(); + } } } - catch (ParseException e) + catch (ParseException e) { throw new ServiceNotFoundException(e.getMessage()); } - + return mbeans; } @@ -228,12 +244,14 @@ // need to add these UCLs late, after the MBean registration LoaderRepository.getDefaultLoaderRepository().addClassLoader(new UnifiedClassLoader(url)); } - + else { // will probably override to add individual URL CL to repository as well // in the same style as with ULR. This would allow findClass() to safely // delegate to the BLR without having to deal with infinite looping. + // + // ... or use loadClassWithout(cl) [JPL] super.addURL(url); } } @@ -261,10 +279,10 @@ // FIXME throw new Error("NYI"); } - + // Classloader overrides ----------------------------------------- public Class loadClass(String name, boolean resolve) throws ClassNotFoundException - { + { if (System.getProperty(ServerConstants.LOADER_REPOSITORY_CLASS_PROPERTY).equals( ServerConstants.UNIFIED_LOADER_REPOSITORY_CLASS)) { @@ -274,7 +292,7 @@ UnifiedLoaderRepository ulr = (UnifiedLoaderRepository)LoaderRepository.getDefaultLoaderRepository(); return ulr.loadClass(name, resolve, Thread.currentThread().getContextClassLoader()); } - + else { // with BLR multiple class definitions by different classloaders can @@ -283,6 +301,6 @@ return super.loadClass(name, resolve); } } - + } |