DependencyManager m = new DependencyManager(context);
// helper class that ensures certain steps get executed in sequence
Ensure e = new Ensure();
// create a service provider and consumer
ResourceConsumer c = new ResourceConsumer(e);
Component consumer = m.createComponent()
.setImplementation(c)
.add(m.createResourceDependency()
.setFilter("(&(path=/path/to/*.txt)(host=localhost))")
.setCallbacks("add", "change", "remove"));
Component dynamicProxyConsumer = m.createComponent()
.setFactory(new ResourceConsumerFactory(e), "create")
.add(m.createResourceDependency()
.setFilter("(path=*.doc)")
.setCallbacks("add", null));
ResourceProvider provider = new ResourceProvider(e);
Component resourceProvider = m.createComponent()
.setImplementation(provider)
.add(m.createServiceDependency()
.setService(ResourceHandler.class)
.setCallbacks("add", "remove"));