use of org.glassfish.flashlight.provider.FlashlightProbe in project Payara by payara.
the class FlashlightProbeClientMediator method handleListenerAnnotations.
/**
* Pick out all methods in the listener with the correct annotation, look up
* the referenced Probe and return a list of all such pairs. Validate that
* the methods really do matchup properly.
*
* @throws RuntimeException if there is any serious problem.
* @param listenerClass
* @return
*/
private List<MethodProbe> handleListenerAnnotations(Class listenerClass, String invokerId) {
List<MethodProbe> mp = new LinkedList<MethodProbe>();
for (Method method : listenerClass.getMethods()) {
ProbeListener probeAnn = method.getAnnotation(ProbeListener.class);
if (probeAnn == null)
continue;
String probeString = probeAnn.value();
if (probeString == null)
continue;
if (invokerId != null) {
String[] strArr = probeString.split(":");
probeString = strArr[0] + ":" + strArr[1] + ":" + strArr[2] + invokerId + ":" + strArr[3];
}
FlashlightProbe probe = probeRegistry.getProbe(probeString);
if (probe == null) {
String errStr = localStrings.getLocalString("probeNotRegistered", "Probe is not registered: {0}", probeString);
throw new RuntimeException(errStr);
}
mp.add(new MethodProbe(method, probe));
}
return mp;
}
use of org.glassfish.flashlight.provider.FlashlightProbe in project Payara by payara.
the class FlashlightProbeClientMediator method registerDTraceListener.
private Object registerDTraceListener(FlashlightProbeProvider propro, List<ProbeClientMethodHandle> pcms, List<FlashlightProbe> probesRequiringClassTransformation) {
// The "listener" needs to be registered against every Probe in propro...
Collection<FlashlightProbe> probes = propro.getProbes();
Object listener = null;
for (FlashlightProbe probe : probes) {
ProbeClientInvoker invoker = ProbeClientInvokerFactory.createDTraceInvoker(probe);
ProbeClientMethodHandleImpl hi = new ProbeClientMethodHandleImpl(invoker.getId(), invoker, probe);
pcms.add(hi);
if (probe.addInvoker(invoker))
probesRequiringClassTransformation.add(probe);
if (listener == null)
// all the probes in propro have the same "listener"
listener = probe.getDTraceProviderImpl();
}
return listener;
}
use of org.glassfish.flashlight.provider.FlashlightProbe in project Payara by payara.
the class ProbeRegistry method getAllProbes.
public Collection<FlashlightProbe> getAllProbes() {
Collection<FlashlightProbe> allProbes = probeMap.values();
Collection<FlashlightProbe> visibleProbes = new ArrayList<FlashlightProbe>();
for (FlashlightProbe probe : allProbes) {
if (!probe.isHidden())
visibleProbes.add(probe);
}
return visibleProbes;
}
use of org.glassfish.flashlight.provider.FlashlightProbe in project Payara by payara.
the class ProbeFactory method createProbe.
public static FlashlightProbe createProbe(Class providerClazz, String moduleProviderName, String moduleName, String probeProviderName, String probeName, String[] paramNames, Class[] paramTypes, boolean self, boolean hidden, boolean stateful, boolean statefulReturn, boolean statefulException, String[] profileNames) {
int id = counter.incrementAndGet();
FlashlightProbe probe = new FlashlightProbe(id, providerClazz, moduleProviderName, moduleName, probeProviderName, probeName, paramNames, paramTypes, self, hidden, stateful, statefulReturn, statefulException, profileNames);
probeRegistry.registerProbe(probe);
return probe;
}
use of org.glassfish.flashlight.provider.FlashlightProbe in project Payara by payara.
the class ProviderImplGenerator method generateConstructor.
private void generateConstructor(ClassWriter cw, String generatedClassName, FlashlightProbeProvider provider) {
Method m = Method.getMethod("void <init> ()");
GeneratorAdapter gen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, m, null, null, cw);
gen.loadThis();
gen.invokeConstructor(Type.getType(Object.class), m);
Type probeRegType = Type.getType(ProbeRegistry.class);
Type probeType = Type.getType(FlashlightProbe.class);
gen.loadThis();
for (FlashlightProbe probe : provider.getProbes()) {
gen.dup();
String fieldName = "_flashlight_" + probe.getProbeName();
gen.push(probe.getId());
gen.invokeStatic(probeRegType, Method.getMethod("org.glassfish.flashlight.provider.FlashlightProbe getProbeById(int)"));
gen.visitFieldInsn(Opcodes.PUTFIELD, generatedClassName, fieldName, probeType.getDescriptor());
}
gen.pop();
// return the value from constructor
gen.returnValue();
gen.endMethod();
}
Aggregations