Class QClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.jpos.q2.QClassLoader
- All Implemented Interfaces:
Closeable, FileFilter, AutoCloseable, QClassLoaderMBean
Q2 Class Loader (scans deploy/lib directory for new jars)
-
Constructor Summary
ConstructorsConstructorDescriptionQClassLoader(MBeanServer server, File libDir, ObjectName loaderName, ClassLoader mainClassLoader) Constructs a Q2 classloader and registers it with the given MBean server. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidAdds a URL to the class loader's search path.voidForcesscan(boolean)to instantiate a fresh classloader on its next call.booleanIndicates whether the watched lib directory has changed since the last scan.scan(boolean forceNewClassLoader) Re-scans the lib directory, replacing the live class loader if needed, and returns the up-to-date loader.Methods inherited from class URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class SecureClassLoader
defineClass, defineClassMethods inherited from class ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
QClassLoader
public QClassLoader(MBeanServer server, File libDir, ObjectName loaderName, ClassLoader mainClassLoader) Constructs a Q2 classloader and registers it with the given MBean server.- Parameters:
server- MBean server hosting this classloaderlibDir- directory scanned for.jarfilesloaderName- JMX name under which this loader is registeredmainClassLoader- parent class loader
-
-
Method Details
-
addURL
Description copied from interface:QClassLoaderMBeanAdds a URL to the class loader's search path.- Specified by:
addURLin interfaceQClassLoaderMBean- Parameters:
url- URL string (any form parsable byURL)- Throws:
MalformedURLException- ifurlis not a valid URL
-
accept
- Specified by:
acceptin interfaceFileFilter
-
isModified
Indicates whether the watched lib directory has changed since the last scan.- Returns:
trueiflibDiris readable and its mtime has advanced
-
scan
public QClassLoader scan(boolean forceNewClassLoader) throws InstanceAlreadyExistsException, InstanceNotFoundException, NotCompliantMBeanException, MBeanRegistrationException Re-scans the lib directory, replacing the live class loader if needed, and returns the up-to-date loader.- Parameters:
forceNewClassLoader- force a fresh loader even when the directory is unchanged- Returns:
- the (possibly new) classloader
- Throws:
InstanceAlreadyExistsException- if the loader can't be re-registeredInstanceNotFoundException- if the previous loader can't be unregisteredNotCompliantMBeanException- if the loader fails MBean compliance checksMBeanRegistrationException- if MBean (un)registration fails
-
forceNewClassLoaderOnNextScan
Forcesscan(boolean)to instantiate a fresh classloader on its next call.
-