litesoft
@ 947
litesoft / trunk / Java / core / Server / src / org / litesoft / configuration / WebInfConfigAccessorLocator.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.configuration; import java.io.*; import org.litesoft.servlet.*; public class WebInfConfigAccessorLocator extends ConfigAccessorLocator { public static final String DEFAULT_WEB_INF_PROPERTIES_NAME = "Properties.properties"; public WebInfConfigAccessorLocator( String pAppNameForPropertyFileName ) { super( pAppNameForPropertyFileName + ".properties" ); } @Override public ConfigDataAccessor createConfigDataAccessor() { ConfigDataAccessor found = searchForConfigFileInWebInf(); if ( found == null ) { if ( null == (found = searchForConfigFileInFileSystem()) ) { throw unableToLocate(); } } return found; } private ConfigDataAccessor searchForConfigFileInWebInf() { File zWebInfDir = WebInfLocator.getDir( this ); if ( zWebInfDir == null ) { return null; } File zFile = new File( zWebInfDir, DEFAULT_WEB_INF_PROPERTIES_NAME ); if ( zFile.isFile() ) { return loadConfigAccessorFrom( zFile ); } zFile = new File( zWebInfDir, mRelativeConfigFilePath ); if ( zFile.isFile() ) { return loadConfigAccessorFrom( zFile ); } return null; } } |