Java Code Examples for org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#isInstrumentationAvailable()

The following examples show how to use org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#isInstrumentationAvailable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultContextLoadTimeWeaver.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@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());
		}
		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);
			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");
		}
	}
}
 
Example 2
Source File: DefaultContextLoadTimeWeaver.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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());
		}
		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);
			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");
		}
	}
}
 
Example 3
Source File: DefaultContextLoadTimeWeaver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
	LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
	if (serverSpecificLoadTimeWeaver != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Determined server-specific load-time weaver: " +
					serverSpecificLoadTimeWeaver.getClass().getName());
		}
		this.loadTimeWeaver = serverSpecificLoadTimeWeaver;
	}
	else if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		logger.debug("Found Spring's JVM agent for instrumentation");
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(classLoader);
	}
	else {
		try {
			this.loadTimeWeaver = new ReflectiveLoadTimeWeaver(classLoader);
			if (logger.isDebugEnabled()) {
				logger.debug("Using 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:spring-instrument-{version}.jar");
		}
	}
}
 
Example 4
Source File: DefaultPersistenceUnitManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader());
	}
	preparePersistenceUnitInfos();
}
 
Example 5
Source File: DefaultContextLoadTimeWeaver.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
	LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
	if (serverSpecificLoadTimeWeaver != null) {
		if (logger.isDebugEnabled()) {
			logger.debug("Determined server-specific load-time weaver: " +
					serverSpecificLoadTimeWeaver.getClass().getName());
		}
		this.loadTimeWeaver = serverSpecificLoadTimeWeaver;
	}
	else if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		logger.debug("Found Spring's JVM agent for instrumentation");
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(classLoader);
	}
	else {
		try {
			this.loadTimeWeaver = new ReflectiveLoadTimeWeaver(classLoader);
			if (logger.isDebugEnabled()) {
				logger.debug("Using 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");
		}
	}
}
 
Example 6
Source File: DefaultPersistenceUnitManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader());
	}
	preparePersistenceUnitInfos();
}
 
Example 7
Source File: DefaultPersistenceUnitManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader());
	}
	preparePersistenceUnitInfos();
}
 
Example 8
Source File: DefaultPersistenceUnitManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.loadTimeWeaver == null && InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		this.loadTimeWeaver = new InstrumentationLoadTimeWeaver(this.resourcePatternResolver.getClassLoader());
	}
	preparePersistenceUnitInfos();
}
 
Example 9
Source File: AgentInstrumentationInitializer.java    From invesdwin-instrument with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void initialize(final String args, final Instrumentation inst) {
    if (InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
        throw new IllegalStateException(
                "Instrumentation is already available, the agent should have been loaded already!");
    }

    InstrumentationSavingAgent.premain(args, inst);
}
 
Example 10
Source File: Main.java    From invesdwin-instrument with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) {
	DynamicInstrumentationLoader.waitForInitialized();
	DynamicInstrumentationLoader.initLoadTimeWeavingContext();
	if (!InstrumentationLoadTimeWeaver.isInstrumentationAvailable()) {
		throw new IllegalStateException("Instrumentation not available!");
	} else {
		System.out.println("Instrumentation available!");
	}
}
 
Example 11
Source File: DynamicInstrumentationLoader.java    From invesdwin-instrument with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean isInitialized() {
    return InstrumentationLoadTimeWeaver.isInstrumentationAvailable();
}
 
Example 12
Source File: JpaConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
private String detectWeavingMode() {
    return InstrumentationLoadTimeWeaver.isInstrumentationAvailable() ? "true" : "static";
}
 
Example 13
Source File: EspmJpaConfig.java    From cloud-espm-cloud-native with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the weaving mode.
 * 
 * @return string
 */
private String getWeavingMode() {
    return InstrumentationLoadTimeWeaver.isInstrumentationAvailable() ? "true" : "static";
}
 
Example 14
Source File: AbstractJpaTests.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Subclasses should override this method if they wish to disable shadow class loading.
 * <p>The default implementation deactivates shadow class loading if Spring's
 * InstrumentationSavingAgent has been configured on VM startup.
 */
protected boolean shouldUseShadowLoader() {
	return !InstrumentationLoadTimeWeaver.isInstrumentationAvailable();
}