2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright 2009 University of California at Berkeley
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
16 * https://source.collectionspace.org/collection-space/LICENSE.txt
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
24 package org.collectionspace.services.common.config;
28 import org.collectionspace.services.config.ClientType;
29 import org.collectionspace.services.config.ServiceConfig;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
34 * ServicesConfigReader reads service layer specific configuration
36 * $LastChangedRevision: $
39 public class ServicesConfigReaderImpl
40 extends AbstractConfigReaderImpl<ServiceConfig> {
42 final private static String CONFIG_FILE_NAME = "service-config.xml";
43 final Logger logger = LoggerFactory.getLogger(ServicesConfigReaderImpl.class);
44 private ServiceConfig serviceConfig;
45 private ClientType clientType;
46 private String clientClassName;
48 public ServicesConfigReaderImpl(String serverRootDir) {
53 public String getFileName() {
54 return CONFIG_FILE_NAME;
58 public void read(boolean useAppGeneratedBindings) throws Exception {
59 String configFileName = getAbsoluteFileName(CONFIG_FILE_NAME);
60 read(configFileName, useAppGeneratedBindings);
64 public void read(String configFileName, boolean useAppGeneratedBindings) throws Exception {
65 if (logger.isDebugEnabled()) {
66 logger.debug("read() config file=" + configFileName);
68 File configFile = new File(configFileName);
69 if (!configFile.exists()) {
70 String msg = "Could not find configuration file " + configFile.getAbsolutePath(); //configFileName;
72 throw new RuntimeException(msg);
74 serviceConfig = (ServiceConfig) parse(configFile, ServiceConfig.class);
75 clientType = serviceConfig.getRepositoryClient().getClientType();
76 if (clientType == null) {
77 String msg = "Missing <client-type> in <repository-client>";
79 throw new IllegalArgumentException(msg);
81 clientClassName = serviceConfig.getRepositoryClient().getClientClass();
82 if (clientClassName == null) {
83 String msg = "Missing <client-class> in <repository-client>";
85 throw new IllegalArgumentException(msg);
87 if (logger.isDebugEnabled()) {
88 logger.debug("using client=" + clientType.toString() + " class=" + clientClassName);
93 public ServiceConfig getConfiguration() {
97 public ClientType getClientType() {
101 public String getClientClass() {
102 return clientClassName;