- public void init(Pz2Configurator pz2conf) {\r
- if (client==null) {\r
- configurationErrors = new ArrayList<ApplicationError>();\r
- errorHelper = new ErrorHelper(pz2conf);\r
- logger.info(Utils.objectId(this) + " is configuring itself using the provided " + Utils.objectId(pz2conf));\r
- try {\r
- cfg = new Pazpar2ClientConfiguration(pz2conf.getConfig());\r
- } catch (ProxyErrorException pe) {\r
- logger.error("Could not configure Pazpar2 client: " + pe.getMessage());\r
- configurationErrors.add(new ConfigurationError("Pz2Client Config","ProxyError","Could not configure Pazpar2 client: " + pe.getMessage(),errorHelper));\r
- } catch (IOException io) {\r
- logger.error("Could not configure Pazpar2 client: " + io.getMessage());\r
- configurationErrors.add(new ConfigurationError("Pz2Client Config","ProxyError","Could not configure Pazpar2 client: " + io.getMessage(),errorHelper));\r
- }\r
- try {\r
- client = new Pazpar2ClientGeneric(cfg); \r
- } catch (ProxyErrorException pe) {\r
- logger.error("Could not instantiate Pazpar2 client: " + pe.getMessage());\r
- configurationErrors.add(new ConfigurationError("Pz2Client","ProxyError","Could not create Pazpar2 client: " +pe.getMessage(),errorHelper)); \r
- } \r
- logger.info("Got " + configurationErrors.size() + " configuration errors");\r
- resetDataObjects();\r
- } else {\r
- logger.warn("Attempt to configure session but it already has a configured client");\r
- }\r
+ public void init(SearchClient searchClient, ConfigurationReader configReader) {\r
+ configurationErrors = new ArrayList<ErrorInterface>();\r
+ errorHelper = new ErrorHelper(configReader); \r
+ logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
+ try {\r
+ searchClient.configure(configReader); \r
+ // At the time of writing this search client is injected using Weld. \r
+ // However, the client is used for asynchronously sending off requests\r
+ // to the server AND propagation of context to threads is currently \r
+ // not supported. Trying to do so throws a WELD-001303 error. \r
+ // To avoid that, a context free client is cloned from the context \r
+ // dependent one. \r
+ // If propagation to threads gets supported, the cloning can go. \r
+ this.searchClient = searchClient.cloneMe(); \r
+ \r
+ } catch (ConfigurationException e) {\r
+ configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader))); \r
+ } \r
+ logger.info(configReader.document());\r
+ resetDataObjects();\r