Source Code Cross Referenced for SimpleUrlHandlerMapping.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » handler » 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.web.servlet.handler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 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.web.servlet.handler;
018:
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:        import java.util.Properties;
023:
024:        import org.springframework.beans.BeansException;
025:
026:        /**
027:         * Implementation of the {@link org.springframework.web.servlet.HandlerMapping}
028:         * interface to map from URLs to request handler beans. Supports both mapping to bean
029:         * instances and mapping to bean names; the latter is required for non-singleton handlers.
030:         *
031:         * <p>The "urlMap" property is suitable for populating the handler map with
032:         * bean references, e.g. via the map element in XML bean definitions.
033:         *
034:         * <p>Mappings to bean names can be set via the "mappings" property, in a form
035:         * accepted by the <code>java.util.Properties</code> class, like as follows:<br>
036:         * <code>
037:         * /welcome.html=ticketController
038:         * /show.html=ticketController
039:         * </code><br>
040:         * The syntax is <code>PATH=HANDLER_BEAN_NAME</code>.
041:         * If the path doesn't begin with a slash, one is prepended.
042:         *
043:         * <p>Supports direct matches (given "/test" -> registered "/test") and "*"
044:         * matches (given "/test" -> registered "/t*"). Note that the default is
045:         * to map within the current servlet mapping if applicable; see the
046:         * {@link #setAlwaysUseFullPath "alwaysUseFullPath"} property for details.
047:         * For details on the pattern options, see the
048:         * {@link org.springframework.util.AntPathMatcher} javadoc.
049:
050:         * @author Rod Johnson
051:         * @author Juergen Hoeller
052:         * @see #setMappings
053:         * @see #setUrlMap
054:         * @see BeanNameUrlHandlerMapping
055:         */
056:        public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping {
057:
058:            private final Map urlMap = new HashMap();
059:
060:            /**
061:             * Map URL paths to handler bean names.
062:             * This is the typical way of configuring this HandlerMapping.
063:             * <p>Supports direct URL matches and Ant-style pattern matches. For syntax
064:             * details, see the {@link org.springframework.util.AntPathMatcher} javadoc.
065:             * @param mappings properties with URLs as keys and bean names as values
066:             * @see #setUrlMap
067:             */
068:            public void setMappings(Properties mappings) {
069:                this .urlMap.putAll(mappings);
070:            }
071:
072:            /**
073:             * Set a Map with URL paths as keys and handler beans (or handler bean names)
074:             * as values. Convenient for population with bean references.
075:             * <p>Supports direct URL matches and Ant-style pattern matches. For syntax
076:             * details, see the {@link org.springframework.util.AntPathMatcher} javadoc.
077:             * @param urlMap map with URLs as keys and beans as values
078:             * @see #setMappings
079:             */
080:            public void setUrlMap(Map urlMap) {
081:                this .urlMap.putAll(urlMap);
082:            }
083:
084:            /**
085:             * Allow Map access to the URL path mappings, with the option to add or
086:             * override specific entries.
087:             * <p>Useful for specifying entries directly, for example via "urlMap[myKey]".
088:             * This is particularly useful for adding or overriding entries in child
089:             * bean definitions.
090:             */
091:            public Map getUrlMap() {
092:                return this .urlMap;
093:            }
094:
095:            /**
096:             * Calls the {@link #registerHandlers} method in addition to the
097:             * superclass's initialization.
098:             */
099:            public void initApplicationContext() throws BeansException {
100:                super .initApplicationContext();
101:                registerHandlers(this .urlMap);
102:            }
103:
104:            /**
105:             * Register all handlers specified in the URL map for the corresponding paths.
106:             * @param urlMap Map with URL paths as keys and handler beans or bean names as values
107:             * @throws BeansException if a handler couldn't be registered
108:             * @throws IllegalStateException if there is a conflicting handler registered
109:             */
110:            protected void registerHandlers(Map urlMap) throws BeansException {
111:                if (urlMap.isEmpty()) {
112:                    logger
113:                            .warn("Neither 'urlMap' nor 'mappings' set on SimpleUrlHandlerMapping");
114:                } else {
115:                    Iterator it = urlMap.keySet().iterator();
116:                    while (it.hasNext()) {
117:                        String url = (String) it.next();
118:                        Object handler = urlMap.get(url);
119:                        // Prepend with slash if not already present.
120:                        if (!url.startsWith("/")) {
121:                            url = "/" + url;
122:                        }
123:                        registerHandler(url, handler);
124:                    }
125:                }
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.