wiki:Instrumentation

Instrumentation

How to Use

  • Start kraken core with -javaagent option.
    java -javaagent:kraken-core-1.3.4-package.jar -jar kraken-core-1.3.4-package.jar
    
  • Get IntrumentationService OSGi service using bundle context or iPOJO require configuration. (org.krakenapps.api.InstrumentationService)
    ServiceReference ref = bundleContext.getServiceReference(InstrumentationService.class.getName());
    InstrumentationService instService = bundleContext.getService(ref);
    
    .. or ..
    
    public class SampleScriptFactory implements ScriptFactory {
        @Requires 
        // you can also use <requires field="instService" /> at component declaration in iPOJO metadata.xml
        private InstrumentationService instService;
    }
    
  • Use InstrumentationService object.
       // inst can be null if you did not start with javaagent option 
       // or JVM does not support instrumentation.
       Instrumentation inst = instService.getInstrumentation();
       long size = inst.getObjectSize(obj);