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;
27 import org.collectionspace.services.common.*;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 * ServicesConfigReader reads service layer specific configuration
34 * $LastChangedRevision: $
37 public class ServicesConfigReaderImpl
38 extends AbstractConfigReaderImpl<ServiceConfig> {
40 final private static String CONFIG_FILE_NAME = "service-config.xml";
41 final Logger logger = LoggerFactory.getLogger(ServicesConfigReaderImpl.class);
42 private ServiceConfig serviceConfig;
43 private ClientType clientType;
44 private String clientClassName;
46 public ServicesConfigReaderImpl(String serverRootDir) {
51 public String getFileName() {
52 return CONFIG_FILE_NAME;
56 public void read() throws Exception {
57 String configFileName = getAbsoluteFileName(CONFIG_FILE_NAME);
58 File configFile = new File(configFileName);
59 if(!configFile.exists()){
60 String msg = "Could not find configuration file " + configFileName;
62 throw new RuntimeException(msg);
64 serviceConfig = (ServiceConfig) parse(configFile, ServiceConfig.class);
65 clientType = serviceConfig.getRepositoryClient().getClientType();
66 if(clientType == null){
67 String msg = "Missing <client-type> in <repository-client>";
69 throw new IllegalArgumentException(msg);
71 clientClassName = serviceConfig.getRepositoryClient().getClientClass();
72 if(clientClassName == null){
73 String msg = "Missing <client-class> in <repository-client>";
75 throw new IllegalArgumentException(msg);
77 if(logger.isDebugEnabled()){
78 logger.debug("using client=" + clientType.toString() + " class=" + clientClassName);
83 public ServiceConfig getConfiguration() {
87 public ClientType getClientType() {
91 public String getClientClass() {
92 return clientClassName;