public class ZooKeeperClassLoader extends ClassLoader implements CallbackClassLoader, org.I0Itec.zkclient.IZkDataListener, org.I0Itec.zkclient.IZkChildListener
ClassLoader
pulling classes from ZooKeeper.
This class loader allows listeners to be registered to receive callbacks when
the ZooKeeper data changes.Constructor and Description |
---|
ZooKeeperClassLoader(ClassLoader parentClassloader,
org.I0Itec.zkclient.ZkClient zk,
String rootPath) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ClassLoaderListener listener)
Add a change listener
|
void |
handleChildChange(String parentPath,
List<String> currentChilds)
Calls any listeners.
|
void |
handleDataChange(String dataPath,
Object data)
Calls any listeners.
|
void |
handleDataDeleted(String dataPath)
Calls any listeners.
|
Class<?> |
loadClass(String name)
|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public ZooKeeperClassLoader(ClassLoader parentClassloader, org.I0Itec.zkclient.ZkClient zk, String rootPath)
parentClassloader
- the (required) parent class loaderzk
- the ZK client to run againstrootPath
- the ZK root path (akin to a classpath entry)public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception
handleChildChange
in interface org.I0Itec.zkclient.IZkChildListener
Exception
public void handleDataChange(String dataPath, Object data) throws Exception
handleDataChange
in interface org.I0Itec.zkclient.IZkDataListener
Exception
public void handleDataDeleted(String dataPath) throws Exception
handleDataDeleted
in interface org.I0Itec.zkclient.IZkDataListener
Exception
public void addListener(ClassLoaderListener listener)
addListener
in interface CallbackClassLoader
listener
- the listener that will be called if there are any
changes to classes already loadedpublic Class<?> loadClass(String name) throws ClassNotFoundException
loadClass
in class ClassLoader
ClassNotFoundException
Copyright © 2014. All rights reserved.