public class AspectJProxyFactory extends ProxyCreatorSupport
addAspect(Object)
,
addAspect(Class)
,
getProxy()
,
getProxy(ClassLoader)
,
ProxyFactory
,
Serialized FormModifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.Class<?>,java.lang.Object> |
aspectCache
Cache for singleton aspect instances
|
private AspectJAdvisorFactory |
aspectFactory |
EMPTY_TARGET_SOURCE
Constructor and Description |
---|
AspectJProxyFactory()
Create a new AspectJProxyFactory.
|
AspectJProxyFactory(java.lang.Class<?>[] interfaces)
Create a new
AspectJProxyFactory . |
AspectJProxyFactory(java.lang.Object target)
Create a new AspectJProxyFactory.
|
Modifier and Type | Method and Description |
---|---|
private void |
addAdvisorsFromAspectInstanceFactory(MetadataAwareAspectInstanceFactory instanceFactory)
Add all
Advisors from the supplied MetadataAwareAspectInstanceFactory
to the current chain. |
void |
addAspect(java.lang.Class<?> aspectClass)
Add an aspect of the supplied type to the end of the advice chain.
|
void |
addAspect(java.lang.Object aspectInstance)
Add the supplied aspect instance to the chain.
|
private MetadataAwareAspectInstanceFactory |
createAspectInstanceFactory(AspectMetadata am,
java.lang.Class<?> aspectClass,
java.lang.String aspectName)
Create a
MetadataAwareAspectInstanceFactory for the supplied aspect type. |
private AspectMetadata |
createAspectMetadata(java.lang.Class<?> aspectClass,
java.lang.String aspectName)
Create an
AspectMetadata instance for the supplied aspect type. |
<T> T |
getProxy()
Create a new proxy according to the settings in this factory.
|
<T> T |
getProxy(java.lang.ClassLoader classLoader)
Create a new proxy according to the settings in this factory.
|
private java.lang.Object |
getSingletonAspectInstance(java.lang.Class<?> aspectClass)
Get the singleton aspect instance for the supplied aspect type.
|
addListener, adviceChanged, createAopProxy, getAopProxyFactory, isActive, removeListener, setAopProxyFactory
addAdvice, addAdvice, addAdvisor, addAdvisor, addAdvisors, addAdvisors, addInterface, adviceIncluded, copyConfigurationFrom, copyConfigurationFrom, countAdvicesOfType, getAdvisorChainFactory, getAdvisors, getAdvisorsInternal, getInterceptorsAndDynamicInterceptionAdvice, getProxiedInterfaces, getTargetClass, getTargetSource, indexOf, indexOf, isInterfaceProxied, isPreFiltered, removeAdvice, removeAdvisor, removeAdvisor, removeInterface, replaceAdvisor, setAdvisorChainFactory, setInterfaces, setPreFiltered, setTarget, setTargetClass, setTargetSource, toProxyConfigString, toString, updateAdvisorArray
copyFrom, isExposeProxy, isFrozen, isOpaque, isOptimize, isProxyTargetClass, setExposeProxy, setFrozen, setOpaque, setOptimize, setProxyTargetClass
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isExposeProxy, isFrozen, isProxyTargetClass, setExposeProxy
private static final java.util.Map<java.lang.Class<?>,java.lang.Object> aspectCache
private final AspectJAdvisorFactory aspectFactory
public AspectJProxyFactory()
public AspectJProxyFactory(java.lang.Object target)
Will proxy all interfaces that the given target implements.
target
- the target object to be proxiedpublic AspectJProxyFactory(java.lang.Class<?>[] interfaces)
AspectJProxyFactory
.
No target, only interfaces. Must add interceptors.public void addAspect(java.lang.Object aspectInstance)
aspectInstance
- the AspectJ aspect instancepublic void addAspect(java.lang.Class<?> aspectClass)
aspectClass
- the AspectJ aspect classprivate void addAdvisorsFromAspectInstanceFactory(MetadataAwareAspectInstanceFactory instanceFactory)
Advisors
from the supplied MetadataAwareAspectInstanceFactory
to the current chain. Exposes any special purpose Advisors
if needed.private AspectMetadata createAspectMetadata(java.lang.Class<?> aspectClass, java.lang.String aspectName)
AspectMetadata
instance for the supplied aspect type.private MetadataAwareAspectInstanceFactory createAspectInstanceFactory(AspectMetadata am, java.lang.Class<?> aspectClass, java.lang.String aspectName)
MetadataAwareAspectInstanceFactory
for the supplied aspect type. If the aspect type
has no per clause, then a SingletonMetadataAwareAspectInstanceFactory
is returned, otherwise
a PrototypeAspectInstanceFactory
is returned.private java.lang.Object getSingletonAspectInstance(java.lang.Class<?> aspectClass)
public <T> T getProxy()
Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.
Uses a default class loader: Usually, the thread context class loader (if necessary for proxy creation).
public <T> T getProxy(java.lang.ClassLoader classLoader)
Can be called repeatedly. Effect will vary if we've added or removed interfaces. Can add and remove interceptors.
Uses the given class loader (if necessary for proxy creation).
classLoader
- the class loader to create the proxy with