--- /dev/null
+package com.indexdata.pz2utils4jsf.config;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.enterprise.context.SessionScoped;\r
+import javax.enterprise.inject.Alternative;\r
+import javax.faces.context.ExternalContext;\r
+import javax.faces.context.FacesContext;\r
+import javax.inject.Named;\r
+import javax.servlet.ServletContext;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import com.indexdata.masterkey.config.MasterkeyConfiguration;\r
+import com.indexdata.masterkey.config.ModuleConfiguration;\r
+\r
+@Named @SessionScoped @Alternative\r
+public class Pz2ConfigureByMk2Config implements Pz2Configurator {\r
+\r
+ private static final long serialVersionUID = 8865086878660568870L;\r
+ private static Logger logger = Logger.getLogger(Pz2ConfigureByMk2Config.class);\r
+ private Pz2Config pz2config = null;\r
+\r
+ public Pz2ConfigureByMk2Config () throws IOException {\r
+ logger.debug("Instantiating Pazpar2 service configuration by MasterKey configuration scheme.");\r
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();\r
+ ServletContext servletContext = (ServletContext) externalContext.getContext(); \r
+ MasterkeyConfiguration mkConfigContext =\r
+ MasterkeyConfiguration.getInstance(servletContext,\r
+ "faces-component", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
+ ModuleConfiguration moduleConfig = mkConfigContext.getModuleConfiguration("pz2client"); \r
+ String pazpar2Url = moduleConfig.get("PAZPAR2_URL");\r
+ String pazpar2ServiceId = moduleConfig.get("PAZPAR2_SERVICE_ID");\r
+ pz2config = new Pz2Config(pazpar2Url,pazpar2ServiceId);\r
+ }\r
+ \r
+ @Override\r
+ public Pz2Config getConfig() {\r
+ return pz2config;\r
+ }\r
+ \r
+\r
+}\r
package com.indexdata.pz2utils4jsf.config;\r
\r
import javax.enterprise.context.SessionScoped;\r
+import javax.enterprise.inject.Alternative;\r
import javax.faces.context.ExternalContext;\r
import javax.faces.context.FacesContext;\r
import javax.inject.Named;\r
\r
import org.apache.log4j.Logger;\r
\r
-@SessionScoped @Named\r
+\r
+@Named @SessionScoped @Alternative\r
public class Pz2ConfigureByWebXml implements Pz2Configurator {\r
\r
private static final long serialVersionUID = 144390224959311772L;\r