source: main/branches/2.1/src/main/webapps/ibisph-view/WEB-INF/config/spring/common.xml @ 3663

Last change on this file since 3663 was 3663, checked in by Garth Braithwaite, 10 years ago

java and view webapp - commit that has most of model map. committing before ripping out some code and cleaning up more model maps.

File size: 16.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--
4        IBIS-PH View System's common Spring properties. This Spring application
5        context file contains properties are commonly used by more than one modules/
6        packages within the system.  These common properties include core base
7        XML/XSLT paths and other resources used by the apps controllers.
8
9        PROPERTY USAGE NOTES:
10        <property name="someName"><null/></property>
11        <property name="someName" value="${some_system_property_name}"/>
12        <value type="xyz.abc">  Beans can't have a type.
13       
14        If setting is something like setXMLPath then the property needs to be name="XMLPath"
15        (the bean naming more than one first letters capped rule) otherwise it's lowercase
16        then mixed case like normal properties.
17
18        Use the "parent" attribute for child objects that are of the same type.  This basically
19        does a clone on an object so that the existing parent object's objects are copied
20        to the child - thus providing a populated base class that all child objects can
21        be implicitly populated without explicitly setting the properties.
22-->
23
24
25<!-- Global/Common/Shared bean definitions used by some or all of the application contexts -->
26
27<beans default-lazy-init="false" default-autowire="no"
28        xmlns="http://www.springframework.org/schema/beans"
29        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
31>
32
33        <!-- deployment based properties.  See Spring in Action 2.4.3 for a
34                discussion on this.  Note that many of these properties are wrapped
35                in a bean.  This is needed so that the servlet based bean defs can
36                access these property file values without having to reopen the
37                property file for that context.
38        -->
39        <bean id="Common.SiteSpecific.Properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
40                <property name="location" value="WEB-INF/config/site_specific.properties"/>
41        </bean>
42        <bean id="Common.XML.EncodingScheme"   class="java.lang.String"><constructor-arg value="${XML.EncodingScheme}"/></bean>
43        <bean id="Common.QueryApplication.URL" class="java.lang.String"><constructor-arg value="${QueryApplication.URL}"/></bean>
44        <bean id="Common.AdminApp.IPAddress"   class="java.lang.String"><constructor-arg value="${AdminApp.IPAddress}"/></bean>
45        <bean id="Common.AdminApp.PublishRequest.MatchPartialIPAddress" class="java.lang.Boolean"><constructor-arg value="${AdminApp.PublishRequest.MatchPartialIPAddress}"/></bean>
46        <bean id="Common.AdminApp.OrgUnitsXML.BaseURL"         class="java.lang.String"><constructor-arg value="${AdminApp.OrgUnitsXML.BaseURL}"/></bean>
47        <bean id="Common.AdminApp.IndicatorViewXML.BaseURL"    class="java.lang.String"><constructor-arg value="${AdminApp.IndicatorViewXML.BaseURL}"/></bean>
48        <bean id="Common.AdminApp.IndicatorXML.BaseURL"        class="java.lang.String"><constructor-arg value="${AdminApp.IndicatorXML.BaseURL}"/></bean>
49        <bean id="Common.AdminApp.CategorizedIndexXML.BaseURL" class="java.lang.String"><constructor-arg value="${AdminApp.CategorizedIndexXML.BaseURL}"/></bean>
50
51
52        <!--  C O N T E X T S  -->
53        <!--
54                These contexts are needed mainly for SystemID beans as they need a
55                concrete file path. 
56        -->
57        <bean id="Common.Contexts" class="org.ibisph.web.ContextsService"/>
58
59        <bean id="Common.Context.WebApplication" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
60                <property name="targetObject" ref="Common.Contexts"/>
61                <property name="targetMethod" value="getWebApplicationContext"/>
62        </bean>
63        <bean id="Common.Context.Application" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
64                <property name="targetObject" ref="Common.Contexts"/>
65                <property name="targetMethod" value="getApplicationContext"/>
66        </bean>
67        <bean id="Common.Context.Servlet" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
68                <property name="targetObject" ref="Common.Contexts"/>
69                <property name="targetMethod" value="getServletContext"/>
70        </bean>
71        <bean id="Common.Context.Servlet.RootPath" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
72                <property name="targetObject" ref="Common.Context.Servlet"/>
73                <property name="targetMethod" value="getRealPath"/>
74                <property name="arguments"><list><value></value></list></property>
75        </bean>
76
77
78        <!--  L O C A L S,  D A T E,  F O R M A T S  -->
79        <bean id="Common.Locale" class="java.util.Locale">
80                <constructor-arg value="en"/>
81                <constructor-arg value="US"/>
82        </bean>
83
84        <!-- Date Format Patterns:
85                To specify the time format use a time pattern string. In this pattern, all
86                ASCII letters are reserved as pattern letters, which are defined as the following:
87               
88                 Symbol   Meaning                 Presentation        Example
89                 ======   =====================   =================   ===================
90                 G        era designator          (Text)              AD
91                 y        year                    (Number)            1996
92                 M        month in year           (Text & Number)     July & 07
93                 d        day in month            (Number)            10
94                 h        hour in am/pm (1~12)    (Number)            12
95                 H        hour in day (0~23)      (Number)            0
96                 m        minute in hour          (Number)            30
97                 s        second in minute        (Number)            55
98                 S        millisecond             (Number)            978
99                 E        day in week             (Text)              Tuesday
100                 D        day in year             (Number)            189
101                 F        day of week in month    (Number)            2 (2nd Wed in July)
102                 w        week in year            (Number)            27
103                 W        week in month           (Number)            2
104                 a        am/pm marker            (Text)              PM
105                 k        hour in day (1~24)      (Number)            24
106                 K        hour in am/pm (0~11)    (Number)            0
107                 z        time zone               (Text)              Pacific Standard Time
108                 '        escape for text         (Delimiter)
109                 ''       single quote            (Literal)           '
110               
111                Examples Using the US Locale:
112               
113                Format Pattern                    Result
114                ==============================    ======================================
115                "yyyy.MM.dd G 'at' hh:mm:ss z"    1996.07.10 AD at 15:08:56 PDT
116                "EEE, MMM d, ''yy"                Wed, July 10, '96
117                "h:mm a"                          12:08 PM
118                "hh 'o''clock' a, zzzz"           12 o'clock PM, Pacific Daylight Time
119                "K:mm a, z"                       0:00 PM, PST
120                "yyyyy.MMMMM.dd GGG hh:mm aaa"    1996.July.10 AD 12:08 PM
121               
122                "dd.MM.yy"                        09.04.98
123                "H:mm"                            18:15
124                "H:mm:ss:SSS"                     18:15:55:624
125                "K:mm a,z"                        6:15 PM,PDT
126
127                Serial Number: yyyy-MM-dd-HH-mm-ss-SS
128        -->
129        <bean id="Common.DateFormat" class="java.text.SimpleDateFormat">
130                <constructor-arg value="EEE, d MMM yyyy HH:mm:ss z"/>
131                <constructor-arg type="java.util.Locale" ref="Common.Locale"/>
132        </bean>
133        <bean id="Common.BackupFileDateSerialNumber.DateFormat" class="java.text.SimpleDateFormat">
134                <constructor-arg value="yyyy-MM-dd-HH-mm-ss-SS"/>
135                <constructor-arg type="java.util.Locale" ref="Common.Locale"/>
136        </bean>
137
138
139        <!--  M O D E L   M A P S -->
140        <bean id="Common.XMLModelMapKey" class="java.lang.String">
141                <constructor-arg value="XML"/>
142        </bean>
143        <bean id="Common.ModifiedDateModelMapKey" class="java.lang.String">
144                <constructor-arg value="XMLModifedDate"/>
145        </bean>
146        <bean id="Common.XMLModelMap.CommonProperties" abstract="true">
147                <property name="modelMapKey" ref="Common.XMLModelMapKey"/>
148        </bean>
149
150        <bean id="Common.WebAppURLContextPrefixFromHTTPRequest.ModelMap" class="org.ibisph.web.modelmap.WebAppURLContextPrefixFromHTTPRequest">
151                <property name="modelMapKey" value="WebAppURLContextPrefix"/>
152        </bean>
153        <bean id="Common.HTTPRequestParameters.ModelMap" class="org.ibisph.web.modelmap.HTTPRequestParameters">
154                <description>
155                        Provides a simple mechanism to pass URL req params to the XSLT
156                        code.  Note that this does NOT differentiate between GET and
157                        POST so might have to remove this in some special cases - like
158                        not needed for the query module builder post etc.
159                </description>
160                <property name="modelMapKey" value="HTTPRequestParameters"/>
161        </bean>
162        <bean id="Common.ModifiedDateFromFileSystemID.ModelMap" class="org.ibisph.modelmap.AddModelDateModelToModelMap">
163                <property name="sourceModelModelMapKey"   ref="Common.XMLModelMapKey"/>
164                <property name="formattedDateModelMapKey" ref="Common.ModifiedDateModelMapKey"/>
165                <property name="dateFormat"               ref="Common.DateFormat"/>
166        </bean>
167
168
169        <!--  X M L   R E S O U R C E S  -->
170        <bean id="Common.XML.OutputFormat" class="org.dom4j.io.OutputFormat">
171                <property name="encoding"   value="${XML.EncodingScheme}"/>
172                <property name="indentSize" value="0"/> <!-- \t = &#09; = horizontal tab -->
173                <property name="indent"     value=""/>
174                <property name="newlines"   value="false"/> <!-- if true just adds extra blank line inbetween... -->
175                <property name="padText"    value="false"/> <!-- if true just adds extra blank line inbetween... -->
176                <property name="trimText"   value="false"/> <!-- do NOT set to true -->
177        </bean>
178
179        <bean id="Common.XML.DAO" class="org.ibisph.xml.dao.Document">
180                <property name="outputFormat" ref="Common.XML.OutputFormat"/>
181        </bean>
182
183
184        <!--  X S L T   T R A N S F O R M A T I O N   R E S O U R C E S  -->
185        <!-- The main function is to set the XSLT transformation factory to be used.
186                This mechanism allows for a pluggable XSLT engine to be explicitly used.
187                This can be set as a system property but doing so can impact other apps
188                that are installed on the same app server which require/rely on other
189                versions of an XSLT processor (typically XALAN).  If the factory is not
190                explicitly set then the app server's/JVM's default XSLT engine will be
191                used (via JAXP - typically XALAN which will NOT work for IBIS as of 2008). 
192
193                NOTES:
194                - This factory must be XSLT v2.0 (at this point Saxon is the best
195                solution - XALAN 2.x will NOT work for IBIS as it is v1.x). 
196
197                - Removed the IBIS transformer factory type classes in late 2008 as they
198                were not needed.  If XALAN ever goes to 2.0 and adopters want to use then
199                those objects can be resurrected or new XALAN objects can be created as
200                needed.
201
202                PRODUCTION: It is highly recommended to use the caching Saxon XSLT engine:
203                <bean id="Common.XSLT.TransformerFactory" class="org.ibisph.xslt.CachedSaxonTransformerFactory"/>
204
205                XSLT DEVELOPMENT: Use the normal, thread safe non caching Saxon XSLT
206                Transformation Factory.  This avoids having to restart the app or touch
207                the core XSLT file.
208                <bean id="Common.XSLT.TransformerFactory" class="net.sf.saxon.TransformerFactoryImpl"/>
209        -->
210        <bean id="Common.XSLT.TransformerFactory" class="net.sf.saxon.TransformerFactoryImpl"/>
211        <bean id="Common.XSLT.Transformation" class="org.ibisph.xslt.Transformation">
212                <constructor-arg ref="Common.XSLT.TransformerFactory"/>
213        </bean>
214
215
216
217        <!--  E X C E P T I O N   R E S O L V E R  -->
218
219        <!-- Exception Resolvers are typically a list of exceptions with associated
220                views to be used to display an error for a given type of exception. 
221                Note that the resolver is ONLY used for exceptions thrown/uncaught
222                within controller objects e.g. objects controlled by the Request Dispatcher
223                servlet/container.  For "view" related errors a HandlerInterceptor
224                is needed see:
225               
226                http://stackoverflow.com/questions/196495/how-to-configure-spring-handlerexceptionresolver-to-handle-nullpointerexception-t)
227               
228                Other types of errors that happen outside of the servlet (like filter
229                errors) are also not able to be handled.  Many of these errors that occur
230                within the IBIS applications are view related and due to the fact that
231                the web.xml error handling can be used to handle ALL types of errors,
232                there's not much value in an ErrorResolver.  As if 2010, all errors
233                simply go through to the container which will then use the web.xml
234                which uses a centralized error jsp to handle all errors.  The error
235                page logs the error and returns an error page to the user.  The two
236                major downsides to this centralized JSP approach is that 1) the error
237                JSP has to be bullet proof, and 2) the error handling is limited to
238                what can be done within a JSP.  The pro to this approach is that it
239                is all centralized and handled consistently.
240        -->
241
242        <!-- Below is a basic ExceptionResolver that many Spring MVC apps implement.
243                Specific exceptions are handled by the simple exception to view resolver
244                This resolver needs to be used first and MUST not be configured to do the
245                general error handling as the next resolver will not be called.  Note that
246                this can be setup to handle everything but it's was easier to understand
247                and control doing this way.
248
249        <bean id="Common.Specific.ExceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
250                <property name="order" value="1"/>
251                <property name="defaultStatusCode" value="700"/>
252                <property name="defaultErrorView" value="/WEB-INF/jsp/error/detail.jsp"/>
253                <property name="exceptionAttribute" value="Exception"/>
254                <property name="mappedHandlers">
255                        <set><value>java.lang.Throwable</value><ref local="Common.Default.ExceptionHandler"/></set>
256                </property>
257                <property name="exceptionMappings">
258                        <props>
259                                <prop key="org.ibisph.web.springmvc.controller.query.NullModuleException">Query.NullModuleDocument.View</prop>
260                                <prop key="java.lang.Exception ">Query.NullModuleDocument.View</prop>
261                        </props>
262                </property>
263        </bean>
264
265        For many years a simple logging type ExceptionResolver was used.  The code
266        below is left in case the logging exception hanlder is wanted by an adopter.
267
268        <bean id="Common.Default.ExceptionHandler" class="org.ibisph.web.springmvc.LoggingControllerExceptionHandler">
269                <property name="order" value="1"/>
270        </bean>
271        -->
272
273
274
275
276        <!--  R E S T R I C T E D   A C C E S S   M O D E L S   /   C O N T R O L L E R   R E S O R U C E S -->
277        <!-- Blocked direct file access URLs.  Files that need to be blocked from
278                public access can have a general mapping that goes to a simple controller
279                that returns a missing resource page.  This could also be mapped to a
280                general controller that simply returns a 404 or 403 error.  Remember that
281                a corresponding mapping needs to exist in the dispatcher_servlet.xml
282                file as well as in the WEB.XML servlet mapping.  There are other ways to
283                impelment like putting the files within a WEB-INF/* subdirectory.  Can
284                also be done via a filter (like the CheckAllowedRequesterIPAddressFilter)
285                or via a similar filter where the return code is injected.
286        -->
287        <bean id="Common.XML.Path" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
288                <property name="targetObject" ref="Common.Context.Servlet"/>
289                <property name="targetMethod" value="getRealPath"/>
290                <property name="arguments"><list><value>xml</value></list></property>
291        </bean>
292        <bean id="Common.RestrictedXMLAccess.XML.SystemID" class="org.ibisph.systemid.FileSystemID">
293                <constructor-arg ref="Common.XML.Path"/>
294                <constructor-arg value="BlockedURLMessage_HTMLContent.xml"/>
295        </bean>
296        <bean id="Common.BannedXMLAccess.Controller" class="org.ibisph.web.springmvc.ModelMapListProcessingController">
297                <property name="modelMapList">
298                        <list>
299                                <bean class="org.ibisph.modelmap.SimpleModelMap" parent="Common.XMLModelMap.CommonProperties">
300                                        <property name="model" ref="Common.RestrictedXMLAccess.XML.SystemID"/>
301                                </bean>
302                                <ref bean="Common.ModifiedDateFromFileSystemID.ModelMap"/>
303                                <ref bean="Common.WebAppURLContextPrefixFromHTTPRequest.ModelMap"/>
304                        </list>
305                </property>
306                <property name="view" ref="Common.HTMLContent.View"/>
307        </bean>
308
309        <bean id="Common.HTMLContent.XSLT.SystemID" class="org.ibisph.systemid.FileSystemID">
310                <constructor-arg ref="Common.Context.Servlet.RootPath"/>
311                <constructor-arg value="xslt/html/HTMLContentPage.xslt"/>
312        </bean>
313        <bean id="Common.HTMLContent.View" class="org.ibisph.xml.springmvc.XSLTXMLTransformationView">
314                <constructor-arg ref="Common.HTMLContent.XSLT.SystemID"/>
315                <constructor-arg ref="Common.XSLT.Transformation"/>
316                <property name="XMLModelMapKey" ref="Common.XMLModelMapKey"/>
317                <property name="contentType" value="text/html"/>
318        </bean>
319
320</beans>
321
Note: See TracBrowser for help on using the repository browser.