本文整理汇总了Java中org.springframework.aop.framework.AopInfrastructureBean类的典型用法代码示例。如果您正苦于以下问题:Java AopInfrastructureBean类的具体用法?Java AopInfrastructureBean怎么用?Java AopInfrastructureBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AopInfrastructureBean类属于org.springframework.aop.framework包,在下文中一共展示了AopInfrastructureBean类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBeanFactory
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with a BeanFactory "
+ "which does not implement ConfigurableBeanFactory: " + beanFactory.getClass());
}
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
// Required so that references (up container hierarchies) are correctly resolved.
this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);
// Required so that all BeanPostProcessors, Scopes, etc become available.
this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);
// Filter out BeanPostProcessors that are part of the AOP infrastructure,
// since those are only meant to apply to beans defined in the original factory.
for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
if (it.next() instanceof AopInfrastructureBean) {
it.remove();
}
}
}
示例2: buildInternalBeanFactory
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
/**
* Build an internal BeanFactory for resolving target beans.
* @param containingFactory the containing BeanFactory that originally defines the beans
* @return an independent internal BeanFactory to hold copies of some target beans
*/
protected DefaultListableBeanFactory buildInternalBeanFactory(ConfigurableBeanFactory containingFactory) {
// Set parent so that references (up container hierarchies) are correctly resolved.
DefaultListableBeanFactory internalBeanFactory = new DefaultListableBeanFactory(containingFactory);
// Required so that all BeanPostProcessors, Scopes, etc become available.
internalBeanFactory.copyConfigurationFrom(containingFactory);
// Filter out BeanPostProcessors that are part of the AOP infrastructure,
// since those are only meant to apply to beans defined in the original factory.
for (Iterator<BeanPostProcessor> it = internalBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
if (it.next() instanceof AopInfrastructureBean) {
it.remove();
}
}
return internalBeanFactory;
}
示例3: setBeanFactory
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
throw new IllegalStateException("ScriptFactoryPostProcessor doesn't work with a BeanFactory "
+ "which does not implement ConfigurableBeanFactory: " + beanFactory.getClass());
}
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
// Required so that references (up container hierarchies) are correctly
// resolved.
this.scriptBeanFactory.setParentBeanFactory(this.beanFactory);
// Required so that all BeanPostProcessors, Scopes, etc become
// available.
this.scriptBeanFactory.copyConfigurationFrom(this.beanFactory);
// Filter out BeanPostProcessors that are part of the AOP
// infrastructure,
// since those are only meant to apply to beans defined in the original
// factory.
for (Iterator<BeanPostProcessor> it = this.scriptBeanFactory.getBeanPostProcessors().iterator(); it
.hasNext();) {
if (it.next() instanceof AopInfrastructureBean) {
it.remove();
}
}
}
示例4: postProcessAfterInitialization
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AopInfrastructureBean) {
// Ignore AOP infrastructure such as scoped proxies.
return bean;
}
Class<?> targetClass = AopUtils.getTargetClass(bean);
if (AopUtils.canApply(this.advisor, targetClass)) {
if (bean instanceof Advised) {
((Advised) bean).addAdvisor(0, this.advisor);
return bean;
}
else {
ProxyFactory proxyFactory = new ProxyFactory(bean);
// Copy our properties (proxyTargetClass etc) inherited from ProxyConfig.
proxyFactory.copyFrom(this);
proxyFactory.addAdvisor(this.advisor);
return proxyFactory.getProxy(this.beanClassLoader);
}
}
else {
// No async proxy needed.
return bean;
}
}
示例5: postProcessAfterInitialization
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AopInfrastructureBean) {
// Ignore AOP infrastructure such as scoped proxies.
return bean;
}
Class<?> targetClass = AopUtils.getTargetClass(bean);
if (AopUtils.canApply(this.advisor, targetClass)) {
if (bean instanceof Advised) {
((Advised) bean).addAdvisor(0, this.advisor);
return bean;
}
else {
ProxyFactory proxyFactory = new ProxyFactory(bean);
// Copy our properties (proxyTargetClass etc) inherited from ProxyConfig.
proxyFactory.copyFrom(this);
proxyFactory.setProxyTargetClass(true);
proxyFactory.setInterfaces( bean.getClass().getInterfaces());
proxyFactory.addAdvisor(this.advisor);
return proxyFactory.getProxy(this.beanClassLoader);
}
}
else {
// No async proxy needed.
return bean;
}
}
示例6: postProcessAfterInitialization
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
// Check for already serializable, infraestructure or serializable proxy targets.
if (bean instanceof SerializableAopProxy ||
bean instanceof AopInfrastructureBean ||
beanName.startsWith(SerializableProxyUtils.TARGET_NAME_PREFIX))
return bean;
SerializableProxy ann = AnnotationUtils.findAnnotation(bean.getClass(), SerializableProxy.class);
if (ann != null) {
if (log.isDebugEnabled())
log.debug("Creating serializable proxy for bean [" + beanName + "]");
boolean proxyTargetClass = !beanFactory.getType(beanName).isInterface() || ann.proxyTargetClass();
return SerializableProxyUtils.createSerializableProxy(bean, proxyTargetClass, ann.useCache(), beanFactory, beanName);
}
return bean;
}
示例7: setBeanFactory
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
}
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
this.scopedTargetSource.setBeanFactory(beanFactory);
ProxyFactory pf = new ProxyFactory();
pf.copyFrom(this);
pf.setTargetSource(this.scopedTargetSource);
Class<?> beanType = beanFactory.getType(this.targetBeanName);
if (beanType == null) {
throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
"': Target type could not be determined at the time of proxy creation.");
}
if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
}
// Add an introduction that implements only the methods on ScopedObject.
ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));
// Add the AopInfrastructureBean marker to indicate that the scoped proxy
// itself is not subject to auto-proxying! Only its target bean is.
pf.addInterface(AopInfrastructureBean.class);
this.proxy = pf.getProxy(cbf.getBeanClassLoader());
}
示例8: should_create_mock_with_configuration
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
@Test
public void should_create_mock_with_configuration() {
//given
final DoubleDefinition doubleDefinition = DoubleDefinition.builder()
.name("mock")
.doubleClass(Object.class)
.doubleConfiguration(MockitoDoubleConfiguration.builder()
.stubOnly(true)
.verboseLogging(true)
.serializableMode(SerializableMode.ACROSS_CLASSLOADERS)
.answer(NoAnswer.class)
.extraInterfaces(new Class[]{Closeable.class})
.invocationListeners(new Class[]{DoNothingInvocationListener.class})
.build())
.build();
//when
doubleFactory.createMock(doubleDefinition);
//then
Mockito
.verify(mockSettings)
.stubOnly();
Mockito
.verify(mockSettings)
.verboseLogging();
Mockito
.verify(mockSettings)
.serializable(SerializableMode.ACROSS_CLASSLOADERS);
Mockito
.verify(mockSettings)
.defaultAnswer(argThat(hasAnswerOfType(NoAnswer.class)));
Mockito
.verify(mockSettings)
.extraInterfaces(argThat(new PresentInAnyOrder(AopInfrastructureBean.class, Closeable.class)));
Mockito
.verify(mockSettings)
.invocationListeners(argThat(hasInstancesOf(DoNothingInvocationListener.class)));
}
示例9: postProcessAfterInitialization
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof AopInfrastructureBean) {
// Ignore AOP infrastructure such as scoped proxies.
return bean;
}
if (isEligible(bean, beanName)) {
if (bean instanceof Advised) {
Advised advised = (Advised) bean;
if (this.beforeExistingAdvisors) {
advised.addAdvisor(0, this.advisor);
}
else {
advised.addAdvisor(this.advisor);
}
return bean;
}
else {
ProxyFactory proxyFactory = new ProxyFactory(bean);
// Copy our properties (proxyTargetClass etc) inherited from ProxyConfig.
proxyFactory.copyFrom(this);
proxyFactory.addAdvisor(this.advisor);
//只改了这里获取ClassLoader的方式,之前的获取方式不对
return proxyFactory.getProxy(Thread.currentThread().getContextClassLoader());
}
}
else {
// No async proxy needed.
return bean;
}
}
开发者ID:hyberbin,项目名称:hyberbin-osgi,代码行数:32,代码来源:UserPersistenceExceptionTranslationPostProcessor.java
示例10: setBeanFactory
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
public void setBeanFactory(BeanFactory beanFactory) {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
}
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
this.scopedTargetSource.setBeanFactory(beanFactory);
ProxyFactory pf = new ProxyFactory();
pf.copyFrom(this);
pf.setTargetSource(this.scopedTargetSource);
Class<?> beanType = beanFactory.getType(this.targetBeanName);
if (beanType == null) {
throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
"': Target type could not be determined at the time of proxy creation.");
}
if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
}
// Add an introduction that implements only the methods on ScopedObject.
ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));
// Add the AopInfrastructureBean marker to indicate that the scoped proxy
// itself is not subject to auto-proxying! Only its target bean is.
pf.addInterface(AopInfrastructureBean.class);
this.proxy = pf.getProxy(cbf.getBeanClassLoader());
}
示例11: isInfrastructureClass
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
/**
* Return whether the given bean class represents an infrastructure class
* that should never be proxied.
* <p>The default implementation considers Advices, Advisors and
* AopInfrastructureBeans as infrastructure classes.
* @param beanClass the class of the bean
* @return whether the bean represents an infrastructure class
* @see org.aopalliance.aop.Advice
* @see org.springframework.aop.Advisor
* @see org.springframework.aop.framework.AopInfrastructureBean
* @see #shouldSkip
*/
protected boolean isInfrastructureClass(Class<?> beanClass) {
boolean retVal = Advice.class.isAssignableFrom(beanClass) ||
Advisor.class.isAssignableFrom(beanClass) ||
AopInfrastructureBean.class.isAssignableFrom(beanClass);
if (retVal && logger.isTraceEnabled()) {
logger.trace("Did not attempt to auto-proxy infrastructure class [" + beanClass.getName() + "]");
}
return retVal;
}
示例12: enhanceBeanClassWithAopInfrastructureBean
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
/**
* Spock doesn't support multiple interfaces mocking.
* <p>
* In order to get around it we create new class definition and add
* {@link AopInfrastructureBean} marker interface to it which will
* skip proxy creation for this class during bean post processing by
* {@link org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor#postProcessAfterInitialization(Object, String)}
*
* @param mockDefinition
* @return original double class enhanced with {@link AopInfrastructureBean}
*/
private Class<?> enhanceBeanClassWithAopInfrastructureBean(DoubleDefinition mockDefinition) {
return new ByteBuddy()
.subclass(mockDefinition.getDoubleClass())
.implement(AopInfrastructureBean.class)
.make()
.load(getClass().getClassLoader())
.getLoaded();
}
示例13: isInfrastructureClass
import org.springframework.aop.framework.AopInfrastructureBean; //导入依赖的package包/类
/**
* Return whether the given bean class represents an infrastructure class
* that should never be proxied.
* <p>The default implementation considers Advices, Advisors and
* AopInfrastructureBeans as infrastructure classes.
* @param beanClass the class of the bean
* @return whether the bean represents an infrastructure class
* @see org.aopalliance.aop.Advice
* @see org.springframework.aop.Advisor
* @see org.springframework.aop.framework.AopInfrastructureBean
* @see #shouldSkip
*/
protected boolean isInfrastructureClass(Class<?> beanClass) {
boolean retVal = Advice.class.isAssignableFrom(beanClass) ||
Pointcut.class.isAssignableFrom(beanClass) ||
Advisor.class.isAssignableFrom(beanClass) ||
AopInfrastructureBean.class.isAssignableFrom(beanClass);
if (retVal && logger.isTraceEnabled()) {
logger.trace("Did not attempt to auto-proxy infrastructure class [" + beanClass.getName() + "]");
}
return retVal;
}