Decoratorpublic class Decorator extends Object implements InvocationHandlerThis is an implementation of the 'decorator' design pattern using Java's proxy mechanism. |
Fields Summary |
---|
private final T | mObject | private final DecoratorListener | mListener |
Constructors Summary |
---|
private Decorator(T obj, DecoratorListener listener)
this.mObject = obj;
this.mListener = listener;
|
Methods Summary |
---|
public java.lang.Object | invoke(java.lang.Object proxy, java.lang.reflect.Method m, java.lang.Object[] args)
Object result = null;
try {
mListener.onBeforeInvocation(m, args);
result = m.invoke(mObject, args);
mListener.onAfterInvocation(m, args, result);
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
if (!mListener.onCatchException(m, args, t)) {
throw t;
}
} finally {
mListener.onFinally(m, args);
}
return result;
| public static T | newInstance(T obj, android.hardware.camera2.utils.Decorator$DecoratorListener listener)Create a decorator wrapping the specified object's method calls.
return (T)java.lang.reflect.Proxy.newProxyInstance(
obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(),
new Decorator<T>(obj, listener));
|
|