Source Code Cross Referenced for IncludeEventHandler.java in  » Template-Engine » Velocity » org » apache » velocity » app » event » 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 » Template Engine » Velocity » org.apache.velocity.app.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.velocity.app.event;
002:
003:        import org.apache.velocity.context.Context;
004:        import org.apache.velocity.util.ContextAware;
005:
006:        /*
007:         * Licensed to the Apache Software Foundation (ASF) under one
008:         * or more contributor license agreements.  See the NOTICE file
009:         * distributed with this work for additional information
010:         * regarding copyright ownership.  The ASF licenses this file
011:         * to you under the Apache License, Version 2.0 (the
012:         * "License"); you may not use this file except in compliance
013:         * with the License.  You may obtain a copy of the License at
014:         *
015:         *   http://www.apache.org/licenses/LICENSE-2.0
016:         *
017:         * Unless required by applicable law or agreed to in writing,
018:         * software distributed under the License is distributed on an
019:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020:         * KIND, either express or implied.  See the License for the
021:         * specific language governing permissions and limitations
022:         * under the License.    
023:         */
024:
025:        /**
026:         *  Event handler for include type directives (e.g. <code>#include()</code>, <code>#parse()</code>)
027:         *  Allows the developer to modify the path of the resource returned.
028:         *
029:         * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
030:         * @version $Id: IncludeEventHandler.java 463298 2006-10-12 16:10:32Z henning $
031:         */
032:        public interface IncludeEventHandler extends EventHandler {
033:            /**
034:             * Called when an include-type directive is encountered (
035:             * <code>#include</code> or <code>#parse</code>). May modify the path
036:             * of the resource to be included or may block the include entirely. All the
037:             * registered IncludeEventHandlers are called unless null is returned. If
038:             * none are registered the template at the includeResourcePath is retrieved.
039:             *
040:             * @param includeResourcePath  the path as given in the include directive.
041:             * @param currentResourcePath the path of the currently rendering template that includes the
042:             *            include directive.
043:             * @param directiveName  name of the directive used to include the resource. (With the
044:             *            standard directives this is either "parse" or "include").
045:             *
046:             * @return a new resource path for the directive, or null to block the
047:             *         include from occurring.
048:             */
049:            public String includeEvent(String includeResourcePath,
050:                    String currentResourcePath, String directiveName);
051:
052:            /**
053:             * Defines the execution strategy for includeEvent
054:             */
055:            static class IncludeEventExecutor implements 
056:                    EventHandlerMethodExecutor {
057:                private Context context;
058:                private String includeResourcePath;
059:                private String currentResourcePath;
060:                private String directiveName;
061:
062:                private boolean executed = false;
063:
064:                IncludeEventExecutor(Context context,
065:                        String includeResourcePath, String currentResourcePath,
066:                        String directiveName) {
067:                    this .context = context;
068:                    this .includeResourcePath = includeResourcePath;
069:                    this .currentResourcePath = currentResourcePath;
070:                    this .directiveName = directiveName;
071:                }
072:
073:                /**
074:                 * Call the method includeEvent()
075:                 *  
076:                 * @param handler call the appropriate method on this handler
077:                 */
078:                public void execute(EventHandler handler) {
079:                    IncludeEventHandler eh = (IncludeEventHandler) handler;
080:
081:                    if (eh instanceof  ContextAware)
082:                        ((ContextAware) eh).setContext(context);
083:
084:                    executed = true;
085:                    includeResourcePath = ((IncludeEventHandler) handler)
086:                            .includeEvent(includeResourcePath,
087:                                    currentResourcePath, directiveName);
088:                }
089:
090:                public Object getReturnValue() {
091:                    return includeResourcePath;
092:                }
093:
094:                public boolean isDone() {
095:                    return executed && (includeResourcePath == null);
096:                }
097:
098:            }
099:
100:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.