/** * Programmatic hook to dynamically load {@link CitationAgent} at runtime. * * @throws IOException * if an error occurs */ public synchronized static void initialise() throws IOException { if (!isLoaded) { AgentLoader.loadAgent(CitationAgent.class); isLoaded = true; } }
/** * Create an agent jar file with the required manifest entries. * * @param file * the location to create the jar * @param agentClass * the agent class * @throws IOException * if an error occurs */ public static void createAgentJar(File file, Class<?> agentClass) throws IOException { final JarOutputStream jos = new JarOutputStream(new FileOutputStream(file)); String classEntryPath = agentClass.getName().replace(".", "/") + ".class"; final InputStream classStream = agentClass.getClassLoader().getResourceAsStream(classEntryPath); if (classEntryPath.startsWith("/")) classEntryPath = classEntryPath.substring(1); JarEntry entry = new JarEntry(classEntryPath); jos.putNextEntry(entry); copy(classStream, jos); jos.closeEntry(); entry = new JarEntry("META-INF/MANIFEST.MF"); jos.putNextEntry(entry); jos.write(createManifest(agentClass)); jos.closeEntry(); jos.close(); }
final File tmp = File.createTempFile("agent", ".jar"); tmp.deleteOnExit(); createAgentJar(tmp, agentClass); final String pid = nameOfRunningVM.substring(0, p); final Class<?> vmClass = tryGetVMClass(); loadFailed(); } else { try { loadFailed();
final File tmp = File.createTempFile("agent", ".jar"); tmp.deleteOnExit(); createAgentJar(tmp, agentClass); final String pid = nameOfRunningVM.substring(0, p); final Class<?> vmClass = tryGetVMClass(); loadFailed(); } else { try { loadFailed();
/** * Programmatic hook to dynamically load {@link CitationAgent} at runtime. * * @throws IOException * if an error occurs */ public static synchronized void initialise() throws IOException { if (!isLoaded) { AgentLoader.loadAgent(ExperimentAgent.class); isLoaded = true; } }
/** * Create an agent jar file with the required manifest entries. * * @param file * the location to create the jar * @param agentClass * the agent class * @throws IOException * if an error occurs */ public static void createAgentJar(File file, Class<?> agentClass) throws IOException { final JarOutputStream jos = new JarOutputStream(new FileOutputStream(file)); String classEntryPath = agentClass.getName().replace(".", "/") + ".class"; final InputStream classStream = agentClass.getClassLoader().getResourceAsStream(classEntryPath); if (classEntryPath.startsWith("/")) classEntryPath = classEntryPath.substring(1); JarEntry entry = new JarEntry(classEntryPath); jos.putNextEntry(entry); copy(classStream, jos); jos.closeEntry(); entry = new JarEntry("META-INF/MANIFEST.MF"); jos.putNextEntry(entry); jos.write(createManifest(agentClass)); jos.closeEntry(); jos.close(); }
/** * Programmatic hook to dynamically load {@link CitationAgent} at runtime. * * @throws IOException * if an error occurs */ public static synchronized void initialise() throws IOException { if (!isLoaded) { AgentLoader.loadAgent(ExperimentAgent.class); isLoaded = true; } }