001 /*
002 * Apache License
003 * Version 2.0, January 2004
004 * http://www.apache.org/licenses/
005 *
006 * Copyright 2008 by chenillekit.org
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 */
014
015 package org.chenillekit.core.services;
016
017 import javax.naming.Context;
018 import javax.sql.DataSource;
019
020 import org.apache.commons.configuration.Configuration;
021 import org.apache.tapestry5.ioc.Resource;
022
023 /**
024 * @version $Id: ConfigurationService.java 349 2008-11-25 10:12:47Z homburgs $
025 */
026 public interface ConfigurationService
027 {
028 /**
029 * get the configuration from the named resource.
030 * <p/>
031 * the system properties merged auto. into the returned configuration
032 *
033 * @param configurationResource the configuration resource
034 *
035 * @return the configuration
036 */
037 Configuration getConfiguration(Resource configurationResource);
038
039 /**
040 * get the configuration from the named resource.
041 *
042 * @param configurationResource the configuration resource
043 * @param mergeWithSysProps merge the configuration resource with system properties
044 *
045 * @return the configuration
046 */
047 Configuration getConfiguration(Resource configurationResource, boolean mergeWithSysProps);
048
049 /**
050 * get the configuration from JNDI context.
051 *
052 * @param context the JNDI context
053 *
054 * @return the configuration
055 */
056 Configuration getConfiguration(Context context);
057
058 /**
059 * get the configuration from system (JVM).
060 *
061 * @return the configuration
062 */
063 Configuration getConfiguration();
064
065 /**
066 * Build a configuration from a table containing multiple configurations.
067 *
068 * @param datasource the datasource to connect to the database
069 * @param table the name of the table containing the configurations
070 * @param nameColumn the column containing the name of the configuration
071 * @param keyColumn the column containing the keys of the configuration
072 * @param valueColumn the column containing the values of the configuration
073 * @param name the name of the configuration
074 */
075 Configuration getConfiguration(DataSource datasource, String table, String nameColumn,
076 String keyColumn, String valueColumn, String name);
077 }