Source Code Cross Referenced for WildcardMatcher.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » matching » modular » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.matching.modular 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.matching.modular;
018:
019:        import org.apache.avalon.framework.configuration.Configurable;
020:        import org.apache.avalon.framework.configuration.Configuration;
021:        import org.apache.avalon.framework.configuration.ConfigurationException;
022:        import org.apache.avalon.framework.parameters.Parameters;
023:        import org.apache.avalon.framework.component.ComponentSelector;
024:        import org.apache.avalon.framework.component.ComponentException;
025:        import org.apache.avalon.framework.component.ComponentManager;
026:        import org.apache.avalon.framework.component.Composable;
027:
028:        import org.apache.cocoon.components.modules.input.InputModule;
029:
030:        import org.apache.cocoon.matching.AbstractWildcardMatcher;
031:
032:        import java.util.Map;
033:
034:        /**
035:         * Matches against a wildcard expression. Needs an input module to
036:         * obtain value to match against.
037:         *
038:         * <p><b>Global and local configuration</b></p>
039:         * <table border="1">
040:         * <tr><td><code>input-module</code></td><td>Name of the input module used to obtain the value</td></tr>
041:         * <tr><td><code>parameter-name</code></td><td>Name of the parameter to match * against</td></tr>
042:         * </table>
043:         *
044:         * @author <a href="mailto:haul@apache.org">Christian Haul</a>
045:         * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
046:         * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
047:         * @version CVS $Id: WildcardMatcher.java 433543 2006-08-22 06:22:54Z crossley $
048:         */
049:        public class WildcardMatcher extends AbstractWildcardMatcher implements 
050:                Configurable, Composable {
051:
052:            /** The component manager instance */
053:            protected ComponentManager manager;
054:
055:            private String defaultParam;
056:            private String defaultInput = "request-param"; // default to request parameters
057:            private Configuration inputConf = null; // will become an empty configuration object
058:            // during configure() so why bother here...
059:            String INPUT_MODULE_ROLE = InputModule.ROLE;
060:            String INPUT_MODULE_SELECTOR = INPUT_MODULE_ROLE + "Selector";
061:
062:            /**
063:             * Set the current <code>ComponentManager</code> instance used by this
064:             * <code>Composable</code>.
065:             */
066:            public void compose(ComponentManager manager)
067:                    throws ComponentException {
068:                this .manager = manager;
069:            }
070:
071:            public void configure(Configuration config)
072:                    throws ConfigurationException {
073:                this .defaultParam = config.getChild("parameter-name").getValue(
074:                        null);
075:                this .inputConf = config.getChild("input-module");
076:                this .defaultInput = this .inputConf.getAttribute("name",
077:                        this .defaultInput);
078:            }
079:
080:            protected String getMatchString(Map objectModel,
081:                    Parameters parameters) {
082:
083:                String paramName = parameters.getParameter("parameter-name",
084:                        this .defaultParam);
085:                String inputName = parameters.getParameter("input-module",
086:                        this .defaultInput);
087:
088:                if (paramName == null) {
089:                    if (getLogger().isWarnEnabled())
090:                        getLogger().warn(
091:                                "No parameter name given. Trying to continue");
092:                }
093:                if (inputName == null) {
094:                    if (getLogger().isWarnEnabled())
095:                        getLogger().warn("No input module given. FAILING");
096:                    return null;
097:                }
098:
099:                InputModule input = null;
100:                ComponentSelector inputSelector = null;
101:                Object result = null;
102:
103:                // one could test whether the input module is ThreadSafe and
104:                // keep a reference for that instance. Then one would need
105:                // to implement Disposable in order to release it at EOL
106:                // That would probably speed up things a lot. Especially, since
107:                // matchers are invoked very often.
108:                // Perhaps a CachingWildcardMatcher ?
109:
110:                try {
111:                    // obtain input module
112:                    inputSelector = (ComponentSelector) this .manager
113:                            .lookup(INPUT_MODULE_SELECTOR);
114:                    if (inputSelector != null
115:                            && inputSelector.hasComponent(inputName)) {
116:                        input = (InputModule) inputSelector.select(inputName);
117:                    }
118:                    if (input != null) {
119:                        result = input.getAttribute(paramName, this .inputConf,
120:                                objectModel);
121:                    }
122:                } catch (Exception e) {
123:                    if (getLogger().isWarnEnabled())
124:                        getLogger().warn(
125:                                "A problem occurred acquiring Parameter '"
126:                                        + paramName + "' from '" + inputName
127:                                        + "': " + e.getMessage());
128:                } finally {
129:                    // release components
130:                    if (inputSelector != null) {
131:                        if (input != null)
132:                            inputSelector.release(input);
133:                        this .manager.release(inputSelector);
134:                    }
135:                }
136:
137:                if (getLogger().isDebugEnabled())
138:                    getLogger()
139:                            .debug(
140:                                    " using " + inputName + " obtained value "
141:                                            + result);
142:
143:                if (result instanceof  String) {
144:                    return (String) result;
145:                } else {
146:                    return result.toString();
147:                }
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.