Example usage for org.springframework.instrument.classloading InstrumentationLoadTimeWeaver isInstrumentationAvailable

List of usage examples for org.springframework.instrument.classloading InstrumentationLoadTimeWeaver isInstrumentationAvailable

Introduction

In this page you can find the example usage for org.springframework.instrument.classloading InstrumentationLoadTimeWeaver isInstrumentationAvailable.

Prototype

public static boolean isInstrumentationAvailable() 

Source Link

Document

Check whether an Instrumentation instance is available for the current VM.

Usage

From source file:br.edu.ifpb.JpaCustomConfiguration.java

private String detectWeavingMode() {
    return InstrumentationLoadTimeWeaver.isInstrumentationAvailable() ? "true" : "static";
}

From source file:org.springframework.context.weaving.DefaultContextLoadTimeWeaver.java

@Override
public void setBeanClassLoader(ClassLoader classLoader) {
    LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
    if (serverSpecificLoadTimeWeaver != null) {
        if (logger.isInfoEnabled()) {
            logger.info("Determined server-specific load-time weaver: "
                    + serverSpecificLoadTimeWeaver.getClass().getName());
        }//  w w w  .  j  a  va2s.co m
        this.loadTimeWeaver = serverSpecificLoadTimeWeaver;
    } else if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
        logger.info("Found Spring's JVM agent for instrumentation");
        this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(classLoader);
    } else {
        try {
            this.loadTimeWeaver = new ReflectiveLoadTimeWeaver(classLoader);
            if (logger.isInfoEnabled()) {
                logger.info("Using a reflective load-time weaver for class loader: "
                        + this.loadTimeWeaver.getInstrumentableClassLoader().getClass().getName());
            }
        } catch (IllegalStateException ex) {
            throw new IllegalStateException(ex.getMessage() + " Specify a custom LoadTimeWeaver or start your "
                    + "Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar");
        }
    }
}

From source file:org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.java

@Override
public void afterPropertiesSet() {
    if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
        this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader());
    }//w  w w  . j ava  2  s .c  om
    preparePersistenceUnitInfos();
}