本文整理汇总了Java中org.springframework.instrument.classloading.LoadTimeWeaver类的典型用法代码示例。如果您正苦于以下问题:Java LoadTimeWeaver类的具体用法?Java LoadTimeWeaver怎么用?Java LoadTimeWeaver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoadTimeWeaver类属于org.springframework.instrument.classloading包,在下文中一共展示了LoadTimeWeaver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBeanClassLoader
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@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");
}
}
}
示例2: createServerSpecificLoadTimeWeaver
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader) {
String name = classLoader.getClass().getName();
try {
if (name.startsWith("weblogic")) {
return new WebLogicLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.glassfish")) {
return new GlassFishLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.apache.catalina")) {
return new TomcatLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.jboss")) {
return new JBossLoadTimeWeaver(classLoader);
}
else if (name.startsWith("com.ibm")) {
return new WebSphereLoadTimeWeaver(classLoader);
}
}
catch (IllegalStateException ex) {
logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
}
return null;
}
示例3: postProcessBeforeInitialization
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof LoadTimeWeaverAware) {
LoadTimeWeaver ltw = this.loadTimeWeaver;
if (ltw == null) {
Assert.state(this.beanFactory != null,
"BeanFactory required if no LoadTimeWeaver explicitly specified");
ltw = this.beanFactory.getBean(
ConfigurableApplicationContext.LOAD_TIME_WEAVER_BEAN_NAME, LoadTimeWeaver.class);
}
((LoadTimeWeaverAware) bean).setLoadTimeWeaver(ltw);
}
return bean;
}
示例4: createEntityManagerFactoryBean
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
/**
* @param testObject The test instance, not null
* @param jpaConfig The configuration parameters for the <code>EntityManagerFactory</code>
* @return A completely configured <code>AbstractEntityManagerFactoryBean</code>
*/
protected AbstractEntityManagerFactoryBean createEntityManagerFactoryBean(Object testObject, JpaConfig jpaConfig) {
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
factoryBean.setDataSource(getDataSource());
factoryBean.setJpaVendorAdapter(getJpaProviderSupport().getSpringJpaVendorAdaptor());
String persistenceXmlFile = jpaConfig.getConfigFiles().iterator().next();
if (!StringUtils.isEmpty(persistenceXmlFile)) {
factoryBean.setPersistenceXmlLocation(persistenceXmlFile);
}
factoryBean.setPersistenceUnitName(jpaConfig.getPersistenceUnitName());
LoadTimeWeaver loadTimeWeaver = getJpaProviderSupport().getLoadTimeWeaver();
if (loadTimeWeaver != null) {
factoryBean.setLoadTimeWeaver(loadTimeWeaver);
}
if (jpaConfig.getConfigMethod() != null) {
try {
ReflectionUtils.invokeMethod(testObject, jpaConfig
.getConfigMethod(), factoryBean);
} catch (InvocationTargetException e) {
throw new UnitilsException("Error while invoking custom config method", e.getCause());
}
}
factoryBean.afterPropertiesSet();
return factoryBean;
}
示例5: serverEntityManagerFactory
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Bean(name = "entityManagerFactory")
@DependsOn("flyway")
@Profile("sqlDb")
public LocalContainerEntityManagerFactoryBean serverEntityManagerFactory(DataSource dataSource,
JpaVendorAdapter vendorAdapter,
LoadTimeWeaver loadTimeWeaver,
Properties hibernateProperties) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setJpaVendorAdapter(vendorAdapter);
em.setLoadTimeWeaver(loadTimeWeaver);
em.setJpaProperties(hibernateProperties);
em.setPackagesToScan(ENTITIES_PACKAGE);
return em;
}
示例6: setBeanClassLoader
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
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");
}
}
}
示例7: createServerSpecificLoadTimeWeaver
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader) {
String name = classLoader.getClass().getName();
try {
if (name.startsWith("weblogic")) {
return new WebLogicLoadTimeWeaver(classLoader);
}
else if (name.startsWith("oracle")) {
return new OC4JLoadTimeWeaver(classLoader);
}
else if (name.startsWith("com.sun.enterprise") || name.startsWith("org.glassfish")) {
return new GlassFishLoadTimeWeaver(classLoader);
}
else if (name.startsWith("org.jboss")) {
return new JBossLoadTimeWeaver(classLoader);
}
else if (name.startsWith("com.ibm")) {
return new WebSphereLoadTimeWeaver(classLoader);
}
}
catch (IllegalStateException ex) {
logger.info("Could not obtain server-specific LoadTimeWeaver: " + ex.getMessage());
}
return null;
}
示例8: enableLTW_withAjWeavingDisabled
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Test
public void enableLTW_withAjWeavingDisabled() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(EnableLTWConfig_withAjWeavingDisabled.class);
ctx.refresh();
LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
verifyZeroInteractions(loadTimeWeaver);
}
示例9: enableLTW_withAjWeavingAutodetect
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Test
public void enableLTW_withAjWeavingAutodetect() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(EnableLTWConfig_withAjWeavingAutodetect.class);
ctx.refresh();
LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
// no expectations -> a class file transformer should NOT be added
// because no META-INF/aop.xml is present on the classpath
verifyZeroInteractions(loadTimeWeaver);
}
示例10: enableLTW_withAjWeavingEnabled
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Test
public void enableLTW_withAjWeavingEnabled() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(EnableLTWConfig_withAjWeavingEnabled.class);
ctx.refresh();
LoadTimeWeaver loadTimeWeaver = ctx.getBean("loadTimeWeaver", LoadTimeWeaver.class);
verify(loadTimeWeaver).addTransformer(isA(ClassFileTransformer.class));
}
示例11: inMemoryEntityManagerFactory
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Bean(name = "entityManagerFactory")
@Profile("h2Db")
public LocalContainerEntityManagerFactoryBean inMemoryEntityManagerFactory(DataSource dataSource,
JpaVendorAdapter vendorAdapter,
LoadTimeWeaver loadTimeWeaver,
Properties hibernateProperties) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setJpaVendorAdapter(vendorAdapter);
em.setLoadTimeWeaver(loadTimeWeaver);
em.setJpaProperties(hibernateProperties);
em.setPackagesToScan(ENTITIES_PACKAGE);
return em;
}
示例12: postProcessBeforeInitialization
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof LoadTimeWeaverAware) {
LoadTimeWeaver ltw = this.loadTimeWeaver;
if (ltw == null) {
Assert.state(this.beanFactory != null,
"BeanFactory required if no LoadTimeWeaver explicitly specified");
ltw = this.beanFactory.getBean(
ConfigurableApplicationContext.LOAD_TIME_WEAVER_BEAN_NAME, LoadTimeWeaver.class);
}
((LoadTimeWeaverAware) bean).setLoadTimeWeaver(ltw);
}
return bean;
}
示例13: loadTimeWeaver
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
/**
* Create a new InstrumentationLoadTimeWeaver for the default ClassLoader.
*/
@Bean()
public LoadTimeWeaver loadTimeWeaver() {
return new org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver();
}
示例14: setLoadTimeWeaver
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Override
public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver) {
this.loadTimeWeaver = loadTimeWeaver;
}
示例15: init
import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
/**
* Initialize this PersistenceUnitInfo with the LoadTimeWeaver SPI interface
* used by Spring to add instrumentation to the current class loader.
*/
public void init(LoadTimeWeaver loadTimeWeaver) {
Assert.notNull(loadTimeWeaver, "LoadTimeWeaver must not be null");
this.loadTimeWeaver = loadTimeWeaver;
this.classLoader = loadTimeWeaver.getInstrumentableClassLoader();
}