| Method from org.springframework.aop.framework.AdvisedSupport Detail: |
public void addAdvice(Advice advice) throws AopConfigException {
int pos = this.advisors.size();
addAdvice(pos, advice);
}
|
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));
}
}
Cannot add introductions this way unless the advice implements IntroductionInfo. |
public void addAdvisor(Advisor advisor) {
int pos = this.advisors.size();
addAdvisor(pos, advisor);
}
|
public void addAdvisor(int pos,
Advisor advisor) throws AopConfigException {
if (advisor instanceof IntroductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
}
addAdvisorInternal(pos, advisor);
}
|
public void addAllAdvisors(Advisor[] advisors) {
if (isFrozen()) {
throw new AopConfigException("Cannot add advisor: Configuration is frozen.");
}
if (!ObjectUtils.isEmpty(advisors)) {
for (int i = 0; i < advisors.length; i++) {
Advisor advisor = advisors[i];
if (advisor instanceof IntroductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
}
Assert.notNull(advisor, "Advisor must not be null");
this.advisors.add(advisor);
}
updateAdvisorArray();
adviceChanged();
}
}
Add all of the given advisors to this proxy configuration. |
public void addInterface(Class intf) {
Assert.notNull(intf, "Interface must not be null");
if (!intf.isInterface()) {
throw new IllegalArgumentException("[" + intf.getName() + "] is not an interface");
}
if (!this.interfaces.contains(intf)) {
this.interfaces.add(intf);
adviceChanged();
}
}
Add a new proxied interface. |
protected void adviceChanged() {
synchronized (this.methodCache) {
this.methodCache.clear();
}
}
Invoked when advice has changed. |
public boolean adviceIncluded(Advice advice) {
Assert.notNull(advice, "Advice must not be null");
for (int i = 0; i < this.advisors.size(); i++) {
Advisor advisor = (Advisor) this.advisors.get(i);
if (advisor.getAdvice() == advice) {
return true;
}
}
return false;
}
Is the given advice included in any advisor within this proxy configuration? |
protected void copyConfigurationFrom(AdvisedSupport other) {
copyConfigurationFrom(other, other.targetSource, new ArrayList(other.advisors));
}
Call this method on a new instance created by the no-arg constructor
to create an independent copy of the configuration from the given object. |
protected void copyConfigurationFrom(AdvisedSupport other,
TargetSource targetSource,
List advisors) {
copyFrom(other);
this.targetSource = targetSource;
this.advisorChainFactory = other.advisorChainFactory;
this.interfaces = new ArrayList(other.interfaces);
for (Iterator it = advisors.iterator(); it.hasNext();) {
Advisor advisor = (Advisor) it.next();
if (advisor instanceof IntroductionAdvisor) {
validateIntroductionAdvisor((IntroductionAdvisor) advisor);
}
Assert.notNull(advisor, "Advisor must not be null");
this.advisors.add(advisor);
}
updateAdvisorArray();
adviceChanged();
}
Copy the AOP configuration from the given AdvisedSupport object,
but allow substitution of a fresh TargetSource and a given interceptor chain. |
public int countAdvicesOfType(Class adviceClass) {
Assert.notNull(adviceClass, "Advice class must not be null");
int count = 0;
for (int i = 0; i < this.advisors.size(); i++) {
Advisor advisor = (Advisor) this.advisors.get(i);
if (advisor.getAdvice() != null &&
adviceClass.isAssignableFrom(advisor.getAdvice().getClass())) {
count++;
}
}
return count;
}
Count advices of the given class. |
public AdvisorChainFactory getAdvisorChainFactory() {
return this.advisorChainFactory;
}
Return the advisor chain factory to use (never null). |
public final Advisor[] getAdvisors() {
return this.advisorArray;
}
|
protected final List getAdvisorsInternal() {
return this.advisors;
}
|
AdvisedSupport getConfigurationOnlyCopy() {
AdvisedSupport copy = new AdvisedSupport();
copy.copyFrom(this);
copy.targetSource = EmptyTargetSource.forClass(getTargetClass(), getTargetSource().isStatic());
copy.advisorChainFactory = this.advisorChainFactory;
copy.interfaces = this.interfaces;
copy.advisors = this.advisors;
copy.updateAdvisorArray();
return copy;
}
Build a configuration-only copy of this AdvisedSupport,
replacing the TargetSource |
public List getInterceptorsAndDynamicInterceptionAdvice(Method method,
Class targetClass) {
MethodCacheKey cacheKey = new MethodCacheKey(method);
List cached = (List) this.methodCache.get(cacheKey);
if (cached == null) {
cached = this.advisorChainFactory.getInterceptorsAndDynamicInterceptionAdvice(
this, method, targetClass);
this.methodCache.put(cacheKey, cached);
}
return cached;
}
|
public Class[] getProxiedInterfaces() {
return (Class[]) this.interfaces.toArray(new Class[this.interfaces.size()]);
}
|
public Class getTargetClass() {
return this.targetSource.getTargetClass();
}
|
public TargetSource getTargetSource() {
return this.targetSource;
}
|
public int indexOf(Advisor advisor) {
Assert.notNull(advisor, "Advisor must not be null");
return this.advisors.indexOf(advisor);
}
|
public int indexOf(Advice advice) {
Assert.notNull(advice, "Advice must not be null");
for (int i = 0; i < this.advisors.size(); i++) {
Advisor advisor = (Advisor) this.advisors.get(i);
if (advisor.getAdvice() == advice) {
return i;
}
}
return -1;
}
|
public boolean isInterfaceProxied(Class intf) {
for (Iterator it = this.interfaces.iterator(); it.hasNext();) {
Class proxyIntf = (Class) it.next();
if (intf.isAssignableFrom(proxyIntf)) {
return true;
}
}
return false;
}
|
public boolean isPreFiltered() {
return this.preFiltered;
}
|
public boolean removeAdvice(Advice advice) throws AopConfigException {
int index = indexOf(advice);
if (index == -1) {
return false;
}
else {
removeAdvisor(index);
return true;
}
}
|
public boolean removeAdvisor(Advisor advisor) {
int index = indexOf(advisor);
if (index == -1) {
return false;
}
else {
removeAdvisor(index);
return true;
}
}
|
public void removeAdvisor(int index) throws AopConfigException {
if (isFrozen()) {
throw new AopConfigException("Cannot remove Advisor: Configuration is frozen.");
}
if (index < 0 || index > this.advisors.size() - 1) {
throw new AopConfigException("Advisor index " + index + " is out of bounds: " +
"This configuration only has " + this.advisors.size() + " advisors.");
}
Advisor advisor = (Advisor) this.advisors.get(index);
if (advisor instanceof IntroductionAdvisor) {
IntroductionAdvisor ia = (IntroductionAdvisor) advisor;
// We need to remove introduction interfaces.
for (int j = 0; j < ia.getInterfaces().length; j++) {
removeInterface(ia.getInterfaces()[j]);
}
}
this.advisors.remove(index);
updateAdvisorArray();
adviceChanged();
}
|
public boolean removeInterface(Class intf) {
return this.interfaces.remove(intf);
}
|
public boolean replaceAdvisor(Advisor a,
Advisor b) throws AopConfigException {
Assert.notNull(a, "Advisor a must not be null");
Assert.notNull(b, "Advisor b must not be null");
int index = indexOf(a);
if (index == -1) {
return false;
}
removeAdvisor(index);
addAdvisor(index, b);
return true;
}
|
public void setAdvisorChainFactory(AdvisorChainFactory advisorChainFactory) {
Assert.notNull(advisorChainFactory, "AdvisorChainFactory must not be null");
this.advisorChainFactory = advisorChainFactory;
}
|
public void setInterfaces(Class[] interfaces) {
Assert.notNull(interfaces, "Interfaces must not be null");
this.interfaces.clear();
for (int i = 0; i < interfaces.length; i++) {
addInterface(interfaces[i]);
}
}
Set the interfaces to be proxied. |
public void setPreFiltered(boolean preFiltered) {
this.preFiltered = preFiltered;
}
|
public void setTarget(Object target) {
setTargetSource(new SingletonTargetSource(target));
}
Set the given object as target.
Will create a SingletonTargetSource for the object. |
public void setTargetClass(Class targetClass) {
this.targetSource = EmptyTargetSource.forClass(targetClass);
}
Set a target class to be proxied, indicating that the proxy
should be castable to the given class.
Internally, an org.springframework.aop.target.EmptyTargetSource
for the given target class will be used. The kind of proxy needed
will be determined on actual creation of the proxy.
This is a replacement for setting a "targetSource" or "target",
for the case where we want a proxy based on a target class
(which can be an interface or a concrete class) without having
a fully capable TargetSource available. |
public void setTargetSource(TargetSource targetSource) {
this.targetSource = (targetSource != null ? targetSource : EMPTY_TARGET_SOURCE);
}
|
public String toProxyConfigString() {
return toString();
}
|
public String toString() {
StringBuffer sb = new StringBuffer(getClass().getName() + ": ");
sb.append(this.interfaces.size()).append(" interfaces ");
sb.append(ClassUtils.classNamesToString(this.interfaces)).append("; ");
sb.append(this.advisors.size()).append(" advisors ");
sb.append(this.advisors).append("; ");
sb.append("targetSource [").append(this.targetSource).append("]; ");
sb.append(super.toString());
return sb.toString();
}
For debugging/diagnostic use. |
protected final void updateAdvisorArray() {
this.advisorArray = (Advisor[]) this.advisors.toArray(new Advisor[this.advisors.size()]);
}
Bring the array up to date with the list. |