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

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

Introduction

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

Prototype

public InstrumentationLoadTimeWeaver(@Nullable ClassLoader classLoader) 

Source Link

Document

Create a new InstrumentationLoadTimeWeaver for the given ClassLoader.

Usage

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());
        }// ww w. ja va  2  s. c  o  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  a  va  2 s .c o  m
    preparePersistenceUnitInfos();
}