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

Last change on this file since 3653 was 3653, checked in by Garth Braithwaite, 11 years ago

view and java - latest refactor commit - home ==> query working.

File size: 16.7 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  -->
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="modelMapModelKey" ref="Common.XMLModelMapKey"/>
148        </bean>
149
150        <bean id="Common.WebAppURLContextPrefixFromHTTPRequest.ModelMap" class="org.ibisph.web.modelmap.WebAppURLContextPrefixFromHTTPRequest">
151                <property name="modelMapModelKey" 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="modelMapModelKey" value="HTTPRequestParameters"/>
161        </bean>
162        <bean id="Common.ModifiedDateFromFileSystemID.ParameterMap" 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        <!--  C O N T R O L L E R S  -->
170        <bean id="Common.FileSystemID.Controller.CommonProperties" class="org.ibisph.web.springmvc.ModelMapListProcessingController" abstract="true">
171                <property name="modelMapList">
172                        <list>
173                                <ref bean="Common.WebAppURLContextPrefixFromHTTPRequest.ModelMap"/>
174                                <ref bean="Common.ModifiedDateFromFileSystemID.ParameterMap"/>
175                                <ref bean="Common.HTTPRequestParameters.ModelMap"/>
176                        </list>
177                </property>
178        </bean>
179
180
181        <!--  X M L   R E S O U R C E S  -->
182        <bean id="Common.XML.OutputFormat" class="org.dom4j.io.OutputFormat">
183                <property name="encoding"   value="${XML.EncodingScheme}"/>
184                <property name="indentSize" value="0"/> <!-- \t = &#09; = horizontal tab -->
185                <property name="indent"     value=""/>
186                <property name="newlines"   value="false"/> <!-- if true just adds extra blank line inbetween... -->
187                <property name="padText"    value="false"/> <!-- if true just adds extra blank line inbetween... -->
188                <property name="trimText"   value="false"/> <!-- do NOT set to true -->
189        </bean>
190
191        <bean id="Common.XML.DAO" class="org.ibisph.xml.dao.Document">
192                <property name="outputFormat" ref="Common.XML.OutputFormat"/>
193        </bean>
194
195
196        <!--  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  -->
197        <!-- The main function is to set the XSLT transformation factory to be used.
198                This mechanism allows for a pluggable XSLT engine to be explicitly used.
199                This can be set as a system property but doing so can impact other apps
200                that are installed on the same app server which require/rely on other
201                versions of an XSLT processor (typically XALAN).  If the factory is not
202                explicitly set then the app server's/JVM's default XSLT engine will be
203                used (via JAXP - typically XALAN which will NOT work for IBIS as of 2008). 
204
205                NOTES:
206                - This factory must be XSLT v2.0 (at this point Saxon is the best
207                solution - XALAN 2.x will NOT work for IBIS as it is v1.x). 
208
209                - Removed the IBIS transformer factory type classes in late 2008 as they
210                were not needed.  If XALAN ever goes to 2.0 and adopters want to use then
211                those objects can be resurrected or new XALAN objects can be created as
212                needed.
213
214                PRODUCTION: It is highly recommended to use the caching Saxon XSLT engine:
215                <bean id="Common.XSLT.TransformerFactory" class="org.ibisph.xslt.CachedSaxonTransformerFactory"/>
216
217                XSLT DEVELOPMENT: Use the normal, thread safe non caching Saxon XSLT
218                Transformation Factory.  This avoids having to restart the app or touch
219                the core XSLT file.
220                <bean id="Common.XSLT.TransformerFactory" class="net.sf.saxon.TransformerFactoryImpl"/>
221        -->
222        <bean id="Common.XSLT.TransformerFactory" class="net.sf.saxon.TransformerFactoryImpl"/>
223        <bean id="Common.XSLT.Transformation" class="org.ibisph.xslt.Transformation">
224                <constructor-arg ref="Common.XSLT.TransformerFactory"/>
225        </bean>
226
227
228
229        <!--  E X C E P T I O N   R E S O L V E R  -->
230
231        <!-- Exception Resolvers are typically a list of exceptions with associated
232                views to be used to display an error for a given type of exception. 
233                Note that the resolver is ONLY used for exceptions thrown/uncaught
234                within controller objects e.g. objects controlled by the Request Dispatcher
235                servlet/container.  For "view" related errors a HandlerInterceptor
236                is needed see:
237               
238                http://stackoverflow.com/questions/196495/how-to-configure-spring-handlerexceptionresolver-to-handle-nullpointerexception-t)
239               
240                Other types of errors that happen outside of the servlet (like filter
241                errors) are also not able to be handled.  Many of these errors that occur
242                within the IBIS applications are view related and due to the fact that
243                the web.xml error handling can be used to handle ALL types of errors,
244                there's not much value in an ErrorResolver.  As if 2010, all errors
245                simply go through to the container which will then use the web.xml
246                which uses a centralized error jsp to handle all errors.  The error
247                page logs the error and returns an error page to the user.  The two
248                major downsides to this centralized JSP approach is that 1) the error
249                JSP has to be bullet proof, and 2) the error handling is limited to
250                what can be done within a JSP.  The pro to this approach is that it
251                is all centralized and handled consistently.
252        -->
253
254        <!-- Below is a basic ExceptionResolver that many Spring MVC apps implement.
255                Specific exceptions are handled by the simple exception to view resolver
256                This resolver needs to be used first and MUST not be configured to do the
257                general error handling as the next resolver will not be called.  Note that
258                this can be setup to handle everything but it's was easier to understand
259                and control doing this way.
260
261        <bean id="Common.Specific.ExceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
262                <property name="order" value="1"/>
263                <property name="defaultStatusCode" value="700"/>
264                <property name="defaultErrorView" value="/WEB-INF/jsp/error/detail.jsp"/>
265                <property name="exceptionAttribute" value="Exception"/>
266                <property name="mappedHandlers">
267                        <set><value>java.lang.Throwable</value><ref local="Common.Default.ExceptionHandler"/></set>
268                </property>
269                <property name="exceptionMappings">
270                        <props>
271                                <prop key="org.ibisph.web.springmvc.controller.query.NullModuleException">Query.NullModuleDocument.View</prop>
272                                <prop key="java.lang.Exception ">Query.NullModuleDocument.View</prop>
273                        </props>
274                </property>
275        </bean>
276
277        For many years a simple logging type ExceptionResolver was used.  The code
278        below is left in case the logging exception hanlder is wanted by an adopter.
279
280        <bean id="Common.Default.ExceptionHandler" class="org.ibisph.web.springmvc.LoggingControllerExceptionHandler">
281                <property name="order" value="1"/>
282        </bean>
283        -->
284
285
286
287
288        <!--  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 -->
289        <!-- Blocked direct file access URLs.  Files that need to be blocked from
290                public access can have a general mapping that goes to a simple controller
291                that returns a missing resource page.  This could also be mapped to a
292                general controller that simply returns a 404 or 403 error.  Remember that
293                a corresponding mapping needs to exist in the dispatcher_servlet.xml
294                file as well as in the WEB.XML servlet mapping.  There are other ways to
295                impelment like putting the files within a WEB-INF/* subdirectory.  Can
296                also be done via a filter (like the CheckAllowedRequesterIPAddressFilter)
297                or via a similar filter where the return code is injected.
298        -->
299        <bean id="Common.XML.Path" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
300                <property name="targetObject" ref="Common.Context.Servlet"/>
301                <property name="targetMethod" value="getRealPath"/>
302                <property name="arguments"><list><value>xml</value></list></property>
303        </bean>
304        <bean id="Common.RestrictedXMLAccess.XML.SystemID" class="org.ibisph.systemid.FileSystemID">
305                <constructor-arg ref="Common.XML.Path"/>
306                <constructor-arg value="BlockedURLMessage_HTMLContent.xml"/>
307        </bean>
308        <bean id="Common.BannedXMLAccess.Controller" class="org.ibisph.web.springmvc.ModelMapListProcessingController" parent="Common.FileSystemID.Controller.CommonProperties">
309                <property name="additionalModelMapList">
310                        <list>
311                                <bean class="org.ibisph.modelmap.SimpleModelMap" parent="Common.XMLModelMap.CommonProperties">
312                                        <property name="model" ref="Common.RestrictedXMLAccess.XML.SystemID"/>
313                                </bean>
314                        </list>
315                </property>
316                <property name="view" ref="Common.HTMLContent.View"/>
317        </bean>
318
319        <bean id="Common.HTMLContent.XSLT.SystemID" class="org.ibisph.systemid.FileSystemID">
320                <constructor-arg ref="Common.Context.Servlet.RootPath"/>
321                <constructor-arg value="xslt/html/HTMLContentPage.xslt"/>
322        </bean>
323        <bean id="Common.HTMLContent.View" class="org.ibisph.xml.springmvc.XSLTXMLTransformationView">
324                <constructor-arg ref="Common.HTMLContent.XSLT.SystemID"/>
325                <constructor-arg ref="Common.XSLT.Transformation"/>
326                <property name="XMLModelMapKey" ref="Common.XMLModelMapKey"/>
327                <property name="contentType" value="text/html"/>
328        </bean>
329
330</beans>
331
Note: See TracBrowser for help on using the repository browser.