|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectjava.lang.Thread
patterntesting.runtime.monitor.ClasspathMonitor
public final class ClasspathMonitor
To avoid classpath problems like double entries of the same class or resource
in the classpath there are several methods available.
To get the boot classpath the system property "sun.boot.class.path" is used to
get them. This will work of course only for the SunVM.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Method Summary | ||
|---|---|---|
static void |
addAsShutdownHook()
You can register the instance as shutdown hook. |
|
void |
addMeAsShutdownHook()
To be able to register the instance as shutdown hook via JMX we can't use a static method - this is the reason why this additional method was added. |
|
void |
dumpMe()
This operation dumps the different MBean attributes to a temporary file with the prefix "cpmon" (for ClasspathMonitor) and the extension ".txt". |
|
String[] |
getBootClasspath()
To get the boot classpath the sytem property "sun.boot.class.path" is used to get them. |
|
|
getClassList(String packageName,
Class<T> type)
Gets the classes of the given type. |
|
String |
getClassLoaderDetails()
Dumps the internal fields of the classloader (after an idea from "Java ist auch eine Insel"). |
|
String |
getClassloaderInfo()
Returns some information about the classloader. |
|
String[] |
getClasspath()
The classpath is stored in the system property "java.class.path". |
|
String[] |
getClasspathClasses()
Scans the classpath for all classes. |
|
Collection<String> |
getClasspathClassList(String packageName)
Gets the classes of a given package name as collection. |
|
Collection<Class<?>> |
getConcreteClassList(String packageName)
Gets a list of concrete classes. |
|
URL |
getDoublet(Class<?> clazz,
int nr)
Gets the doublet. |
|
URL |
getDoublet(String name,
int nr)
Gets the doublet. |
|
String[] |
getDoubletClasspath()
Gets the doublet classpath. |
|
List<Class<?>> |
getDoubletList()
Gets the doublet list. |
|
protected List<Class<?>> |
getDoubletListParallel()
This is an experiment: can we tune getDoubleList() by using thread techniques like consumer-/producer-pattern? |
|
protected List<Class<?>> |
getDoubletListSerial()
Looks for each loaded class if it is a doublet or not. |
|
String[] |
getDoublets()
Gets the doublets. |
|
URL |
getFirstDoublet(Class<?> clazz)
Gets the first doublet. |
|
URL |
getFirstDoublet(String name)
Gets the first doublet. |
|
String[] |
getIncompatibleClasses()
Incompatible classes are doublets with different byte codes. |
|
List<Class<?>> |
getIncompatibleClassList()
Looks for each doublet if it has a different doublets. |
|
String[] |
getIncompatibleClasspath()
Gets the incompatible classpath. |
|
static ClasspathMonitor |
getInstance()
Yes, it is a Singleton because it offers only some services. |
|
String[] |
getLoadedClasses()
As MBean a string array could be displayed by the 'jconsole'. |
|
String |
getLoadedClassesAsString()
Gets the loaded classes as string. |
|
List<Class<?>> |
getLoadedClassList()
Returns a list of classes which were loaded by the classloader. |
|
Package[] |
getLoadedPackageArray()
This method is used by PatternTesting Samples (in packages.jsp). |
|
String[] |
getLoadedPackages()
Gets the loaded packages. |
|
String |
getLoadedPackagesAsString()
If you want to dump all packages you can use this method. |
|
String[] |
getManifestEntries(Class<?> clazz)
If a MANIFEST is found for a given class the attributes in this file should be returned as a string array. |
|
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(Class<?> cl)
Gets the no classes. |
|
int |
getNoClasses(String classname)
Get the number of different versions of the given class. |
|
int |
getNoResources(String name)
Get number of resources. |
|
static URL |
getResource(String name)
Gets the resource. |
|
Enumeration<URL> |
getResources(String name)
Gets the resources. |
|
Long |
getSerialVersionUID(Class<?> clazz)
Gets the serial version uid. |
|
Long |
getSerialVersionUID(String classname)
|
|
String[] |
getUnusedClasses()
Unused classes are classes which are not loaded but which are found in the classpath. |
|
String[] |
getUnusedClasspath()
The unused classpath is this path which are not used in past. |
|
String[] |
getUsedClasspath()
It might be that the used classpath changes during the calculation of it. |
|
SortedSet<URI> |
getUsedClasspathSet()
Gets the loaded classpath (without the bootclasspath) as sorted set. |
|
boolean |
isClassloaderSupported()
Checks if is classloader supported. |
|
boolean |
isDoublet(Class<?> clazz)
Is the given class a doublet, i.e. can it be found more than once in the classpath? |
|
boolean |
isDoublet(String name)
Checks if is doublet. |
|
boolean |
isLoaded(String classname)
Checks if the given classname is loaded. |
|
boolean |
isMultiThreadingEnabled()
Is multi threading enabled? |
|
static boolean |
isRegisteredAsMBean()
If you want to ask JMX if bean is already registered you can ask the MBeanHelper or you can ask this method. |
|
boolean |
isShutdownHook()
Here you can ask if the ClasspathMonitor was already registeres ad shutdown hook. |
|
void |
logMe()
Logs the different array to the log output. |
|
static void |
main(String[] args)
This main method is only for testing the ClasspathMonitor together with the 'jconsole'. |
|
static void |
registerAsMBean()
Register as m bean. |
|
static void |
removeAsShutdownHook()
If you have registered the instance you can now de-register it. |
|
void |
removeMeAsShutdownHook()
If you want to unregister the instance as shutdown hook you can use this (not static) method. |
|
protected void |
reset()
Resets the doubletList and maybe later other things. |
|
void |
run()
This method is called when the ClasspathMonitor is registered as shutdown hook. |
|
void |
setMultiThreadingEnabled(boolean enabled)
Here you can enable or disable the (experimental) multi threading mode to see if it is really faster on a mult-core machine. |
|
String |
toString()
We don't want to use the toString() implementation of the Thread class so we use our own one. |
|
URI |
whichClass(Class<?> clazz)
Where is the given class found in the classpath? |
|
URI |
whichClass(String name)
Which class. |
|
JarFile |
whichClassJar(Class<?> clazz)
Which class jar. |
|
JarFile |
whichClassJar(String classname)
Which class jar. |
|
URI |
whichClassPath(Class<?> clazz)
Returns the jar file or path where the given class was found. |
|
URI |
whichClassPath(Package p)
Which class path. |
|
URI |
whichClassPath(String classname)
Returns the jar file or path where the given classname was found. |
|
URI |
whichResource(String name)
Which resource. |
|
JarFile |
whichResourceJar(String resource)
Which resource jar. |
|
static JarFile |
whichResourceJar(URI resource)
Which resource jar. |
|
URI |
whichResourcePath(String resource)
Returns the jar file or path where the given resource was found. |
|
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
protected void reset()
public static ClasspathMonitor getInstance()
public static void registerAsMBean()
public static boolean isRegisteredAsMBean()
@Description(value="returns the URI of the given resource") public URI whichResource(String name)
whichResource in interface ClasspathMonitorMBeanname - the name
ClasspathMonitorMBean.whichResource(String)public URI whichClass(String name)
whichClass in interface ClasspathMonitorMBeanname - the name
ClasspathMonitorMBean.whichClass(java.lang.String)public URI whichClass(Class<?> clazz)
clazz - the class
public URI whichClassPath(String classname)
classname - e.g. java.lang.String
public URI whichClassPath(Class<?> clazz)
clazz - e.g. Sting.class
public URI whichClassPath(Package p)
p - the p
public URI whichResourcePath(String resource)
resource - e.g. log4j.properties
public JarFile whichClassJar(Class<?> clazz)
clazz - the clazz
public JarFile whichClassJar(String classname)
classname - the classname
public JarFile whichResourceJar(String resource)
resource - the resource
public static JarFile whichResourceJar(URI resource)
resource - the resource
public Enumeration<URL> getResources(String name)
name - the name
public static URL getResource(String name)
name - the name
public int getNoResources(String name)
ClasspathMonitorMBean
getNoResources in interface ClasspathMonitorMBeanname - the name of the resource
ClasspathMonitorMBean.getNoResources(java.lang.String)public int getNoClasses(Class<?> cl)
cl - the cl
public int getNoClasses(String classname)
ClasspathMonitorMBean
getNoClasses in interface ClasspathMonitorMBeanclassname - the classname
ClasspathMonitorMBean.getNoClasses(java.lang.String)public boolean isDoublet(String name)
isDoublet in interface ClasspathMonitorMBeanname - the name
ClasspathMonitorMBean.isDoublet(java.lang.String)public boolean isDoublet(Class<?> clazz)
clazz - the class to be checked
public URL getFirstDoublet(String name)
getFirstDoublet in interface ClasspathMonitorMBeanname - the name
ClasspathMonitorMBean.getFirstDoublet(java.lang.String)public URL getFirstDoublet(Class<?> clazz)
clazz - the class
public URL getDoublet(String name,
int nr)
getDoublet in interface ClasspathMonitorMBeanname - the namenr - the nr
ClasspathMonitorMBean.getDoublet(java.lang.String,
int)
public URL getDoublet(Class<?> clazz,
int nr)
clazz - the clazznr - the nr
public List<Class<?>> getDoubletList()
protected List<Class<?>> getDoubletListSerial()
public String[] getDoublets()
getDoublets in interface ClasspathMonitorMBeanClasspathMonitorMBean.getDoublets()public String[] getDoubletClasspath()
getDoubletClasspath in interface ClasspathMonitorMBeanClasspathMonitorMBean.getDoubletClasspath()public String getClassLoaderDetails()
public boolean isClassloaderSupported()
isClassloaderSupported in interface ClasspathMonitorMBeanpublic String getClassloaderInfo()
getClassloaderInfo in interface ClasspathMonitorMBeanpublic String[] getLoadedPackages()
getLoadedPackages in interface ClasspathMonitorMBeanClasspathMonitorMBean.getLoadedPackages()public Package[] getLoadedPackageArray()
public String getLoadedPackagesAsString()
public List<Class<?>> getLoadedClassList()
public String[] getLoadedClasses()
getLoadedClasses in interface ClasspathMonitorMBeanpublic String getLoadedClassesAsString()
public boolean isLoaded(String classname)
isLoaded in interface ClasspathMonitorMBeanclassname - name of the class
ClasspathMonitorMBean.isLoaded(java.lang.String)public String[] getUnusedClasses()
getUnusedClasses in interface ClasspathMonitorMBeangetLoadedClasses(),
getClasspathClasses()public String[] getClasspathClasses()
getClasspathClasses in interface ClasspathMonitorMBeanpublic Collection<String> getClasspathClassList(String packageName)
packageName - the package name
public <T> Collection<Class<T>> getClassList(String packageName,
Class<T> type)
T - the generic typepackageName - the package nametype - the type
public Collection<Class<?>> getConcreteClassList(String packageName)
packageName - the package name
public SortedSet<URI> getUsedClasspathSet()
public String[] getUsedClasspath()
getUsedClasspath in interface ClasspathMonitorMBeangetUsedClasspath()public String[] getUnusedClasspath()
getUnusedClasspath in interface ClasspathMonitorMBeanpublic String[] getBootClasspath()
getBootClasspath in interface ClasspathMonitorMBeanpublic String[] getClasspath()
getClasspath in interface ClasspathMonitorMBean
public Long getSerialVersionUID(String classname)
throws IllegalAccessException
getSerialVersionUID in interface ClasspathMonitorMBeanclassname - name of the class
IllegalAccessException - if class can't be accessedClasspathMonitorMBean.getSerialVersionUID(java.lang.String)
public Long getSerialVersionUID(Class<?> clazz)
throws IllegalAccessException
clazz - the clazz
IllegalAccessException - the illegal access exceptionpublic String[] getManifestEntries(Class<?> clazz)
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
clazz - the clazz
public String[] getManifestEntries(String classname)
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
getManifestEntries in interface ClasspathMonitorMBeanclassname - (must be in the classpath, otherwise you'll get a
IllegalArgumentException)
public List<Class<?>> getIncompatibleClassList()
public String[] getIncompatibleClasses()
getIncompatibleClasses in interface ClasspathMonitorMBeanpublic String[] getIncompatibleClasspath()
getIncompatibleClasspath in interface ClasspathMonitorMBeanpublic static void addAsShutdownHook()
logMe(),
dumpMe(),
addMeAsShutdownHook(),
removeMeAsShutdownHook()public static void removeAsShutdownHook()
addAsShutdownHook(),
removeMeAsShutdownHook()public void addMeAsShutdownHook()
addMeAsShutdownHook in interface ClasspathMonitorMBeanaddAsShutdownHook()public void removeMeAsShutdownHook()
removeMeAsShutdownHook in interface ClasspathMonitorMBeanremoveAsShutdownHook(),
addMeAsShutdownHook()public boolean isShutdownHook()
isShutdownHook in interface ClasspathMonitorMBeanpublic void run()
run in interface Runnablerun in class ThreadThread.run()public void logMe()
logMe in interface ClasspathMonitorMBeanpublic void dumpMe()
dumpMe in interface ClasspathMonitorMBeanpublic String toString()
toString in class ThreadThread.toString()
public static void main(String[] args)
throws JMException
args - the args
JMException - the JM exceptionpublic boolean isMultiThreadingEnabled()
isMultiThreadingEnabled in interface ClasspathMonitorMBeanpublic void setMultiThreadingEnabled(boolean enabled)
setMultiThreadingEnabled in interface ClasspathMonitorMBeanenabled - the enabledprotected List<Class<?>> getDoubletListParallel()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||