Source Code Cross Referenced for BeanNameAutoProxyCreator.java in  » J2EE » spring-framework-2.5 » 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.5 » org.springframework.aop.framework.autoproxy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.aop.framework.autoproxy;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import org.springframework.aop.TargetSource;
024:        import org.springframework.beans.factory.BeanFactory;
025:        import org.springframework.beans.factory.FactoryBean;
026:        import org.springframework.util.Assert;
027:        import org.springframework.util.PatternMatchUtils;
028:        import org.springframework.util.StringUtils;
029:
030:        /**
031:         * Auto proxy creator that identifies beans to proxy via a list of names.
032:         * Checks for direct, "xxx*", and "*xxx" matches.
033:         *
034:         * <p>For configuration details, see the javadoc of the parent class
035:         * AbstractAutoProxyCreator. Typically, you will specify a list of
036:         * interceptor names to apply to all identified beans, via the
037:         * "interceptorNames" property.
038:         *
039:         * @author Juergen Hoeller
040:         * @since 10.10.2003
041:         * @see #setBeanNames
042:         * @see #isMatch
043:         * @see #setInterceptorNames
044:         * @see AbstractAutoProxyCreator
045:         */
046:        public class BeanNameAutoProxyCreator extends AbstractAutoProxyCreator {
047:
048:            private List beanNames;
049:
050:            /**
051:             * Set the names of the beans that should automatically get wrapped with proxies.
052:             * A name can specify a prefix to match by ending with "*", e.g. "myBean,tx*"
053:             * will match the bean named "myBean" and all beans whose name start with "tx".
054:             * <p><b>NOTE:</b> In case of a FactoryBean, only the objects created by the
055:             * FactoryBean will get proxied. This default behavior applies as of Spring 2.0.
056:             * If you intend to proxy a FactoryBean instance itself (a rare use case, but
057:             * Spring 1.2's default behavior), specify the bean name of the FactoryBean
058:             * including the factory-bean prefix "&": e.g. "&myFactoryBean".
059:             * @see org.springframework.beans.factory.FactoryBean
060:             * @see org.springframework.beans.factory.BeanFactory#FACTORY_BEAN_PREFIX
061:             */
062:            public void setBeanNames(String[] beanNames) {
063:                Assert.notEmpty(beanNames, "'beanNames' must not be empty");
064:                this .beanNames = new ArrayList(beanNames.length);
065:                for (int i = 0; i < beanNames.length; i++) {
066:                    this .beanNames
067:                            .add(StringUtils.trimWhitespace(beanNames[i]));
068:                }
069:            }
070:
071:            /**
072:             * Identify as bean to proxy if the bean name is in the configured list of names.
073:             */
074:            protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass,
075:                    String beanName, TargetSource targetSource) {
076:                if (this .beanNames != null) {
077:                    for (Iterator it = this .beanNames.iterator(); it.hasNext();) {
078:                        String mappedName = (String) it.next();
079:                        if (FactoryBean.class.isAssignableFrom(beanClass)) {
080:                            if (!mappedName
081:                                    .startsWith(BeanFactory.FACTORY_BEAN_PREFIX)) {
082:                                continue;
083:                            }
084:                            mappedName = mappedName
085:                                    .substring(BeanFactory.FACTORY_BEAN_PREFIX
086:                                            .length());
087:                        }
088:                        if (isMatch(beanName, mappedName)) {
089:                            return PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS;
090:                        }
091:                    }
092:                }
093:                return DO_NOT_PROXY;
094:            }
095:
096:            /**
097:             * Return if the given bean name matches the mapped name.
098:             * <p>The default implementation checks for "xxx*", "*xxx" and "*xxx*" matches,
099:             * as well as direct equality. Can be overridden in subclasses.
100:             * @param beanName the bean name to check
101:             * @param mappedName the name in the configured list of names
102:             * @return if the names match
103:             * @see org.springframework.util.PatternMatchUtils#simpleMatch(String, String)
104:             */
105:            protected boolean isMatch(String beanName, String mappedName) {
106:                return PatternMatchUtils.simpleMatch(mappedName, beanName);
107:            }
108:
109:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.