Java Doc for AbstractAutoProxyCreator.java in  » J2EE » spring-framework-2.0.6 » org » springframework » aop » framework » autoproxy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.aop.framework.autoproxy 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.aop.framework.ProxyConfig
      org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator

All known Subclasses:   org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator,  org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator,
AbstractAutoProxyCreator
abstract public class AbstractAutoProxyCreator extends ProxyConfig implements InstantiationAwareBeanPostProcessor,BeanClassLoaderAware,BeanFactoryAware,Ordered,AopInfrastructureBean(Code)
org.springframework.beans.factory.config.BeanPostProcessor implementation that wraps each eligible bean with an AOP proxy, delegating to specified interceptors before invoking the bean itself.

This class distinguishes between "common" interceptors: shared for all proxies it creates, and "specific" interceptors: unique per bean instance. There need not be any common interceptors. If there are, they are set using the interceptorNames property. As with ProxyFactoryBean, interceptors names in the current factory are used rather than bean references to allow correct handling of prototype advisors and interceptors: for example, to support stateful mixins. Any advice type is supported for "interceptorNames" entries.

Such auto-proxying is particularly useful if there's a large number of beans that need to be wrapped with similar proxies, i.e. delegating to the same interceptors. Instead of x repetitive proxy definitions for x target beans, you can register one single such post processor with the bean factory to achieve the same effect.

Subclasses can apply any strategy to decide if a bean is to be proxied, e.g. by type, by name, by definition details, etc. They can also return additional interceptors that should just be applied to the specific bean instance. The default concrete implementation is BeanNameAutoProxyCreator, identifying the beans to be proxied via a list of bean names.

Any number of TargetSourceCreator implementations can be used to create a custom target source - for example, to pool prototype objects. Auto-proxying will occur even if there is no advice, as long as a TargetSourceCreator specifies a custom org.springframework.aop.TargetSource . If there are no TargetSourceCreators set, or if none matches, a org.springframework.aop.target.SingletonTargetSource will be used by default to wrap the target bean instance.
author:
   Juergen Hoeller
author:
   Rod Johnson
author:
   Rob Harrop
since:
   13.10.2003
See Also:   AbstractAutoProxyCreator.setInterceptorNames
See Also:   AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean
See Also:   BeanNameAutoProxyCreator
See Also:   DefaultAdvisorAutoProxyCreator



Field Summary
final protected static  Object[]DO_NOT_PROXY
     Convenience constant for subclasses: Return value for "do not proxy".
final protected static  Object[]PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
     Convenience constant for subclasses: Return value for "proxy without additional interceptors, just the common ones".
final protected  Loglogger
    


Method Summary
protected  Advisor[]buildAdvisors(String beanName, Object[] specificInterceptors)
     Determine the advisors for the given bean, including the specific interceptors as well as the common interceptor, all adapted to the Advisor interface.
protected  ObjectcreateProxy(Class beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource)
     Create an AOP proxy for the given bean.
protected  voidcustomizeProxyFactory(ProxyFactory proxyFactory)
     Subclasses may choose to implement this: for example, to change the interfaces exposed.
abstract protected  Object[]getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource customTargetSource)
     Return whether the given bean is to be proxied, what additional advices (e.g.
protected  BeanFactorygetBeanFactory()
     Return the owning BeanFactory May be null, as this object doesn't need to belong to a bean factory.
protected  ObjectgetCacheKey(Class beanClass, String beanName)
     Build a cache key for the given bean class and bean name.
protected  TargetSourcegetCustomTargetSource(Class beanClass, String beanName)
     Create a target source for bean instances.
final public  intgetOrder()
    
public  booleanisFrozen()
    
protected  booleanisInfrastructureClass(Class beanClass, String beanName)
     Return whether the given bean class and bean name represents an infrastructure class that should never be proxied.
protected  booleanisInfrastructureClass(Class beanClass)
     Return whether the given bean class represents an infrastructure class that should never be proxied.
public  ObjectpostProcessAfterInitialization(Object bean, String beanName)
     Create a proxy with the configured interceptors if the bean is identified as one to proxy by the subclass.
public  booleanpostProcessAfterInstantiation(Object bean, String beanName)
    
public  ObjectpostProcessBeforeInitialization(Object bean, String beanName)
    
public  ObjectpostProcessBeforeInstantiation(Class beanClass, String beanName)
    
public  PropertyValuespostProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
    
public  voidsetAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry)
     Specify the AdvisorAdapterRegistry to use.
public  voidsetApplyCommonInterceptorsFirst(boolean applyCommonInterceptorsFirst)
     Set whether the common interceptors should be applied before bean-specific ones.
public  voidsetBeanClassLoader(ClassLoader classLoader)
    
public  voidsetBeanFactory(BeanFactory beanFactory)
    
public  voidsetCustomTargetSourceCreators(TargetSourceCreator[] targetSourceCreators)
     Set custom TargetSourceCreators to be applied in this order. If the list is empty, or they all return null, a SingletonTargetSource will be created for each bean.

Note that TargetSourceCreators will kick in even for target beans where no advices or advisors have been found.

public  voidsetFrozen(boolean frozen)
     Set whether or not the proxy should be frozen, preventing advice from being added to it once it is created.
public  voidsetInterceptorNames(String[] interceptorNames)
     Set the common interceptors.
final public  voidsetOrder(int order)
     Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors.
protected  booleanshouldProxyTargetClass(Class beanClass, String beanName)
     Determine whether the given bean should be proxied with its target class rather than its interfaces.
protected  booleanshouldSkip(Class beanClass, String beanName)
     Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

Sometimes we need to be able to avoid this happening if it will lead to a circular reference.


Field Detail
DO_NOT_PROXY
final protected static Object[] DO_NOT_PROXY(Code)
Convenience constant for subclasses: Return value for "do not proxy".
See Also:   AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean



PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
final protected static Object[] PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS(Code)
Convenience constant for subclasses: Return value for "proxy without additional interceptors, just the common ones".
See Also:   AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean



logger
final protected Log logger(Code)
Logger available to subclasses





Method Detail
buildAdvisors
protected Advisor[] buildAdvisors(String beanName, Object[] specificInterceptors)(Code)
Determine the advisors for the given bean, including the specific interceptors as well as the common interceptor, all adapted to the Advisor interface.
Parameters:
  beanName - the name of the bean
Parameters:
  specificInterceptors - the set of interceptors that isspecific to this bean (may be empty, but not null) the list of Advisors for the given bean



createProxy
protected Object createProxy(Class beanClass, String beanName, Object[] specificInterceptors, TargetSource targetSource)(Code)
Create an AOP proxy for the given bean.
Parameters:
  beanClass - the class of the bean
Parameters:
  beanName - the name of the bean
Parameters:
  specificInterceptors - the set of interceptors that isspecific to this bean (may be empty, but not null)
Parameters:
  targetSource - the TargetSource for the proxy,already pre-configured to access the bean the AOP proxy for the bean
See Also:   AbstractAutoProxyCreator.buildAdvisors



customizeProxyFactory
protected void customizeProxyFactory(ProxyFactory proxyFactory)(Code)
Subclasses may choose to implement this: for example, to change the interfaces exposed.

The default implementation is empty.
Parameters:
  proxyFactory - ProxyFactory that is already configured withTargetSource and interfaces and will be used to create the proxyimmediably after this method returns




getAdvicesAndAdvisorsForBean
abstract protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource customTargetSource) throws BeansException(Code)
Return whether the given bean is to be proxied, what additional advices (e.g. AOP Alliance interceptors) and advisors to apply.
Parameters:
  beanClass - the class of the bean to advise
Parameters:
  beanName - the name of the bean
Parameters:
  customTargetSource - the TargetSource returned by theAbstractAutoProxyCreator.getCustomTargetSource method: may be ignored.Will be null if no custom target source is in use. an array of additional interceptors for the particular bean;or an empty array if no additional interceptors but just the common ones;or null if no proxy at all, not even with the common interceptors.See constants DO_NOT_PROXY and PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS.
throws:
  BeansException - in case of errors
See Also:   AbstractAutoProxyCreator.DO_NOT_PROXY
See Also:   AbstractAutoProxyCreator.PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS



getBeanFactory
protected BeanFactory getBeanFactory()(Code)
Return the owning BeanFactory May be null, as this object doesn't need to belong to a bean factory.



getCacheKey
protected Object getCacheKey(Class beanClass, String beanName)(Code)
Build a cache key for the given bean class and bean name.
Parameters:
  beanClass - the bean class
Parameters:
  beanName - the bean name the cache key for the given class and name



getCustomTargetSource
protected TargetSource getCustomTargetSource(Class beanClass, String beanName)(Code)
Create a target source for bean instances. Uses any TargetSourceCreators if set. Returns null if no custom TargetSource should be used.

This implementation uses the "customTargetSourceCreators" property. Subclasses can override this method to use a different mechanism.
Parameters:
  beanClass - the class of the bean to create a TargetSource for
Parameters:
  beanName - the name of the bean a TargetSource for this bean
See Also:   AbstractAutoProxyCreator.setCustomTargetSourceCreators




getOrder
final public int getOrder()(Code)



isFrozen
public boolean isFrozen()(Code)



isInfrastructureClass
protected boolean isInfrastructureClass(Class beanClass, String beanName)(Code)
Return whether the given bean class and bean name represents an infrastructure class that should never be proxied.
See Also:   AbstractAutoProxyCreator.isInfrastructureClass(Class)



isInfrastructureClass
protected boolean isInfrastructureClass(Class beanClass)(Code)
Return whether the given bean class represents an infrastructure class that should never be proxied.

Default implementation considers Advisors, Advices and AbstractAutoProxyCreators as infrastructure classes.
Parameters:
  beanClass - the class of the bean whether the bean represents an infrastructure class
See Also:   org.springframework.aop.Advisor
See Also:   org.aopalliance.intercept.MethodInterceptor
See Also:   AbstractAutoProxyCreator.shouldSkip




postProcessAfterInitialization
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException(Code)
Create a proxy with the configured interceptors if the bean is identified as one to proxy by the subclass.
See Also:   AbstractAutoProxyCreator.getAdvicesAndAdvisorsForBean



postProcessAfterInstantiation
public boolean postProcessAfterInstantiation(Object bean, String beanName)(Code)



postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, String beanName)(Code)



postProcessBeforeInstantiation
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException(Code)



postProcessPropertyValues
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)(Code)



setAdvisorAdapterRegistry
public void setAdvisorAdapterRegistry(AdvisorAdapterRegistry advisorAdapterRegistry)(Code)
Specify the AdvisorAdapterRegistry to use. Default is the global AdvisorAdapterRegistry.
See Also:   org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry



setApplyCommonInterceptorsFirst
public void setApplyCommonInterceptorsFirst(boolean applyCommonInterceptorsFirst)(Code)
Set whether the common interceptors should be applied before bean-specific ones. Default is "true"; else, bean-specific interceptors will get applied first.



setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)(Code)



setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)(Code)



setCustomTargetSourceCreators
public void setCustomTargetSourceCreators(TargetSourceCreator[] targetSourceCreators)(Code)
Set custom TargetSourceCreators to be applied in this order. If the list is empty, or they all return null, a SingletonTargetSource will be created for each bean.

Note that TargetSourceCreators will kick in even for target beans where no advices or advisors have been found. If a TargetSourceCreator returns a TargetSource for a specific bean, that bean will be proxied in any case.

TargetSourceCreators can only be invoked if this post processor is used in a BeanFactory, and its BeanFactoryAware callback is used.
Parameters:
  targetSourceCreators - list of TargetSourceCreator.Ordering is significant: The TargetSource returned from the first matchingTargetSourceCreator (that is, the first that returns non-null) will be used.




setFrozen
public void setFrozen(boolean frozen)(Code)
Set whether or not the proxy should be frozen, preventing advice from being added to it once it is created.

Overridden from the super class to prevent the proxy configuration from being frozen before the proxy is created.




setInterceptorNames
public void setInterceptorNames(String[] interceptorNames)(Code)
Set the common interceptors. These must be bean names in the current factory. They can be of any advice or advisor type Spring supports.

If this property isn't set, there will be zero common interceptors. This is perfectly valid, if "specific" interceptors such as matching Advisors are all we want.




setOrder
final public void setOrder(int order)(Code)
Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors.

Default value is Integer.MAX_VALUE, meaning that it's non-ordered.
Parameters:
  order - ordering value




shouldProxyTargetClass
protected boolean shouldProxyTargetClass(Class beanClass, String beanName)(Code)
Determine whether the given bean should be proxied with its target class rather than its interfaces. Checks the AbstractAutoProxyCreator.setProxyTargetClass "proxyTargetClass" setting as well as the AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE "preserveTargetClass" attribute of the corresponding bean definition.
Parameters:
  beanClass - the class of the bean
Parameters:
  beanName - the name of the bean whether the given bean should be proxied with its target class
See Also:   AutoProxyUtils.shouldProxyTargetClass



shouldSkip
protected boolean shouldSkip(Class beanClass, String beanName)(Code)
Subclasses should override this method to return true if the given bean should not be considered for auto-proxying by this post-processor.

Sometimes we need to be able to avoid this happening if it will lead to a circular reference. This implementation returns false.
Parameters:
  beanClass - the class of the bean
Parameters:
  beanName - the name of the bean whether to skip the given bean




Methods inherited from org.springframework.aop.framework.ProxyConfig
public void copyFrom(ProxyConfig other)(Code)(Java Doc)
public boolean isExposeProxy()(Code)(Java Doc)
public boolean isFrozen()(Code)(Java Doc)
public boolean isOpaque()(Code)(Java Doc)
public boolean isOptimize()(Code)(Java Doc)
public boolean isProxyTargetClass()(Code)(Java Doc)
public void setExposeProxy(boolean exposeProxy)(Code)(Java Doc)
public void setFrozen(boolean frozen)(Code)(Java Doc)
public void setOpaque(boolean opaque)(Code)(Java Doc)
public void setOptimize(boolean optimize)(Code)(Java Doc)
public void setProxyTargetClass(boolean proxyTargetClass)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.