|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsun.tracing.ProviderSkeleton
public abstract class ProviderSkeleton
Provides a common code for implementation of 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.
Field Summary | |
---|---|
protected boolean |
active
|
protected java.util.HashMap<java.lang.reflect.Method,ProbeSkeleton> |
probes
|
protected java.lang.Class<? extends Provider> |
providerType
|
Constructor Summary | |
---|---|
protected |
ProviderSkeleton(java.lang.Class<? extends Provider> type)
Initializes the provider. |
Method Summary | ||
---|---|---|
protected abstract ProbeSkeleton |
createProbe(java.lang.reflect.Method method)
Creates a framework-specific probe subtype. |
|
void |
dispose()
Default provider disposal method. |
|
protected static java.lang.String |
getAnnotationString(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.lang.String defaultValue)
Utility method for getting a string value from an annotation. |
|
protected static java.lang.Object |
getAnnotationValue(java.lang.reflect.AnnotatedElement element,
java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.lang.String methodName,
java.lang.Object defaultValue)
Utility method for calling an arbitrary method in an annotation. |
|
Probe |
getProbe(java.lang.reflect.Method m)
Direct accessor for Probe objects. |
|
protected java.lang.String |
getProviderName()
Gets the user-specified provider name for the user's interface. |
|
void |
init()
Post-constructor initialization routine. |
|
java.lang.Object |
invoke(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Triggers a framework probe when a user interface method is called. |
|
|
newProxyInstance()
Magic routine which creates an implementation of the user's interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean active
protected java.lang.Class<? extends Provider> providerType
protected java.util.HashMap<java.lang.reflect.Method,ProbeSkeleton> probes
Constructor Detail |
---|
protected ProviderSkeleton(java.lang.Class<? extends Provider> type)
type
- the user's interfaceMethod Detail |
---|
protected abstract ProbeSkeleton createProbe(java.lang.reflect.Method method)
method
- A method in the user's interface
public void init()
public <T extends Provider> T newProxyInstance()
invoke()
method of this class (until
overridden by the VM).
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
Provider
or Object
and we
invoke the method directly.
invoke
in interface java.lang.reflect.InvocationHandler
proxy
- the instance whose method was invokedmethod
- the method that was calledargs
- the arguments passed in the call.
public Probe getProbe(java.lang.reflect.Method m)
Probe
objects.
getProbe
in interface Provider
m
- the method corresponding to a probe
public void dispose()
dispose
in interface Provider
protected java.lang.String getProviderName()
protected static java.lang.String getAnnotationString(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.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 java.lang.Object getAnnotationValue(java.lang.reflect.AnnotatedElement element, java.lang.Class<? extends java.lang.annotation.Annotation> annotation, java.lang.String methodName, java.lang.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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |