Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* #%L
* BroadleafCommerce Common Libraries
* %%
* Copyright (C) 2009 - 2013 Broadleaf Commerce
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.broadleafcommerce.common.extensibility;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.instrument.Instrumentation;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.CodeSource;
import java.security.PrivilegedAction;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* This class is based on the OpenJPA's org.apache.openjpa.enhance.InstrumentationFactory. It essentially does
* its best to install an instrumentation agent. The preferred or prescribed way to install an instrumentation agent
* is to add the agent as an argument on the command line when starting the JVM. This class attempts to do the
* same thing after the JVM has already started. Unfortunately, this is the only way we know of to attach an agent to
* the JVM except by adding a "javaagent:..." flag on the command line.
*
* @author Kelly Tisdell
* @deprecated Because of classloader differences, this approach is not reliable for some containers. Use the javaagent jvm argument instead to set instrumentation.
*/
@Deprecated
public class InstrumentationRuntimeFactory {
private static final Log LOG = LogFactory.getLog(InstrumentationRuntimeFactory.class);
private static final String IBM_VM_CLASS = "com.ibm.tools.attach.VirtualMachine";
private static final String SUN_VM_CLASS = "com.sun.tools.attach.VirtualMachine";
private static boolean isIBM = false;
private static Instrumentation inst;
/**
* This method is called by the JVM to set the instrumentation. We can't synchronize this because it will cause
* a deadlock with the thread calling the getInstrumentation() method when the instrumentation is installed.
*
* @param agentArgs
* @param instrumentation
*/
public static void agentmain(String agentArgs, Instrumentation instrumentation) {
inst = instrumentation;
}
/**
* This method returns the Instrumentation object provided by the JVM. If the Instrumentation object is null,
* it does its best to add an instrumentation agent to the JVM and then the instrumentation object.
* @return Instrumentation
*/
public static synchronized Instrumentation getInstrumentation() {
if (inst != null) {
return inst;
}
if (System.getProperty("java.vendor").toUpperCase().contains("IBM")) {
isIBM = true;
}
AccessController.doPrivileged(new PrivilegedAction