当前位置: 首页>>代码示例>>Java>>正文


Java LoadTimeWeaver类代码示例

本文整理汇总了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");
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:DefaultContextLoadTimeWeaver.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:DefaultContextLoadTimeWeaver.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:LoadTimeWeaverAwareProcessor.java

示例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;
  }
 
开发者ID:linux-china,项目名称:unitils,代码行数:30,代码来源:JpaEntityManagerFactoryLoader.java

示例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;
}
 
开发者ID:mattpwest,项目名称:entelect-spring-webapp-template,代码行数:17,代码来源:JPAConfig.java

示例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");
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:DefaultContextLoadTimeWeaver.java

示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:DefaultContextLoadTimeWeaver.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:EnableLoadTimeWeavingTests.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:EnableLoadTimeWeavingTests.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:EnableLoadTimeWeavingTests.java

示例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;
}
 
开发者ID:mattpwest,项目名称:entelect-spring-webapp-template,代码行数:16,代码来源:JPAConfig.java

示例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;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:LoadTimeWeaverAwareProcessor.java

示例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();
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:8,代码来源:WebDatasourceConfig.java

示例14: setLoadTimeWeaver

import org.springframework.instrument.classloading.LoadTimeWeaver; //导入依赖的package包/类
@Override
public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver) {
	this.loadTimeWeaver = loadTimeWeaver;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AspectJWeavingEnabler.java

示例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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SpringPersistenceUnitInfo.java


注:本文中的org.springframework.instrument.classloading.LoadTimeWeaver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。