public abstract class ProviderSkeleton extends Object implements InvocationHandler, Provider
Provider classes.
Each tracing subsystem needs to provide three classes, a factory
(derived from ProviderFactory, a provider (a subclass of
Provider, and a probe type (subclass of ProbeSkeleton).
The factory object takes a user-defined interface and provides an
implementation of it whose method calls will trigger probes in the
tracing framework.
The framework's provider class, and its instances, are not seen by the
user at all -- they usually sit in the background and receive and dispatch
the calls to the user's provider interface. The ProviderSkeleton
class provides almost all of the implementation needed by a framework
provider. Framework providers must only provide a constructor and
disposal method, and implement the createProbe method to create
an appropriate ProbeSkeleton subclass.
The framework's probe class provides the implementation of the two
probe methods, isEnabled() and uncheckedTrigger(). Both are
framework-dependent implementations.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
active |
protected HashMap<Method,ProbeSkeleton> |
probes |
protected Class<? extends Provider> |
providerType |
| Modifier | Constructor and Description |
|---|---|
protected |
ProviderSkeleton(Class<? extends Provider> type)
Initializes the provider.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract ProbeSkeleton |
createProbe(Method method)
Creates a framework-specific probe subtype.
|
void |
dispose()
Default provider disposal method.
|
protected static String |
getAnnotationString(AnnotatedElement element,
Class<? extends Annotation> annotation,
String defaultValue)
Utility method for getting a string value from an annotation.
|
protected static Object |
getAnnotationValue(AnnotatedElement element,
Class<? extends Annotation> annotation,
String methodName,
Object defaultValue)
Utility method for calling an arbitrary method in an annotation.
|
Probe |
getProbe(Method m)
Direct accessor for
Probe objects. |
protected String |
getProviderName()
Gets the user-specified provider name for the user's interface.
|
void |
init()
Post-constructor initialization routine.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Triggers a framework probe when a user interface method is called.
|
<T extends Provider> |
newProxyInstance()
Magic routine which creates an implementation of the user's interface.
|
protected boolean active
protected HashMap<Method,ProbeSkeleton> probes
protected abstract ProbeSkeleton createProbe(Method method)
method - A method in the user's interfacepublic void init()
public <T extends Provider> T newProxyInstance()
invoke() method of this class (until
overridden by the VM).public Object invoke(Object proxy, Method method, Object[] args)
Provider or Object and we
invoke the method directly.invoke in interface InvocationHandlerproxy - the instance whose method was invokedmethod - the method that was calledargs - the arguments passed in the call.public void dispose()
protected String getProviderName()
protected static String getAnnotationString(AnnotatedElement element, Class<? extends Annotation> annotation, String defaultValue)
element - the element that was annotated, either a class or methodannotation - the class of the annotation we're interested indefaultValue - the value to return if the annotation doesn't
exist, doesn't have a "value", or the value is empty.protected static Object getAnnotationValue(AnnotatedElement element, Class<? extends Annotation> annotation, String methodName, Object defaultValue)
element - the element that was annotated, either a class or methodannotation - the class of the annotation we're interested inmethodName - the name of the method in the annotation we wish
to call.defaultValue - the value to return if the annotation doesn't
exist, or we couldn't invoke the method for some reason.Copyright © 2012. All Rights Reserved.