Class ResourcepathMonitor
java.lang.Object
java.lang.Thread
clazzfish.monitor.util.Shutdowner
clazzfish.monitor.AbstractMonitor
clazzfish.monitor.ResourcepathMonitor
- All Implemented Interfaces:
AbstractMonitorMBean,ResourcepathMonitorMBean,Shutdownable,Runnable
Analogous to ClasspathMonitor this class allows you to ask for resources in
the classpath. Originally this class was part of the PatternTesting project.
- Author:
- oliver
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis operation dumps the different MBean attributes to the given directory.getDoublet(String name, int nr) Gets the doublet.String[]Looks for each found doublet resource in which classpath it was found.protected URI[]Gets the URIs of the doublet resourcepath.String[]Gets the doublets.getFirstDoublet(String name) Returns the first doublet of the given classname or resource.String[]Gets the classpath which contains incompatible resources.protected URI[]Gets the classpath which contains incompatible resources.String[]Incompatible resources are doublets with different content.static ResourcepathMonitorYes, it is a Singleton because it offers only some services.intgetNoResources(String name) Gets the number of resources.String[]Scans the classpath for all resources.getResourcesFor(String name) Gets the resources for a given name.booleanIs the given classname or resource a doublet, e.g. can it be found several times in the classpath?static booleanIf you want to ask JMX if bean is already registered you can use this method.voidlogMe()Logs the different array to the log output.static voidWith this method you can register theResourcepathMonitorwith the default name.static voidUnregister ResourcepathMonitor as MBean.whichResource(String name) Looks if the given resource can be found in the classpath.Methods inherited from class clazzfish.monitor.AbstractMonitor
copyResource, dump, dump, dumpArray, dumpArray, dumpHeadline, dumpMe, dumpMe, getDumpDir, isMBean, registerMeAsMBean, registerMeAsMBean, registerMeAsMBean, run, toString, toStringArray, unregisterMeAsMBeanMethods inherited from class clazzfish.monitor.util.Shutdowner
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHookMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, yieldMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface clazzfish.monitor.AbstractMonitorMBean
dumpMe, dumpMe, getDumpDirMethods inherited from interface clazzfish.monitor.util.Shutdownable
addMeAsShutdownHook, isShutdownHook, removeMeAsShutdownHook
-
Constructor Details
-
ResourcepathMonitor
protected ResourcepathMonitor()We offer only some services. So there is no need to instantiate it from outside.
-
-
Method Details
-
getInstance
Yes, it is a Singleton because it offers only some services. So we don't need the object twice.- Returns:
- the only instance
-
registerAsMBean
public static void registerAsMBean()With this method you can register theResourcepathMonitorwith the default name.You can only register the
ResourcepathMonitoronce only. If you want to register it with another name you have to first unregister it. -
unregisterAsMBean
public static void unregisterAsMBean()Unregister ResourcepathMonitor as MBean. -
isRegisteredAsMBean
public static boolean isRegisteredAsMBean()If you want to ask JMX if bean is already registered you can use this method.- Returns:
- true if class is registered as MBean
-
getResources
Scans the classpath for all resources. For performance reason we return no longer a copy but the origin array. Don't do changes for the returned array!- Specified by:
getResourcesin interfaceResourcepathMonitorMBean- Returns:
- all resources as String array
-
whichResource
Looks if the given resource can be found in the classpath.- Specified by:
whichResourcein interfaceResourcepathMonitorMBean- Parameters:
name- of a resource e.g. "log4j.properties"- Returns:
- URI of the given resource (or null if resource was not found)
- See Also:
-
getResourcesFor
Gets the resources for a given name.- Parameters:
name- the name- Returns:
- the resources as URL enumeration
-
getNoResources
Gets the number of resources.- Specified by:
getNoResourcesin interfaceResourcepathMonitorMBean- Parameters:
name- the name of the resource- Returns:
- number of resources
- See Also:
-
isDoublet
@Description("is the given classname or resource found more than once in the classpath?") public boolean isDoublet(String name) 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.- Specified by:
isDoubletin interfaceResourcepathMonitorMBean- Parameters:
name- a classname or resource- Returns:
- true if more than one classname or resource was found in the classpath
- Throws:
NoSuchElementException- the no such element exceptionNoSuchElementException- if no classname or resource was found- See Also:
-
getFirstDoublet
@Description("returns the first doublet of the given classname or resource") public URI getFirstDoublet(String name) Returns the first doublet of the given classname or resource.- Specified by:
getFirstDoubletin interfaceResourcepathMonitorMBean- Parameters:
name- a classname or resource- Returns:
- the first doublet
- See Also:
-
getDoublet
Gets the doublet.- Specified by:
getDoubletin interfaceResourcepathMonitorMBean- Parameters:
name- the namenr- the nr- Returns:
- the doublet
- See Also:
-
getDoublets
Gets the doublets.Note: The Manifest file (META-INF/MANIFEST.MF) ist not counted as doublet file because it is not really a resource.
- Specified by:
getDoubletsin interfaceResourcepathMonitorMBean- Returns:
- the doublets
- See Also:
-
getDoubletResourcepath
@Description("returns the classpath where doublets were found") public String[] getDoubletResourcepath()Looks for each found doublet resource in which classpath it was found. Resources like META-INF/MANIFEST.MF are not considered as doublet - otherwise you'll find all classpathes in the array.- Specified by:
getDoubletResourcepathin interfaceResourcepathMonitorMBean- Returns:
- the classpath where doublets were found
-
getDoubletResourcepathURIs
Gets the URIs of the doublet resourcepath. Doublets in the META-INF folder are filtered out because these resources contains often some meta information of the JAR.- Returns:
- the URIs of the doublets
-
getIncompatibleResources
Incompatible resources are doublets with different content.- Specified by:
getIncompatibleResourcesin interfaceResourcepathMonitorMBean- Returns:
- doublet resources with different content
-
getIncompatibleResourcepath
Gets the classpath which contains incompatible resources. Resources in the META-INF folder are filtered out because resources in this folder contains often only some meta info of the JAR.- Specified by:
getIncompatibleResourcepathin interfaceResourcepathMonitorMBean- Returns:
- the classpathes where incompatible resources were found
-
getIncompatibleResourcepathURIs
Gets the classpath which contains incompatible resources. Resources in the META-INF folder are filtered out because resources in this folder contains often only some meta info of the JAR.- Returns:
- the resourcepath as array of URIs
-
logMe
public void logMe()Logs the different array to the log output.- Specified by:
logMein interfaceAbstractMonitorMBean- Specified by:
logMein classAbstractMonitor
-
dumpMe
This operation dumps the different MBean attributes to the given directory.- Overrides:
dumpMein classAbstractMonitor- Parameters:
dumpDir- the directory where the attributes are dumped to.- Throws:
IOException- Signals that an I/O exception has occurred.
-