org.ops4j.peaberry.cache
Class AbstractServiceRegistry

java.lang.Object
  extended by org.ops4j.peaberry.cache.AbstractServiceRegistry
All Implemented Interfaces:
CachingServiceRegistry, ServiceRegistry, ServiceWatcher<Object>
Direct Known Subclasses:
OSGiServiceRegistry

public abstract class AbstractServiceRegistry
extends Object
implements CachingServiceRegistry

Partial ServiceRegistry implementation with generation based caching.

Author:
mcculls@gmail.com (Stuart McCulloch)

Constructor Summary
protected AbstractServiceRegistry(boolean useNativeFilter)
           
 
Method Summary
protected abstract
<T> AbstractServiceListener<T>
createListener(String ldapFilter)
           
 void flush(int targetGeneration)
          Release any unused service instances from the cache.
<T> Iterable<Import<T>>
lookup(Class<T> clazz, AttributeFilter filter)
          Lookup services from the registry, constrained by the given filter.
<T> void
watch(Class<T> clazz, AttributeFilter filter, ServiceWatcher<? super T> watcher)
          Watch for services in the registry, constrained by the given filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ops4j.peaberry.ServiceWatcher
add
 

Constructor Detail

AbstractServiceRegistry

protected AbstractServiceRegistry(boolean useNativeFilter)
Method Detail

lookup

public final <T> Iterable<Import<T>> lookup(Class<T> clazz,
                                            AttributeFilter filter)
Description copied from interface: ServiceRegistry
Lookup services from the registry, constrained by the given filter.

Specified by:
lookup in interface ServiceRegistry
Parameters:
clazz - expected service interface
filter - service attribute filter
Returns:
ordered sequence of imported services, most recommended first

watch

public final <T> void watch(Class<T> clazz,
                            AttributeFilter filter,
                            ServiceWatcher<? super T> watcher)
Description copied from interface: ServiceRegistry
Watch for services in the registry, constrained by the given filter.

Specified by:
watch in interface ServiceRegistry
Parameters:
clazz - expected service interface
filter - service attribute filter
watcher - the watcher that should receive any matching services

flush

public final void flush(int targetGeneration)
Description copied from interface: CachingServiceRegistry
Release any unused service instances from the cache.

Specified by:
flush in interface CachingServiceRegistry
Parameters:
targetGeneration - the generation to flush

createListener

protected abstract <T> AbstractServiceListener<T> createListener(String ldapFilter)


Copyright © 2006-2012 OPS4J - Open Participation Software for Java. All Rights Reserved.