Package com.indexdata.mkjsf.config

The library comes with two alternative mechanisms for configuration of an application, but it is possible to apply a custom scheme too or not use the configurations at all.

See:
          Description

Interface Summary
Configurable Interface to be implemented by any part of an application that wish to use a ConfigurationReader for it's configuration.
ConfigurationReader Interface to be implemented by classes that read configurations from a source - i.e.
 

Class Summary
Configuration Represents a configuration as a set of key-value pairs
Mk2ConfigReader Reads configuration from a MasterKey configuration scheme
WebXmlConfigReader Reads a configuration from the context parameters of the deployment descriptor (web.xml)
 

Package com.indexdata.mkjsf.config Description

The library comes with two alternative mechanisms for configuration of an application, but it is possible to apply a custom scheme too or not use the configurations at all.

The library does require that a configuration scheme is chosen - in beans.xml as described below.

But the library does NOT impose any mandatory parameters in order to start up (except for those required for bootstrapping the configuration). The library does know of certain parameters, if it encounters them.

The known parameters are TYPE (service type) PAZPAR2_URL, SERVICE_ID, and SERVICE_PROXY_URL

The built-in configuration schemes are:

It must be determined deploy-time what configuration scheme to use, by selecting the preferred mechanism in the application's beans.xml. In this example the MasterKey configuration scheme is injected:

 <beans xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
     http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">  
     <alternatives>         
        <class>com.indexdata.mkjsf.config.Mk2ConfigReader</class>
        <!-- Options                      Mk2ConfigReader     -->
        <!--                              WebXmlConfigReader  -->        
     </alternatives>          
 </beans>
 

For the web.xml configuration scheme (choosing WebXmlConfigReader in beans.xml) to pre-define the URL of the Pazpar2 to use and choose Pazpar2 as the selected service type, the configuration could be:

  <context-param>
   <param-name>PAZPAR2_URL</param-name>
   <param-value>http://localhost:8004/</param-value>
  </context-param>
  <context-param>
   <description>Service type. Possible values: SP, PZ2, TBD</description>
   <param-name>TYPE</param-name>
   <param-value>PZ2</param-value>  
  </context-param>
 

For the Mk2ConfigReader scheme to work, the web.xml must then contain pointers to the configuration directory and properties file. The specific configuration itself would be in those files then. In this example the configuration directory is in the web application itself (war://testconfig). A more regular example would put it in a separate directory to not have it overwritten by each deployment of the war.

 <context-param>
  <param-name>MASTERKEY_ROOT_CONFIG_DIR</param-name>
  <param-value>war://testconfig</param-value>
 </context-param>
 <context-param>
  <description>
   The sub directory to hold config file(s) for this Masterkey component.
  </description>
  <param-name>MASTERKEY_COMPONENT_CONFIG_DIR</param-name>
  <param-value>/jsfdemo</param-value>
 </context-param>
 <context-param>
  <param-name>MASTERKEY_CONFIG_FILE_NAME</param-name>
  <param-value>jsfdemo.properties</param-value>
 </context-param>
 <context-param>
  <description>
   Defines the lifespan of configuration parameters as retrieved
   from the file pointed to by MASTERKEY_CONFIG_FILE_NAME.
   Can be SERVLET (cached) or REQUEST (read for every request).
   Will default to SERVLET.
  </description>
  <param-name>MASTERKEY_CONFIG_LIFE_TIME</param-name>
  <param-value>REQUEST</param-value>
 </context-param>
 

The jsfdemo.properties file might look like this for running against a local Pazpar2 service:

pz2client.PAZPAR2_URL = http://localhost:8004/

Some of the other known parameters in this format could be:

 service.TYPE = SP              
 proxyclient.SERVICE_PROXY_URL = http://localhost:8080/service-proxy/
 

It's possible to implement a custom configuration scheme by either ignoring whatever scheme is injected and then applying the required values otherwise, OR by extending the ConfigurationReader and inject that class in beans.xml instead of any of the two predefined options. The extended class must construct a Configuration object -- which is basically a set of key-value pairs -- and then set the desired values and hand it off to the Configurable (currently Pz2Service, Pz2Client, and ServiceProxyClient)

Finally it's possible to set the URL runtime even from the UI pages.



Copyright © 2013. All Rights Reserved.