net.smartlab.web.config.FileDomainConfigurationStrategy Maven / Gradle / Ivy
/*
* The SmartWeb Framework
* Copyright (C) 2004-2006
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* For further informations on the SmartWeb Framework please visit
*
* http://smartweb.sourceforge.net
*/
package net.smartlab.web.config;
import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.smartlab.config.Configuration;
import net.smartlab.config.ConfigurationException;
import net.smartlab.config.XMLConfiguration;
import net.smartlab.web.Domain;
/**
* @TODO documentation
* @author [email protected]
*
*/
public class FileDomainConfigurationStrategy implements DomainConfigurationStrategy {
/**
* @throws ConfigurationException
* @see net.smartlab.web.config.FactoryConfigurationStrategy#getConfiguration()
*/
public Configuration getConfiguration(Domain domain) throws ConfigurationException {
String archive = Domain.getLastArchiveName(domain.getClass());
URL file = Domain.getResource(this.getClass(), new String[] {"/META-INF/" + archive + ".xml",
"/META-INF/smartweb.jar.xml"});
return new XMLConfiguration(file);
}
/**
* @see net.smartlab.web.config.FactoryConfigurationStrategy#getConfiguration(java.lang.String)
*/
public Configuration getConfiguration(Domain domain, String filename) throws ConfigurationException {
Domain.getLastArchiveName(domain.getClass()); // used only for logging search path
URL file = Domain.getResource(this.getClass(), new String[] {"/META-INF/" + filename});
return new XMLConfiguration(file);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy