001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.commons.config; 021 022import org.slf4j.Logger; 023import org.slf4j.LoggerFactory; 024 025import org.apache.isis.core.commons.resource.ResourceStreamSource; 026import org.apache.isis.core.commons.resource.ResourceStreamSourceChainOfResponsibility; 027import org.apache.isis.core.commons.resource.ResourceStreamSourceFileSystem; 028 029/** 030 * Convenience implementation of {@link IsisConfigurationBuilder} that loads 031 * configuration resource from a specified directory (or directories) on the 032 * filesystem. 033 * 034 * @see ResourceStreamSourceFileSystem 035 */ 036public class IsisConfigurationBuilderFileSystem extends IsisConfigurationBuilderResourceStreams { 037 038 @SuppressWarnings("unused") 039 private static final Logger LOG = LoggerFactory.getLogger(IsisConfigurationBuilderFileSystem.class); 040 041 private static ResourceStreamSource createResourceStreamSource(final String... directories) { 042 final ResourceStreamSourceChainOfResponsibility composite = new ResourceStreamSourceChainOfResponsibility(); 043 for (final String directory : directories) { 044 composite.addResourceStreamSource(new ResourceStreamSourceFileSystem(directory)); 045 } 046 return composite; 047 } 048 049 public IsisConfigurationBuilderFileSystem(final String... directories) { 050 super(createResourceStreamSource(directories)); 051 } 052 053 public IsisConfigurationBuilderFileSystem() { 054 super(ResourceStreamSourceFileSystem.create(ConfigurationConstants.DEFAULT_CONFIG_DIRECTORY)); 055 } 056 057}