Documents configuration schemes in more detail
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / config / package-info.java
1 /**\r
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
7  *\r
8  * <p>Following classes can be configured: Pz2Service (controller), Pz2Client, and ServiceProxyClient. Some currently \r
9  * acknowledged parameters are TYPE (service type) PAZPAR2_URL, SERVICE_ID, and SERVICE_PROXY_URL</p>\r
10  * \r
11  * <h3>Selecting a configuration scheme</h3>\r
12  * \r
13  * <p>The built-in configuration schemes are:</p>\r
14  * <ol>\r
15  *  <li>Configuration by context parameters in web.xml, this is the simple though less flexible choice</li>\r
16  *  <li>The configuration scheme Index Data uses for other MasterKey applications, Mk2Config, this is the more versatile option</li>\r
17  * </ol> \r
18  * \r
19  * <p>It must be determined deploy-time what configuration scheme to use, by selecting the preferred \r
20  * mechanism in the application's beans.xml. In this example the MasterKey configuration scheme is injected:</p> \r
21  * \r
22  * <pre>\r
23  * &lt;beans xmlns="http://java.sun.com/xml/ns/javaee"\r
24  *         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
25  *         xsi:schemaLocation="\r
26  *     http://java.sun.com/xml/ns/javaee \r
27  *     http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"&gt;  \r
28  *     &lt;alternatives>         \r
29  *        &lt;class>com.indexdata.mkjsf.config.WebXmlConfigReader&lt;/class&gt;\r
30  *        &lt;!-- Options                      Mk2ConfigReader     --&gt;\r
31  *        &lt;!--                              WebXmlConfigReader  --&gt;        \r
32  *     &lt;/alternatives&gt;          \r
33  * &lt;/beans&gt;\r
34  * </pre>\r
35  * \r
36  * Please note that with Tomcat7 this beans.xml would be the one in your application's WEB-INF, which means you can set it once and\r
37  * for all. With Glassfish and JBoss, it would be the one in the META-INF directory of the mkjsf jar (the artifact of this project)\r
38  * meaning it would have to be re-applied with every update of new versions of mkjsf.  \r
39  * \r
40  * <h3>Configuring the service using web.xml only</h3>\r
41  * \r
42  * <p>For the web.xml configuration scheme (choosing WebXmlConfigReader in beans.xml)\r
43  * to pre-define the URL of the Pazpar2 to use and choose Pazpar2 as the selected\r
44  * service type, the configuration could be:</p>\r
45  * \r
46  * <pre>\r
47  *  &lt;context-param&gt;\r
48  *   &lt;param-name&gt;PAZPAR2_URL&lt;/param-name&gt;\r
49  *   &lt;param-value&gt;http://localhost:8004/&lt;/param-value&gt;\r
50  *  &lt;/context-param&gt;\r
51  *  &lt;context-param&gt;\r
52  *   &lt;description&gt;Service type. Possible values: SP, PZ2, TBD&lt;/description&gt;\r
53  *   &lt;param-name&gt;TYPE&lt;/param-name&gt;\r
54  *   &lt;param-value&gt;PZ2&lt;/param-value&gt;  \r
55  *  &lt;/context-param&gt;\r
56  * </pre>\r
57  * \r
58  * <h3>Configuring the service using 'Mk2Config' scheme</h3>\r
59  * \r
60  * <p>The Mk2ConfigReader scheme allows the configuration to exist outside of the web application archive. \r
61  * It supports name spaces for different parts of the application (as opposed to the web.xml scheme) and it \r
62  * supports different configurations for different virtual hosts using the same web application deployment.</p> \r
63  * <p>For the Mk2ConfigReader scheme to work, the web.xml must contain pointers to the configuration directory \r
64  * and properties file. The specific configuration itself would be in those files then.\r
65  * In this example the configuration directory is in the web application itself (war://testconfig). Usually it \r
66  * would probably be somewhere else in your file system.</p> \r
67  * <pre>\r
68  * &lt;context-param&gt;\r
69  *  &lt;param-name&gt;MASTERKEY_ROOT_CONFIG_DIR&lt;/param-name&gt;\r
70  *  &lt;param-value&gt;war://testconfig&lt;/param-value&gt;\r
71  * &lt;/context-param&gt;\r
72  * &lt;context-param&gt;\r
73  *  &lt;description&gt;\r
74  *   The sub directory to hold config file(s) for this Masterkey component.\r
75  *  &lt;/description&gt;\r
76  *  &lt;param-name&gt;MASTERKEY_COMPONENT_CONFIG_DIR&lt;/param-name&gt;\r
77  *  &lt;param-value&gt;/jsfdemo&lt;/param-value&gt;\r
78  * &lt;/context-param&gt;\r
79  * &lt;context-param&gt;\r
80  *  &lt;param-name&gt;MASTERKEY_CONFIG_FILE_NAME&lt;/param-name&gt;\r
81  *  &lt;param-value>jsfdemo.properties&lt;/param-value&gt;\r
82  * &lt;/context-param&gt;\r
83  * &lt;context-param&gt;\r
84  *  &lt;description&gt;\r
85  *   Defines the lifespan of configuration parameters as retrieved\r
86  *   from the file pointed to by MASTERKEY_CONFIG_FILE_NAME.\r
87  *   Can be SERVLET (cached) or REQUEST (read for every request).\r
88  *   Will default to SERVLET.\r
89  *  &lt;/description&gt;\r
90  *  &lt;param-name&gt;MASTERKEY_CONFIG_LIFE_TIME&lt;/param-name&gt;\r
91  *  &lt;param-value&gt;REQUEST&lt;/param-value&gt;\r
92  * &lt;/context-param&gt;\r
93  * </pre>\r
94  * \r
95  * <p>The jsfdemo.properties file might look like this for running against a \r
96  * local Pazpar2 service:</p>\r
97  * \r
98  * <code>pz2client.PAZPAR2_URL = http://localhost:8004/</code>\r
99  * \r
100  * <p>Some of the other known parameters in this format could be:</p>\r
101  * \r
102  * <pre>\r
103  * service.TYPE = SP              \r
104  * proxyclient.SERVICE_PROXY_URL = http://localhost:8080/service-proxy/\r
105  * </pre> \r
106  * \r
107  * <p>It's possible to implement a custom configuration scheme by either ignoring whatever scheme is \r
108  * injected and then applying the required values otherwise, OR by extending the ConfigurationReader\r
109  * and inject that class in beans.xml instead of any of the two predefined options. The extended\r
110  * class must construct a Configuration object -- which is basically a set of key-value pairs -- \r
111  * and then set the desired values and hand it off to the Configurable (currently Pz2Service, Pz2Client, \r
112  * and ServiceProxyClient)</p> \r
113  * \r
114  * <p>It would also be easy enough to simply set the URL runtime from the UI pages, using methods on \r
115  * Pz2Service (named 'pz2').</p> \r
116  * \r
117  */\r
118 package com.indexdata.mkjsf.config;