org.apache.cocoon.components.modules.input

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 » Web Framework » cocoon » org.apache.cocoon.components.modules.input 
org.apache.cocoon.components.modules.input
input

InputModules

Introduction

Input modules are generic components that let one map a key to one or more values. In concept and API, input modules are closest to the java.util.Properties class. An input module has a number of named attributes, each of which has an associated value or values, which will be computed or looked up when requested.

    |       InputModule          |
    |----------------------------|
    | PropName   | PropValue(s)  |
    |----------------------------|
    | prop1      | value1        |
    | prop2      | value2        |
    | ...        | ...           |
    | propn      | valuen        |
    +----------------------------+

Three operations are defined by the InputModule interface:

getAttributeNames
Retrieve a list of all available attributes (the set prop1, prop2, ..., propn).
getAttribute
Retrieve the value of an attribute. For instance, getAttribute(prop1) would return value1
GetAttributeValues
Retrieve an Iterator for a list of values for an attribute.

Usage

Input modules are used in various places in Cocoon, notably from within the sitemap, XSPs, and matchers.

In the sitemap, input modules are made available through a {modulename:attributename} syntax. For instance, if a RequestParameterModule named request-param is defined in cocoon.xconf, then {request-param:user} will in effect be replaced by the value of the user request parameter (e.g. index.html?user=joe). Similarly, a SystemPropertyModule named system-property would allow {system-property:user.home} to represent user's home directory path.

Configuration

Input modules are declared in cocoon.xconf. There is a section dedicated to input modules:

  <input-modules>
    <component-instance name="global"
             class="org.apache.cocoon.components.modules.input.GlobalInputModule"
             logger="core.modules.input"/>
    <component-instance name="request"
             class="org.apache.cocoon.components.modules.input.RequestModule"
             logger="core.modules.input"/>
    <component-instance name="session"
             class="org.apache.cocoon.components.modules.input.SessionModule"
             logger="core.modules.input"/>
    <component-instance name="request-param"
             class="org.apache.cocoon.components.modules.input.RequestParameterModule"
             logger="core.modules.input"/>
    ...
    <component-instance name="defaults"
             class="org.apache.cocoon.components.modules.input.DefaultsModule"
             logger="core.modules.input">
      <values>
        <skin>defaultSkin</skin>
        <base-url>http://localhost:8080/cocoon</base-url>
      </values>
    </component-instance>
  <input-modules>

Static/dynamic configuration

In cocoon.xconf, each input module can take a static configuration. This is made available to the class via the configure() method, called once on startup. In the example above, an Avalon Configuration object representing the <values> node will be passed to the DefaultsModule.

In addition, every time an input module is used, a dynamic configuration is passed to it, as well as the current "object model". You can see these in the InputModule interface definition for all three methods. This dynamic, per-request configuration will usually override the static configuration. This dual static/dynamic configuration makes input modules useful in a wide variety of circumstances.

Meta Modules

So-called "meta" modules are modules that act on other modules. The simplest example of a meta module is the SimpleMappingMetaModule, which will query another module with a modified version of an attribute name. For instance, if configured with:

<component-instance name="mappingmodule"
    class="org.apache.cocoon.components.modules.input.SimpleMappingMetaModule"
    logger="core.modules.mapper">
  <input-module name="xmlmodule"/>
  <prefix>/site/</prefix>
  <suffix>/@href</suffix>
</component-instance>

Then a key foo will cause xmlmodule to be queried for attribute /site/foo/@href, and that value will be returned.

Another useful example is ChainMetaModule, which will query a set of input modules until one returns a non-null value for an attribute, providing "fall-back" behaviour.

The machinery for meta modules is provided in AbstractMetaModule.

JXPath use in Input Modules

Many input modules make use of the JXPath library, which lets one traverse Java object structures with an XPath-like syntax. Support for this is mostly located in the JXPathMetaModule and AbstractJXPathModule superclasses, which should be kept synchronised.

Further Information

The best way to learn what can be done with input modules is by examining the samples that come with the Cocoon application. The main Cocoon documentation and Cocoon Wiki should have further information.

Java Source File NameTypeComment
AbstractInputModule.javaClass AbstractInputModule gives you the infrastructure for easily deploying more InputModules.
AbstractJXPathModule.javaClass JXPathModule allows to access properties of any object in generic way.
AbstractMetaModule.javaClass AbstractMetaModule gives you the infrastructure for easily deploying more "meta" InputModules i.e.
BaseLinkModule.javaClass BaseLinkModule returns a relative link (../, ../../ etc) to the base of the current request or sitemap URI.
ChainMetaModule.javaClass This modules allows to "chain" several other modules.
CollectionMetaModule.javaClass Constructs an array of values suitable for a JDBC collection type from parameters obtained from another input module.
ContextPathModule.javaClass ContextPathModule provides a real filesystem path for a virtual context-relative path.
CookieModule.javaClass Input module for cookies.
DateInputModule.javaClass DateInputModule returns current date, optionally formated as string.
DateMetaInputModule.javaClass Parses a date string according to a given format and returns a date object.
DefaultsMetaModule.javaClass Old name for DefaultsModule .
DefaultsModule.javaClass Set a number of constants.
DigestMetaModule.javaClass Meta module that obtains values from other module and returns message digest of value.
FlowAttributeModule.javaClass FlowAttributeModule provides access to the flow business object properties. To get access to the properties use XPath syntax.
FlowContinuationModule.javaClass FlowContinuationModule provides access to the flow web continuation object.
GlobalInputModule.javaClass This simple module allows to define global parameters in a sitemap.
HeaderAttributeModule.javaClass HeaderAttributeModule accesses request header attributes.
InputModule.javaInterface InputModule specifies an interface for components that provide access to individual attributes e.g.
InputModuleHelper.javaClass
IteratorHelper.javaClass Wraps an Enumeration and provides Iterator interface.
JXPathHelper.javaClass
JXPathHelperConfiguration.javaClass
JXPathMetaModule.javaClass JXPathModule allows to access properties of any object in generic way.
LocateResource.javaClass Locate a resource in a resource tree.
MapMetaModule.javaClass Meta module that obtains an Object from another module, assumes that this Object implements the java.util.Map interface, and gives access to the map contents.
ModuleHolder.javaClass
NamingInputModule.javaClass NamingInputModule accesses values stored in the JNDI context.

This module accept any configuration parameters and passes them as properties to the InitialContext.

NullInputModule.javaClass NullInputModule returns a null object.
PortletURLModule.javaClass Input module to be used in together with org.apache.cocoon.transformation.LinkRewriterTransformer in JSR-168 (Portlet) environment.
ProjectPathModule.javaClass ProjectPathModule provides relative and absolute paths with regards to the root of a project.
PropertiesFileModule.javaClass Input module for accessing properties in a properties file.
RandomNumberModule.javaClass RandomNumberModule returns a random number as a string. Configuration through child elements: "min", "max" setting range of random number.
RawRequestParameterModule.javaClass RawRequestParameterModule accesses request parameters without decoding to the specified form-encoding or casting.
RealPathModule.javaClass RealPathModule provides a real filesystem path for a virtual context-relative path.
RequestAttributeModule.javaClass RequestAttributeModule accesses request attributes.
RequestModule.javaClass RequestModule provides access to Request object properties. To get access to request properties use XPath syntax, e.g.
RequestParameterModule.javaClass RequestParameterModule accesses request parameters.
RequestURIModule.javaClass RequestURIModule accesses the request URI.
SelectMetaInputModule.javaClass

Configuration

input-module Configuration and name of input module used for the selection. req Stringnull
when Selection case, condition in test attribute, input module name in name attribute.
SessionAttributeModule.javaClass SessionAttributeModule accesses session attributes.
SessionModule.javaClass SessionModule provides access to Session object properties. To get access to session properties use XPath syntax, e.g.
SimpleMappingMetaModule.javaClass Meta module that obtains values from an other module and by replacing the requested attribute name with another name.
SitemapVariableHolder.javaClass
StringConstantModule.javaClass StringConstantModule returns a constant string.
SystemPropertyModule.javaClass SystemPropertyModule is an JXPath based InputModule implementation that provides access to system properties. Available system properties are defined by Java's System.getProperties(). JXPath allows to apply XPath functions to system properties.

If there is a security manager, its checkPropertiesAccess method is called with no arguments.

URLDecodeModule.javaClass This module provides functionality for converting a String from the application/x-www-form-urlencoded MIME format.
URLEncodeModule.javaClass This module provides functionality for converting a String to the application/x-www-form-urlencoded MIME format.
XMLFileModule.javaClass This module provides an Input Module interface to any XML document, by using XPath expressions as attribute keys. The XML can be obtained from any Cocoon Source (e.g., cocoon:/..., context://.., and regular URLs). Sources can be held in memory for better performance and reloaded if changed.

Caching and reloading can be turned on / off (default: caching on, reloading off) through <reloadable>false</reloadable> and <cacheable>false</cacheable>.

XMLMetaModule.javaClass Meta module that obtains values from other module and returns all parameters as XML.

Config

 <!-- in cocoon.xconf -->
 <ignore>do-</ignore>
 <strip>user.</strip>
 <input-module name="request-param"/>
 <!-- e.g.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.