org.ops4j.peaberry.util
Class Decorators

java.lang.Object
  extended by org.ops4j.peaberry.util.Decorators

public final class Decorators
extends Object

Methods for creating various general purpose ImportDecorators.

Author:
mcculls@gmail.com (Stuart McCulloch)

Method Summary
static
<S> ImportDecorator<S>
chain(ImportDecorator... decorators)
          An ImportDecorator that applies decorators in a chain, right-left.
static
<S> ImportDecorator<S>
intercept(com.google.inject.matcher.Matcher<? super Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors)
          An ImportDecorator that supports MethodInterceptors.
static
<S> ImportDecorator<S>
sticky(Callable<Boolean> resetTask)
          An ImportDecorator that caches the first valid service instance and uses that until it becomes invalid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sticky

public static <S> ImportDecorator<S> sticky(Callable<Boolean> resetTask)
An ImportDecorator that caches the first valid service instance and uses that until it becomes invalid. The decorator then calls the reset task to see if it should reset the cache and get a new service instance.

If no reset task is provided, the service instance cache is never reset.

Note: sticky decorators only really make sense for single services.

Parameters:
resetTask - called when cached service becomes invalid, may be null
Returns:
decorator that caches service instances

chain

public static <S> ImportDecorator<S> chain(ImportDecorator... decorators)
An ImportDecorator that applies decorators in a chain, right-left.

Parameters:
decorators - sequence of decorators
Returns:
decorator combining the given decorators

intercept

public static <S> ImportDecorator<S> intercept(com.google.inject.matcher.Matcher<? super Class<?>> classMatcher,
                                               com.google.inject.matcher.Matcher<? super Method> methodMatcher,
                                               org.aopalliance.intercept.MethodInterceptor... interceptors)
An ImportDecorator that supports MethodInterceptors.

Parameters:
classMatcher - matches interfaces to be intercepted
methodMatcher - matches methods to be intercepted
interceptors - sequence of method interceptors
Returns:
decorator that intercepts imported services


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