source: main/trunk/src/main/webapps/ibisph-view/WEB-INF/config/spring/common.xml @ 3710

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

java and view - email verification code working. updated systemid modelmaps to use verified file, then the new resource then classpath system id lookup. many of the modelmap objects were changed from "XML" to the more generic "file". Renamed the saxon*.jars to include the exact version number.

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