Interface ClasspathMonitorMBean
- All Superinterfaces:
AbstractMonitorMBean
,Runnable
,Shutdownable
- All Known Implementing Classes:
ClasspathMonitor
@Description("Classpath Monitor to be able to inspect the classpath and to find doublets")
public interface ClasspathMonitorMBean
extends AbstractMonitorMBean
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.
Originally this interface was part of the PatternTesting project where part of this interface was moved to ResourcepathMonitorMBean with v1.6.4 to make this interface more clearly. And it is no longer Serializable because there is no need for it - all informations can be restored from the classpath.
- Author:
- oliver
-
Method Summary
Modifier and TypeMethodDescriptionString[]
Gets the boot classpath.Returns some information about the classloader.String[]
Gets the normal classpath which is also available by the system property "java.class.path".String[]
Looks in the normal classpath after all classes and returns it as String array.getDoublet
(Class<?> clazz, int n) Returns the n'th doublet of the given class.String[]
Looks for each found doublet in which classpath it was found.String[]
Looks for each loaded class if it is a doublet or not.getFirstDoublet
(Class<?> clazz) Returns the first doublet of the given class.String[]
Incompatible classes are doublets with different byte codes.String[]
Gets the incompatible classpath.String[]
Returns the classes which were loaded by the classloader.String[]
Returns the packages which were loaded by the classloader.String[]
getManifestEntries
(String classname) If a MANIFEST is found for a given class the attributes in this file should be returned as a string array.int
getNoClasses
(String classname) Get the number of different versions of the given class.getSerialVersionUID
(String classname) Gets the serial version uid.String[]
Returns the classes which are not yet loaded.String[]
The unused classpath is this path which are not used in past.String[]
Gets the loaded classpath (without the bootclasspath) as URI array.boolean
Is the given class a doublet, e.g. can it be found several times in the classpath?boolean
Is the given classname already loaded?.whichClass
(String name) Looks if the given classname can be found in the classpath.Methods inherited from interface clazzfish.monitor.AbstractMonitorMBean
dumpMe, dumpMe, getDumpDir, logMe
Methods inherited from interface clazzfish.monitor.util.Shutdownable
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHook
-
Method Details
-
whichClass
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
- Parameters:
name
- of a class e.g. "java.lang.String"- Returns:
- URI of the given resource (or null if resource was not found)
-
getNoClasses
@Description("how often the given class is found in the classpath") int getNoClasses(String classname) Get the number of different versions of the given class.- Parameters:
classname
- the name of the class- Returns:
- how often the classname was found in the classpath
-
isDoublet
@Description("is the given classname or resource found more than once in the classpath?") boolean isDoublet(Class<?> clazz) Is the given class a doublet, e.g. can it be found several times in the classpath? This method is the successor of the old isDoublet method which expects a String as argument.- Parameters:
clazz
- the class- Returns:
- true if more than one classname or resource was found in the classpath
- Throws:
NoSuchElementException
- if no classname or resource was found
-
getFirstDoublet
@Description("returns the first doublet of the given classname or resource") URI getFirstDoublet(Class<?> clazz) Returns the first doublet of the given class. This method is the successor of the old isDoublet method which expects a String as argument.- Parameters:
clazz
- the class- Returns:
- the first doublet
-
getDoublets
Looks for each loaded class if it is a doublet or not.- Returns:
- a sorted array with the found doublets
-
getDoubletClasspath
Looks for each found doublet in which classpath it was found.- Returns:
- the classpath where doublets were found
-
getDoublet
@Description("returns the n'th doublet of the given classname or resource") URI getDoublet(Class<?> clazz, int n) Returns the n'th doublet of the given class. This method is the successor of the old isDoublet method which expects a String as argument.- Parameters:
clazz
- the clazzn
- number of wanted doublet- Returns:
- the n'th doublet URL
-
getLoadedPackages
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'.- Returns:
- the packages as string array
-
getLoadedClasses
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'.- Returns:
- the classes as string array
-
isLoaded
Is the given classname already loaded?.- Parameters:
classname
- the name of the class- Returns:
- true if given classname is already loaded
-
getUnusedClasses
Returns the classes which are not yet loaded. These are the classes returned by getClasspathClasses() but not by getLoadedClasses().- Returns:
- the classes which are not yet loaded
-
getUsedClasspath
Gets the loaded classpath (without the bootclasspath) as URI array.- Returns:
- the loaded classpath (sorted)
-
getUnusedClasspath
The unused classpath is this path which are not used in past.- Returns:
- the unused classpath (sorted)
-
getBootClasspath
Gets the boot classpath.- Returns:
- boot classpath
-
getClasspath
@Description("returns the complete classpath which is seen by the application") String[] getClasspath()Gets the normal classpath which is also available by the system property "java.class.path".- Returns:
- the classpath as String array
-
getClasspathClasses
Looks in the normal classpath after all classes and returns it as String array.- Returns:
- all found classes in the classpath
-
getSerialVersionUID
@Description("returns the servialSerialVersionUID of the given class") Long getSerialVersionUID(String classname) throws IllegalAccessException Gets the serial version uid.- Parameters:
classname
- the name of the class- Returns:
- the serialVersionUID of the given class (or null if the class does not have one)
- Throws:
IllegalAccessException
- e.g. if there is no SerialVersionUID
-
getManifestEntries
@Description("return the manifest entries for the given class") String[] getManifestEntries(String classname) 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 likeManifest-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
- Parameters:
classname
- the name of the class- Returns:
- the attribute entries of the Manifest (or emtpy array if no Manifest or no attributes are found)
-
getIncompatibleClasses
@Description("returns the doublet classes with different byte codes") String[] getIncompatibleClasses()Incompatible classes are doublets with different byte codes.- Returns:
- doublet classes with different byte codes
-
getIncompatibleClasspath
@Description("returns the classpath where incompatible classes were found") String[] getIncompatibleClasspath()Gets the incompatible classpath.- Returns:
- the classpathes where incompatible classes were found
-
getClassloaderInfo
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.- Returns:
- e.g. "unknown classloader xxx - classpath can be wrong"
-