org.springframework.aop.DynamicIntroductionAdvice Java Examples

The following examples show how to use org.springframework.aop.DynamicIntroductionAdvice. 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: AdvisedSupport.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Cannot add introductions this way unless the advice implements IntroductionInfo.
 */
@Override
public void addAdvice(int pos, Advice advice) throws AopConfigException {
	Assert.notNull(advice, "Advice must not be null");
	if (advice instanceof IntroductionInfo) {
		// We don't need an IntroductionAdvisor for this kind of introduction:
		// It's fully self-describing.
		addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice));
	}
	else if (advice instanceof DynamicIntroductionAdvice) {
		// We need an IntroductionAdvisor for this kind of introduction.
		throw new AopConfigException("DynamicIntroductionAdvice may only be added as part of IntroductionAdvisor");
	}
	else {
		addAdvisor(pos, new DefaultPointcutAdvisor(advice));
	}
}
 
Example #2
Source File: AdvisedSupport.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Cannot add introductions this way unless the advice implements IntroductionInfo.
 */
@Override
public void addAdvice(int pos, Advice advice) throws AopConfigException {
	Assert.notNull(advice, "Advice must not be null");
	if (advice instanceof IntroductionInfo) {
		// We don't need an IntroductionAdvisor for this kind of introduction:
		// It's fully self-describing.
		addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice));
	}
	else if (advice instanceof DynamicIntroductionAdvice) {
		// We need an IntroductionAdvisor for this kind of introduction.
		throw new AopConfigException("DynamicIntroductionAdvice may only be added as part of IntroductionAdvisor");
	}
	else {
		addAdvisor(pos, new DefaultPointcutAdvisor(advice));
	}
}
 
Example #3
Source File: AdvisedSupport.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Cannot add introductions this way unless the advice implements IntroductionInfo.
 */
@Override
public void addAdvice(int pos, Advice advice) throws AopConfigException {
	Assert.notNull(advice, "Advice must not be null");
	if (advice instanceof IntroductionInfo) {
		// We don't need an IntroductionAdvisor for this kind of introduction:
		// It's fully self-describing.
		addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice));
	}
	else if (advice instanceof DynamicIntroductionAdvice) {
		// We need an IntroductionAdvisor for this kind of introduction.
		throw new AopConfigException("DynamicIntroductionAdvice may only be added as part of IntroductionAdvisor");
	}
	else {
		addAdvisor(pos, new DefaultPointcutAdvisor(advice));
	}
}
 
Example #4
Source File: AdvisedSupport.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Cannot add introductions this way unless the advice implements IntroductionInfo.
 */
@Override
public void addAdvice(int pos, Advice advice) throws AopConfigException {
	Assert.notNull(advice, "Advice must not be null");
	if (advice instanceof IntroductionInfo) {
		// We don't need an IntroductionAdvisor for this kind of introduction:
		// It's fully self-describing.
		addAdvisor(pos, new DefaultIntroductionAdvisor(advice, (IntroductionInfo) advice));
	}
	else if (advice instanceof DynamicIntroductionAdvice) {
		// We need an IntroductionAdvisor for this kind of introduction.
		throw new AopConfigException("DynamicIntroductionAdvice may only be added as part of IntroductionAdvisor");
	}
	else {
		addAdvisor(pos, new DefaultPointcutAdvisor(advice));
	}
}
 
Example #5
Source File: DelegatePerTargetObjectIntroductionInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// Create a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #6
Source File: DelegatingIntroductionInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Both constructors use this init method, as it is impossible to pass
 * a "this" reference from one constructor to another.
 * @param delegate the delegate object
 */
private void init(Object delegate) {
	Assert.notNull(delegate, "Delegate must not be null");
	this.delegate = delegate;
	implementInterfacesOnObject(delegate);

	// We don't want to expose the control interface
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #7
Source File: DefaultIntroductionAdvisor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void validateInterfaces() throws IllegalArgumentException {
	for (Class<?> ifc : this.interfaces) {
		if (this.advice instanceof DynamicIntroductionAdvice &&
				!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
		 throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
				 "does not implement interface [" + ifc.getName() + "] specified for introduction");
		}
	}
}
 
Example #8
Source File: DelegatePerTargetObjectIntroductionInterceptor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// Create a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #9
Source File: DelegatingIntroductionInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Both constructors use this init method, as it is impossible to pass
 * a "this" reference from one constructor to another.
 * @param delegate the delegate object
 */
private void init(Object delegate) {
	Assert.notNull(delegate, "Delegate must not be null");
	this.delegate = delegate;
	implementInterfacesOnObject(delegate);

	// We don't want to expose the control interface
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #10
Source File: DefaultIntroductionAdvisor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void validateInterfaces() throws IllegalArgumentException {
	for (Class<?> ifc : this.interfaces) {
		if (this.advice instanceof DynamicIntroductionAdvice &&
				!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
		 throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
				 "does not implement interface [" + ifc.getName() + "] specified for introduction");
		}
	}
}
 
Example #11
Source File: DelegatePerTargetObjectIntroductionInterceptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// Create a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #12
Source File: DelegatingIntroductionInterceptor.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Both constructors use this init method, as it is impossible to pass
 * a "this" reference from one constructor to another.
 * @param delegate the delegate object
 */
private void init(Object delegate) {
	Assert.notNull(delegate, "Delegate must not be null");
	this.delegate = delegate;
	implementInterfacesOnObject(delegate);

	// We don't want to expose the control interface
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #13
Source File: DefaultIntroductionAdvisor.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void validateInterfaces() throws IllegalArgumentException {
	for (Class<?> ifc : this.interfaces) {
		if (this.advice instanceof DynamicIntroductionAdvice &&
				!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
		throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
				"does not implement interface [" + ifc.getName() + "] specified for introduction");
		}
	}
}
 
Example #14
Source File: DelegatePerTargetObjectIntroductionInterceptor.java    From java-technology-stack with MIT License 5 votes vote down vote up
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType) {
	this.defaultImplType = defaultImplType;
	this.interfaceType = interfaceType;
	// Create a new delegate now (but don't store it in the map).
	// We do this for two reasons:
	// 1) to fail early if there is a problem instantiating delegates
	// 2) to populate the interface map once and once only
	Object delegate = createNewDelegate();
	implementInterfacesOnObject(delegate);
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #15
Source File: DelegatingIntroductionInterceptor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Both constructors use this init method, as it is impossible to pass
 * a "this" reference from one constructor to another.
 * @param delegate the delegate object
 */
private void init(Object delegate) {
	Assert.notNull(delegate, "Delegate must not be null");
	this.delegate = delegate;
	implementInterfacesOnObject(delegate);

	// We don't want to expose the control interface
	suppressInterface(IntroductionInterceptor.class);
	suppressInterface(DynamicIntroductionAdvice.class);
}
 
Example #16
Source File: DefaultIntroductionAdvisor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void validateInterfaces() throws IllegalArgumentException {
	for (Class<?> ifc : this.interfaces) {
		if (this.advice instanceof DynamicIntroductionAdvice &&
				!((DynamicIntroductionAdvice) this.advice).implementsInterface(ifc)) {
		throw new IllegalArgumentException("DynamicIntroductionAdvice [" + this.advice + "] " +
				"does not implement interface [" + ifc.getName() + "] specified for introduction");
		}
	}
}
 
Example #17
Source File: DefaultIntroductionAdvisor.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create a DefaultIntroductionAdvisor for the given advice.
 * @param advice the Advice to apply
 * @param intf the interface to introduce
 */
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
	addInterface(intf);
}
 
Example #18
Source File: DefaultIntroductionAdvisor.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Create a DefaultIntroductionAdvisor for the given advice.
 * @param advice the Advice to apply
 * @param intf the interface to introduce
 */
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
	addInterface(intf);
}
 
Example #19
Source File: DefaultIntroductionAdvisor.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Create a DefaultIntroductionAdvisor for the given advice.
 * @param advice the Advice to apply
 * @param intf the interface to introduce
 */
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
	addInterface(intf);
}
 
Example #20
Source File: DefaultIntroductionAdvisor.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Create a DefaultIntroductionAdvisor for the given advice.
 * @param advice the Advice to apply
 * @param intf the interface to introduce
 */
public DefaultIntroductionAdvisor(DynamicIntroductionAdvice advice, Class<?> intf) {
	Assert.notNull(advice, "Advice must not be null");
	this.advice = advice;
	addInterface(intf);
}