List of usage examples for java.lang.instrument Instrumentation addTransformer
void addTransformer(ClassFileTransformer transformer);
From source file:com.facebook.infrastructure.continuations.ContinuationAgent.java
public static void premain(String agentArguments, Instrumentation instrumentation) { System.out.println("Inside the ContinuationAgent"); instrumentation .addTransformer(new ContinuationClassTransformer(agentArguments, new BcelClassTransformer())); }
From source file:com.mgmtp.perfload.agent.Agent.java
void addTransformer(final Instrumentation instrumentation) { logger.writeln("Adding transformer..."); instrumentation.addTransformer(transformer); }
From source file:org.apache.cassandra.continuations.CAgent.java
public static void premain(String agentArguments, Instrumentation instrumentation) { instrumentation .addTransformer(new ContinuationClassTransformer(agentArguments, new BcelClassTransformer())); }
From source file:org.metricagent.agent.MetricAgent.java
public static void premain(String agentArgument, Instrumentation instrumentation) { //BasicConfigurator.configure(); log.info("Starting Metric Agent"); configuration = ConfigurationManager.getInstance().loadFromFile(CONFIGURATION_FILENAME); log.info("Configuration : " + configuration.getReporting()); if (configuration.getReporting().getGraphite() != null) { Graphite graphite = configuration.getReporting().getGraphite(); MetricManager.getInstance().initializeGraphiteReporter(graphite.getName(), graphite.getUrl(), graphite.getPort().intValue(), graphite.getPeriod().intValue(), graphite.getBatchSize().intValue()); log.info("Reporting via Graphite; name : {0}, URL :{1} , port :{2} , period : {3}, batchSize: {4}", graphite.getName(), graphite.getUrl(), graphite.getPort().intValue(), graphite.getPeriod().intValue(), graphite.getBatchSize().intValue()); } else if (configuration.getReporting().getCsv() != null) { Csv csv = (Csv) configuration.getReporting().getCsv(); log.info("Reporting via Csv path :{0} period :{1}", csv.getPath(), csv.getPeriod().intValue()); MetricManager.getInstance().initializeCsvReporter(csv.getPath(), csv.getPeriod().intValue()); } else if (configuration.getReporting().getConsole() != null) { MetricManager.getInstance()//from w ww . jav a 2 s. c o m .initializeConsoleReporter(configuration.getReporting().getConsole().getPeriod().intValue()); log.info("Reporting via Console"); } else if (configuration.getReporting().getJmx() != null) { log.info("Reporting via JMX"); MetricManager.getInstance().initializeJmxRerporter(); } instrumentation.addTransformer(new MetricAgent()); }
From source file:org.wavescale.hotload.agent.HotLoadAgent.java
public static void premain(String agentArgs, Instrumentation instrumentation) { ConfigManager configManager = ConfigManager.getInstance(); initConfigManager(agentArgs.split(" ")); LogManager.getLogManager().getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(configManager.getLogLevel()); NotifyHandler watchHandler = new WatchHandler(); try {/* w w w.j a va 2 s .com*/ FileWatcher fileMonitor = new FileWatcher(configManager.getDirsToMonitor(), configManager.isMonitorRecursive()); fileMonitor.addNotifyHandler(watchHandler); instrumentation.addTransformer(new MethodTransformer()); } catch (IOException e) { LOGGER.log(Level.SEVERE, " An I/O error occured with trace:" + e); } }
From source file:org.wso2.das.javaagent.instrumentation.InstrumentingAgent.java
public static void premain(String agentArgs, Instrumentation instrumentation) { InstrumentingAgent.args = agentArgs; InstrumentingAgent agent = new InstrumentingAgent(); InstrumentationDataHolder instDataHolder = InstrumentationDataHolder.getInstance(); agent.setConfigurationFilePath(agentArgs); agent.setLoggingConfiguration();//from w w w . j a v a 2s .c o m if (log.isDebugEnabled()) { log.debug("Starting Instrumentation javaagent"); } try { File file = new File(createAgentConfigFilepath(instDataHolder)); JAXBContext jaxbContext = JAXBContext.newInstance(InstrumentationAgent.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); InstrumentationAgent instAgent = (InstrumentationAgent) jaxbUnmarshaller.unmarshal(file); AgentConnection agentConnection = instAgent.getAgentConnection(); if (agentConnection != null) { List<Scenario> scenarios = instAgent.getScenarios(); for (Scenario scenario : scenarios) { List<InstrumentationClass> instClasses = scenario.getinstrumentationClasses(); for (InstrumentationClass instClass : instClasses) { agent.processClassData(agent, scenario, instClass); } } instDataHolder.setAgentConnection(agentConnection); instDataHolder.setClassMap(agent.classMap); AgentPublisherHolder.getInstance().addAgentConfiguration(agentConnection); Thread connectionWorker = new Thread(new AgentConnectionWorker()); connectionWorker.start(); if (log.isDebugEnabled()) { log.debug("Add transformer to instrumenting classes."); } instrumentation.addTransformer(new InstrumentationClassTransformer()); } } catch (InstrumentationAgentException | JAXBException e) { if (log.isDebugEnabled()) { log.debug("InstrumentationAgent failed due to : " + e.getMessage()); } } }