Improved: Deprecate ‘ContainerConfig#getConfiguration(String, String)’

(OFBIZ-11100)

Since there is no global container configuration file anymore this
method should not be used.  It has been superseded by an overload
which do not require to pass the file name of the configuration file.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863020 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mathieu Lirzin
2019-07-13 21:38:51 +00:00
parent 72aba3778c
commit 16ee111ec3
8 changed files with 30 additions and 24 deletions
@@ -30,7 +30,6 @@ import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilURL;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.base.util.UtilXml;
import org.w3c.dom.Document;
@@ -49,29 +48,36 @@ public class ContainerConfig {
private static Map<String, Configuration> configurations = new LinkedHashMap<>();
public static Configuration getConfiguration(String containerName, String configFile) throws ContainerException {
/**
* Retrieves the container configuration element corresponding to a container name.
*
* @param containerName the name of the container to retrieve
* @param configFile the file name corresponding to the global container configuration file
* @return the corresponding configuration element.
* @throws ContainerException when no configuration element are found.
* @deprecated Use {@link #getConfiguration(String)} instead.
*/
@Deprecated
public static Configuration getConfiguration(String containerName, String configFile)
throws ContainerException {
return getConfiguration(containerName);
}
/**
* Retrieves the container configuration element corresponding to a container name.
*
* @param containerName the name of the container to retrieve
* @return the corresponding configuration element.
* @throws ContainerException when no configuration element are found.
*/
public static Configuration getConfiguration(String containerName) throws ContainerException {
Configuration configuration = configurations.get(containerName);
if (configuration == null) {
getConfigurations(configFile);
configuration = configurations.get(containerName);
}
if (configuration == null) {
throw new ContainerException("No container found with the name : " + containerName);
}
return configuration;
}
public static Collection<Configuration> getConfigurations(String configFile) throws ContainerException {
if (UtilValidate.isEmpty(configFile)) {
throw new ContainerException("configFile argument cannot be null or empty");
}
URL xmlUrl = UtilURL.fromResource(configFile);
if (xmlUrl == null) {
throw new ContainerException("Could not find container config file " + configFile);
}
return getConfigurations(xmlUrl);
}
public static Collection<Configuration> getConfigurations(URL xmlUrl) throws ContainerException {
if (xmlUrl == null) {
throw new ContainerException("xmlUrl argument cannot be null");
@@ -54,7 +54,7 @@ public class NamingServiceContainer implements Container {
this.name =name;
this.configFileLocation = configFile;
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFileLocation);
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name);
// get the naming (JNDI) port