All Downloads are FREE. Search and download functionalities are using the official Maven repository.

patterntesting.runtime.monitor.ClasspathMonitorMBean Maven / Gradle / Ivy

Go to download

PatternTesting Runtime (patterntesting-rt) is the runtime component for the PatternTesting framework. It provides the annotations and base classes for the PatternTesting testing framework (e.g. patterntesting-check, patterntesting-concurrent or patterntesting-exception) but can be also used standalone for classpath monitoring or profiling. It uses AOP and AspectJ to perform this feat.

The newest version!
package patterntesting.runtime.monitor;

import java.io.Serializable;
import java.net.*;

/**
 * All the methods which might help you to find classpath problems are
 * collected in this JMX interface.
 * Most of the methods returns a String because this can be easily shown in
 * the JConsole.
 *
 * @author oliver
 * @version $Revision: 1.16 $
 */
public interface ClasspathMonitorMBean extends Serializable {

    /**
     * Looks if the given resource can be found in the classpath.
     * 
* To avoid problems like "java.rmi.UnmarshalException: failed to unmarshal * class java.lang.Object; nested exception is: java.io.IOException: unknown * protocol: zip" no longer a URL but URI is now returned * * @param name of a resource e.g. "log4j.properties" * @return URI of the given resource (or null if resource was not found) */ public URI whichResource(String name); /** * Looks if the given classname can be found in the classpath. *
* To avoid problems like "java.rmi.UnmarshalException: failed to unmarshal * class java.lang.Object; nested exception is: java.io.IOException: unknown * protocol: zip" no longer a URL but URI is now returned * * @param name of a class e.g. "java.lang.String" * @return URI of the given resource (or null if resource was not found) */ public URI whichClass(String name); /** * Get number of resources. * * @param name of the resource * @return how often the resource was found */ public int getNoResources(String name); /** * Get the number of different versions of the given class. * * @param classname * @return how often the classname was found in the classpath */ public int getNoClasses(String classname); /** * Is the given classname or resource a doublet, e.g. can it be found * several times in the classpath? * If the classname or resource is not in the classpath a * java.util.NoSuchElementException will be thrown. * * @param name a classname or resource * @return true if more than one classname or resource was found in the * classpath * @throws java.util.NoSuchElementException if no classname or resource was found */ public boolean isDoublet(String name); /** * Returns the first doublet of the given classname or resource. * * @param name a classname or resource * @return the first doublet */ public URL getFirstDoublet(String name); /** * Looks for each loaded class if it is a doublet or not. * * @return a sorted array with the found doublets */ public String[] getDoublets(); /** * Looks for each found doublet in which classpath it was found. * * @return the classpath where doublets were found */ public String[] getDoubletClasspath(); /** * Returns the n'th doublet of the given classname or resource * * @param name a classname or resource * @param n * @return the n'th doublet URL */ public URL getDoublet(String name, int n); /** * Returns the packages which were loaded by the classloader. * The loaded packages are returned as string array so that it can * be displayed by the 'jconsole'. * * @return the packages as string array */ public String[] getLoadedPackages(); /** * Returns the classes which were loaded by the classloader. * The loaded packages are returned as string array so that it can * be displayed by the 'jconsole'. * * @return the classes as string array */ public String[] getLoadedClasses(); /** * Is the given classname already loaded? * * @param classname * @return true if given classname is already loaded */ public boolean isLoaded(String classname); /** * Returns the classes which are not yet loaded. These are the classes * returned by getClasspathClasses() but not by getLoadedClasses(). * * @return the classes which are not yet loaded */ public String[] getUnusedClasses(); /** * Gets the loaded classpath (without the bootclasspath) as URI array. * * @return the loaded classpath (sorted) */ public String[] getUsedClasspath(); /** * The unused classpath is this path which are not used in past. * * @return the unused classpath (sorted) */ public String[] getUnusedClasspath(); /** * Gets the boot classpath. * * @return boot classpath */ public String[] getBootClasspath(); /** * Gets the normal classpath which is also available by the * system property "java.class.path". * * @return the classpath as String array */ public String[] getClasspath(); /** * Looks in the normal classpath after all classes and returns it as * String array. * * @return all found classes in the classpath */ public String[] getClasspathClasses(); /** * @param classname * @return the serialVersionUID of the given class * (or null if the class does not have one) * @throws IllegalAccessException */ public Long getSerialVersionUID(String classname) throws IllegalAccessException; /** * If a MANIFEST is found for a given class the attributes in this * file should be returned as a string array. * E.g. for commons-lang-2.3.jar the string array may looks like *
     * Manifest-Version: 1.0
     * Ant-Version: Apache Ant 1.6.5
     * Created-By: 1.3.1_09-85 ("Apple Computer, Inc.")
     * Package: org.apache.commons.lang
     * Extension-Name: commons-lang
     * Specification-Version: 2.3
     * Specification-Vendor: Apache Software Foundation
     * Specification-Title: Commons Lang
     * Implementation-Version: 2.3
     * Implementation-Vendor: Apache Software Foundation
     * Implementation-Title: Commons Lang
     * Implementation-Vendor-Id: org.apache
     * X-Compile-Source-JDK: 1.3
     * X-Compile-Target-JDK: 1.1
     * 
* * @param classname * @return the attribute entries of the Manifest * (or emtpy array if no Manifest or no attributes are found) */ public String[] getManifestEntries(String classname); /** * Incompatible classes are doublets with different serialVersionUID. * * @return doublet classes with different serialVersionUID */ public String[] getIncompatibleClasses(); /** * @return the classpathes where incompatible classes were found */ public String[] getIncompatibleClasspath(); /** * @return true if it is a known classloader */ public boolean isClassloaderSupported(); /** * Returns some information about the classloader. At least the user * should be informed if it is a unknown classloader which is not * supported or not tested. * * @return e.g. "unknown classloader xxx - classpath can be wrong" */ public String getClassloaderInfo(); /** * Prints the different MBean attributes to the log output. */ public void logMe(); /** * This operation dumps the different MBean attributes to a temporary * file with the prefix "cpmon" (for ClasspathMonitor) and the * extension ".txt". */ public void dumpMe(); /** * Is multi threading enabled? * @since 0.9.7 * @return true if multi threading is enabled for this class. */ public boolean isMultiThreadingEnabled(); /** * Here you can enable or disable the multi threading mode. * @since 0.9.7 * @param enabled */ public void setMultiThreadingEnabled(boolean enabled); } /* * $Log: ClasspathMonitorMBean.java,v $ * Revision 1.16 2009/12/19 22:34:09 oboehm * trailing spaces removed * * Revision 1.15 2009/09/21 08:11:35 oboehm * 2860629 fixed (you can now ask for the manifest entries for a class) * * Revision 1.14 2009/09/18 13:54:52 oboehm * javadoc warnings fixed * * Revision 1.13 2009/08/21 19:59:22 oboehm * multi threading support added * * Revision 1.12 2009/05/19 18:59:37 oboehm * part of ClasspathMonitor extracted to ClasspathDigger * (the classloader dependent part) * * Revision 1.11 2009/05/12 20:02:06 oboehm * fixing 2787695 * * Revision 1.10 2009/05/09 19:47:06 oboehm * isLoaded(String) implemented and tested * * $Source: /cvsroot/patterntesting/PatternTesting08/patterntesting-rt/src/main/java/patterntesting/runtime/monitor/ClasspathMonitorMBean.java,v $ */




© 2015 - 2025 Weber Informatics LLC | Privacy Policy