Skip to content
Permalink
Browse files

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
  • Loading branch information
mthl committed Jul 13, 2019
1 parent 72aba37 commit 16ee111ec3044f97140475325b061b7993e7bc85
@@ -30,7 +30,6 @@
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 @@ private 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 void init(List<StartupCommand> ofbizCommands, String name, String configF
this.name =name;
this.configFileLocation = configFile;

ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFileLocation);
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name);

// get the naming (JNDI) port

@@ -103,7 +103,7 @@
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {

this.name = name;
ContainerConfig.Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
ContainerConfig.Configuration configuration = ContainerConfig.getConfiguration(name);
Property engineConfig = retrieveTomcatEngineConfig(configuration);

// tomcat setup
@@ -39,7 +39,7 @@
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
this.name = name;

ContainerConfig.Configuration cc = ContainerConfig.getConfiguration(name, configFile);
ContainerConfig.Configuration cc = ContainerConfig.getConfiguration(name);

preloadedDelegatorNames = StringUtil.split(ContainerConfig.getPropertyValue(cc, "preloaded-delegators", "default"), ", ");
}
@@ -101,7 +101,7 @@ public void init(List<StartupCommand> ofbizCommands, String name, String configF
ServiceDispatcher.enableJMS(false);
ServiceDispatcher.enableSvcs(false);

Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
Configuration configuration = ContainerConfig.getConfiguration(name);
Property delegatorNameProp = configuration.getProperty("delegator-name");
String overrideDelegator = loadDataProps.get(DELEGATOR_NAME);

@@ -46,7 +46,7 @@
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
this.name = name;
// initialize the LocalDispatcherFactory
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFile);
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name);
ContainerConfig.Configuration.Property dispatcherFactoryProperty = cfg.getProperty("dispatcher-factory");
if (dispatcherFactoryProperty == null || UtilValidate.isEmpty(dispatcherFactoryProperty.value)) {
throw new ContainerException("Unable to initialize container " + name + ": dispatcher-factory property is not set");
@@ -84,7 +84,7 @@ public void init(List<StartupCommand> ofbizCommands, String name, String configF

@Override
public boolean start() throws ContainerException {
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFile);
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name);
String dispatcherName = ContainerConfig.getPropertyValue(cfg, "dispatcher-name", "JavaMailDispatcher");
String delegatorName = ContainerConfig.getPropertyValue(cfg, "delegator-name", "default");
this.deleteMail = "true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"));
@@ -60,7 +60,7 @@ public void init(List<StartupCommand> ofbizCommands, String name, String configF
@Override
public boolean start() throws ContainerException {
// get the container config
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(containerName, configFile);
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(containerName);
ContainerConfig.Configuration.Property initialCtxProp = cfg.getProperty("use-initial-context");
ContainerConfig.Configuration.Property lookupHostProp = cfg.getProperty("bound-host");
ContainerConfig.Configuration.Property lookupPortProp = cfg.getProperty("bound-port");

0 comments on commit 16ee111

Please sign in to comment.
You can’t perform that action at this time.