2 * The library comes with two alternative mechanisms for configuration of an application, but it is
\r
3 * possible to apply a custom scheme too or not use the configurations at all.
\r
4 * <p>The library does require that a configuration scheme is chosen - in beans.xml as described below.</p>
\r
5 * <p>But the library does NOT impose any mandatory parameters in order to start up (except for those required for
\r
6 * bootstrapping the configuration). The library <i>does</i> know of certain parameters, if it encounters them.
\r
8 * <p>The known parameters are TYPE (service type) PAZPAR2_URL, SERVICE_ID, and SERVICE_PROXY_URL</p>
\r
10 * <p>The built-in configuration schemes are:</p>
\r
12 * <li>Configuration by context parameters in web.xml</li>
\r
13 * <li>The configuration scheme Index Data uses for other MasterKey applications</li>
\r
16 * <p>It must be determined deploy-time what configuration scheme to use, by selecting the preferred
\r
17 * mechanism in the application's beans.xml. In this example the MasterKey configuration scheme is injected:</p>
\r
20 * <beans xmlns="http://java.sun.com/xml/ns/javaee"
\r
21 * xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
\r
22 * xsi:schemaLocation="
\r
23 * http://java.sun.com/xml/ns/javaee
\r
24 * http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
\r
25 * <alternatives>
\r
26 * <class>com.indexdata.mkjsf.config.Mk2ConfigReader</class>
\r
27 * <!-- Options Mk2ConfigReader -->
\r
28 * <!-- WebXmlConfigReader -->
\r
29 * </alternatives>
\r
33 * <p>For the web.xml configuration scheme (choosing WebXmlConfigReader in beans.xml)
\r
34 * to pre-define the URL of the Pazpar2 to use, the configuration could be:</p>
\r
37 * <context-param>
\r
38 * <param-name>PAZPAR2_URL</param-name>
\r
39 * <param-value>http://localhost:8004/</param-value>
\r
40 * </context-param>
\r
43 * <p>For the Mk2ConfigReader scheme to work, the web.xml must then contain pointers to the configuration directory
\r
44 * and properties file.
\r
45 * In this example the configuration directory is in the web application itself (war://testconfig). A more regular
\r
46 * example would put it in a separate directory to not have it overwritten by each deployment of the war.</p>
\r
48 * <context-param>
\r
49 * <param-name>MASTERKEY_ROOT_CONFIG_DIR</param-name>
\r
50 * <param-value>war://testconfig</param-value>
\r
51 * </context-param>
\r
52 * <context-param>
\r
53 * <description>
\r
54 * The sub directory to hold config file(s) for this Masterkey component.
\r
55 * </description>
\r
56 * <param-name>MASTERKEY_COMPONENT_CONFIG_DIR</param-name>
\r
57 * <param-value>/jsfdemo</param-value>
\r
58 * </context-param>
\r
59 * <context-param>
\r
60 * <param-name>MASTERKEY_CONFIG_FILE_NAME</param-name>
\r
61 * <param-value>jsfdemo.properties</param-value>
\r
62 * </context-param>
\r
63 * <context-param>
\r
64 * <description>
\r
65 * Defines the lifespan of configuration parameters as retrieved
\r
66 * from the file pointed to by MASTERKEY_CONFIG_FILE_NAME.
\r
67 * Can be SERVLET (cached) or REQUEST (read for every request).
\r
68 * Will default to SERVLET.
\r
69 * </description>
\r
70 * <param-name>MASTERKEY_CONFIG_LIFE_TIME</param-name>
\r
71 * <param-value>REQUEST</param-value>
\r
72 * </context-param>
\r
75 * <p>The jsfdemo.properties file might look like this for running against a
\r
76 * local Pazpar2 service:</p>
\r
78 * <code>pz2client.PAZPAR2_URL = http://localhost:8004/</code>
\r
80 * <p>Some of the other know parameters in this format could be:</p>
\r
83 * service.TYPE = SP
\r
84 * proxyclient.SERVICE_PROXY_URL = http://localhost:8080/service-proxy/
\r
87 * <p>It's possible to implement a custom configuration scheme by either ignoring whatever scheme is
\r
88 * injected and then applying the required values otherwise, OR by extending the ConfigurationReader
\r
89 * and inject that class in beans.xml instead of any of the two predefined options. The extended
\r
90 * class must construct a Configuration object -- which is basically a set of key-value pairs --
\r
91 * and then set the desired values and hand it off to the Configurable (currently Pz2Service, Pz2Client,
\r
92 * ServiceProxyClient</p>
\r
94 * <p>Finally it's possible to set the URL runtime even from the UI pages.</p>
\r
97 package com.indexdata.mkjsf.config;