You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mt...@apache.org on 2019/10/18 19:46:32 UTC
svn commit: r1868601 - in /ofbiz/ofbiz-framework/trunk: ./
framework/base/src/main/java/org/apache/ofbiz/base/component/
framework/base/src/main/java/org/apache/ofbiz/base/container/
framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/...
Author: mthl
Date: Fri Oct 18 19:46:32 2019
New Revision: 1868601
URL: http://svn.apache.org/viewvc?rev=1868601&view=rev
Log:
Improved: Refactor ‘ContainerConfig’ class
(OFBIZ-11256)
This removes some code duplication, make things immutable and add some javadoc.
Modified:
ofbiz/ofbiz-framework/trunk/build.gradle
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerConfig.java
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java
ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/NamingServiceContainer.java
ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java
ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java
ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java
ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/rmi/RmiServiceContainer.java
Modified: ofbiz/ofbiz-framework/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/build.gradle (original)
+++ ofbiz/ofbiz-framework/trunk/build.gradle Fri Oct 18 19:46:32 2019
@@ -307,7 +307,7 @@ checkstyle {
// the sum of errors that were present before introducing the
// âcheckstyleâ tool present in the framework and in the official
// plugins.
- maxErrors = 37967
+ maxErrors = 37947
// Currently there are a lot of errors so we need to temporarily
// hide them to avoid polluting the terminal output.
showViolations = false
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java Fri Oct 18 19:46:32 2019
@@ -37,7 +37,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.ofbiz.base.container.ContainerConfig;
-import org.apache.ofbiz.base.container.ContainerConfig.Configuration;
import org.apache.ofbiz.base.container.ContainerException;
import org.apache.ofbiz.base.location.FlexibleLocation;
import org.apache.ofbiz.base.util.Assert;
@@ -431,8 +430,7 @@ public final class ComponentConfig {
Collectors.toMap(rli -> rli.name, rli -> rli),
Collections::unmodifiableMap));
try {
- Collection<Configuration> configurations = ContainerConfig.getConfigurations(xmlUrl);
- this.configurations = Collections.unmodifiableList(new ArrayList<>(configurations));
+ configurations = ContainerConfig.getConfigurations(componentElement);
} catch (ContainerException ce) {
throw new ComponentException("Error reading container configurations for component: " + this.globalName, ce);
}
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerConfig.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerConfig.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerConfig.java Fri Oct 18 19:46:32 2019
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -15,39 +15,32 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *******************************************************************************/
+ */
package org.apache.ofbiz.base.container;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toList;
+
+import java.util.Collections;
import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
+import java.util.Objects;
import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.base.util.UtilXml;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
/**
- * ContainerConfig - Container configuration for ofbiz.xml
- *
+ * A container configuration.
*/
-public class ContainerConfig {
-
- private ContainerConfig() {}
-
- public static final String module = ContainerConfig.class.getName();
-
+public final class ContainerConfig {
+ /** The global container configuration store. */
private static Map<String, Configuration> configurations = new LinkedHashMap<>();
+ private ContainerConfig() { }
+
/**
* Retrieves the container configuration element corresponding to a container name.
*
@@ -78,29 +71,33 @@ public class ContainerConfig {
return configuration;
}
- public static Collection<Configuration> getConfigurations(URL xmlUrl) throws ContainerException {
- if (xmlUrl == null) {
- throw new ContainerException("xmlUrl argument cannot be null");
- }
- Collection<Configuration> result = getConfigurationPropsFromXml(xmlUrl);
+ /**
+ * Finds the container configuration elements in a .
+ *
+ * @param root the URL of the XML file which cannot be {@code null}
+ * @return a list of container configuration
+ * @throws ContainerException when failing to read the XML document.
+ */
+ public static List<Configuration> getConfigurations(Element root) throws ContainerException {
+ List<Configuration> res = UtilXml.childElementList(root, "container").stream()
+ .map(Configuration::new)
+ .collect(collectingAndThen(toList(), Collections::unmodifiableList));
synchronized (ContainerConfig.class) {
- for (Configuration container : result) {
- configurations.put(container.name, container);
- }
+ res.forEach(cfg -> configurations.put(cfg.name, cfg));
}
- return result;
+ return res;
}
- public static String getPropertyValue(ContainerConfig.Configuration parentProp, String name, String defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static String getPropertyValue(Configuration parentProp, String name, String defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
return prop.value;
}
- public static int getPropertyValue(ContainerConfig.Configuration parentProp, String name, int defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static int getPropertyValue(Configuration parentProp, String name, int defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
@@ -111,24 +108,24 @@ public class ContainerConfig {
}
}
- public static boolean getPropertyValue(ContainerConfig.Configuration parentProp, String name, boolean defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static boolean getPropertyValue(Configuration parentProp, String name, boolean defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
return "true".equalsIgnoreCase(prop.value);
}
- public static String getPropertyValue(ContainerConfig.Configuration.Property parentProp, String name, String defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static String getPropertyValue(Property parentProp, String name, String defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
return prop.value;
}
- public static int getPropertyValue(ContainerConfig.Configuration.Property parentProp, String name, int defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static int getPropertyValue(Property parentProp, String name, int defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
@@ -139,97 +136,181 @@ public class ContainerConfig {
}
}
- public static boolean getPropertyValue(ContainerConfig.Configuration.Property parentProp, String name, boolean defaultValue) {
- ContainerConfig.Configuration.Property prop = parentProp.getProperty(name);
+ public static boolean getPropertyValue(Property parentProp, String name, boolean defaultValue) {
+ Property prop = parentProp.getProperty(name);
if (prop == null || UtilValidate.isEmpty(prop.value)) {
return defaultValue;
}
return "true".equalsIgnoreCase(prop.value);
}
- private static Collection<Configuration> getConfigurationPropsFromXml(URL xmlUrl) throws ContainerException {
- Document containerDocument = null;
- try {
- containerDocument = UtilXml.readXmlDocument(xmlUrl, true);
- } catch (SAXException | ParserConfigurationException | IOException e) {
- throw new ContainerException("Error reading the container config file: " + xmlUrl, e);
- }
- Element root = containerDocument.getDocumentElement();
- List<Configuration> result = new ArrayList<>();
- for (Element curElement: UtilXml.childElementList(root, "container")) {
- result.add(new Configuration(curElement));
+ /**
+ * A container configuration.
+ */
+ public static class Configuration {
+ /** The identifier of the configuration. */
+ private final String name;
+ /** The name of class the configuration. */
+ private final String className;
+ /** The list of loader names triggering the launch of the container. */
+ private final List<String> loaders;
+ /** The container property elements. */
+ private final Map<String, Property> properties;
+
+ /**
+ * Constructs a container configuration.
+ *
+ * @param element the {@code <container>} XML element to parse
+ */
+ public Configuration(Element element) {
+ name = element.getAttribute("name");
+ className = element.getAttribute("class");
+ loaders = Collections.unmodifiableList(StringUtil.split(element.getAttribute("loaders"), ","));
+ properties = Property.parseProps(element);
+ }
+
+ /**
+ * @return the name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return the className
+ */
+ public String className() {
+ return className;
+ }
+
+ /**
+ * @return the loaders
+ */
+ public List<String> loaders() {
+ return loaders;
+ }
+
+ /**
+ * @return the properties
+ */
+ public Map<String, Property> properties() {
+ return properties;
+ }
+
+ /**
+ * Provides the child property corresponding to a specified identifier.
+ *
+ * @param name the child property identifier
+ * @return the property corresponding to {@code name} or {@code null} if the identifier is absent.
+ */
+ public Property getProperty(String name) {
+ return properties().get(name);
}
- return result;
- }
- public static class Configuration {
- public final String name;
- public final String className;
- public final List<String> loaders;
- public final Map<String, Property> properties;
+ /**
+ * Provides all the child properties whose values are equal a specified value.
+ *
+ * @param value the value to match
+ * @return a list of matching properties
+ */
+ public List<Property> getPropertiesWithValue(String value) {
+ return Property.getPropertiesWithValue(properties(), value);
+ }
+ }
- public Configuration(Element element) {
- this.name = element.getAttribute("name");
- this.className = element.getAttribute("class");
- this.loaders = StringUtil.split(element.getAttribute("loaders"), ",");
-
- properties = new LinkedHashMap<>();
- for (Element curElement: UtilXml.childElementList(element, "property")) {
- Property property = new Property(curElement);
- properties.put(property.name, property);
+ /**
+ * A tree of container configuration properties.
+ */
+ public static class Property {
+ /** The identifier of the configuration element */
+ private final String name;
+ /** The value associated with the {@code name} identifier. */
+ private final String value;
+ /** The properties children */
+ private final Map<String, Property> properties;
+
+ /**
+ * Constructs a container configuration element.
+ *
+ * @param element the {@code <property>} XML element containing the configuration.
+ */
+ public Property(Element element) {
+ name = element.getAttribute("name");
+ String value = element.getAttribute("value");
+ if (UtilValidate.isEmpty(value)) {
+ value = UtilXml.childElementValue(element, "property-value");
}
+ this.value = value;
+ this.properties = parseProps(element);
}
+ /**
+ * @return the name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String value() {
+ return value;
+ }
+
+ /**
+ * @return the properties
+ */
+ public Map<String, Property> properties() {
+ return properties;
+ }
+
+ /**
+ * Provides the child property corresponding to a specified identifier.
+ *
+ * @param name the child property identifier
+ * @return the property corresponding to {@code name} or {@code null} if the identifier is absent.
+ */
public Property getProperty(String name) {
return properties.get(name);
}
+ /**
+ * Provides all the child properties whose values are equal a specified value.
+ *
+ * @param value the value to match
+ * @return a list of matching properties
+ */
public List<Property> getPropertiesWithValue(String value) {
- List<Property> props = new LinkedList<>();
- if (UtilValidate.isNotEmpty(properties)) {
- for (Property p: properties.values()) {
- if (p != null && value.equals(p.value)) {
- props.add(p);
- }
- }
- }
- return props;
+ return getPropertiesWithValue(properties, value);
}
- public static class Property {
- public String name;
- public String value;
- public Map<String, Property> properties;
-
- public Property(Element element) {
- this.name = element.getAttribute("name");
- this.value = element.getAttribute("value");
- if (UtilValidate.isEmpty(this.value)) {
- this.value = UtilXml.childElementValue(element, "property-value");
- }
-
- properties = new LinkedHashMap<>();
- for (Element curElement: UtilXml.childElementList(element, "property")) {
- Property property = new Property(curElement);
- properties.put(property.name, property);
- }
- }
-
- public Property getProperty(String name) {
- return properties.get(name);
- }
-
- public List<Property> getPropertiesWithValue(String value) {
- List<Property> props = new LinkedList<>();
- if (UtilValidate.isNotEmpty(properties)) {
- for (Property p: properties.values()) {
- if (p != null && value.equals(p.value)) {
- props.add(p);
- }
- }
- }
- return props;
- }
+ /**
+ * Aggregates the {@code <property>} XML elements in a Map.
+ *
+ * @param root the root XML Element containing {@code <property>} children
+ * @return a map of property elements
+ */
+ private static Map<String, Property> parseProps(Element root) {
+ LinkedHashMap<String, Property> res = new LinkedHashMap<>();
+ UtilXml.childElementList(root, "property").forEach(el -> {
+ Property p = new Property(el);
+ res.put(p.name, p);
+ });
+ return Collections.unmodifiableMap(res);
+ }
+
+ /**
+ * Provides all the child properties whose values are equal a specified value.
+ *
+ * @param value the value to match
+ * @return a list of matching properties
+ */
+ private static List<Property> getPropertiesWithValue(Map<String, Property> propkvs, String value) {
+ return propkvs.values().stream()
+ .filter(Objects::nonNull)
+ .filter(p -> value.equals(p.value))
+ .collect(toList());
}
}
}
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/ContainerLoader.java Fri Oct 18 19:46:32 2019
@@ -102,11 +102,11 @@ public class ContainerLoader {
List<StartupCommand> ofbizCommands) throws StartupException {
List<Container> loadContainers = new ArrayList<>();
for (ContainerConfig.Configuration containerCfg : ComponentConfig.getAllConfigurations()) {
- if (intersects(containerCfg.loaders, loaders)) {
- Debug.logInfo("Loading container: " + containerCfg.name, module);
+ if (intersects(containerCfg.loaders(), loaders)) {
+ Debug.logInfo("Loading container: " + containerCfg.name(), module);
Container tmpContainer = loadContainer(containerCfg, ofbizCommands);
loadContainers.add(tmpContainer);
- Debug.logInfo("Loaded container: " + containerCfg.name, module);
+ Debug.logInfo("Loaded container: " + containerCfg.name(), module);
}
}
return loadContainers;
@@ -119,7 +119,7 @@ public class ContainerLoader {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class<?> containerClass;
try {
- containerClass = loader.loadClass(containerCfg.className);
+ containerClass = loader.loadClass(containerCfg.className());
} catch (ClassNotFoundException e) {
throw new StartupException("Cannot locate container class", e);
}
@@ -132,7 +132,7 @@ public class ContainerLoader {
try {
containerObj = (Container) containerClass.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
- throw new StartupException("Cannot create " + containerCfg.name, e);
+ throw new StartupException("Cannot create " + containerCfg.name(), e);
}
if (containerObj == null) {
throw new StartupException("Unable to create instance of component container");
@@ -140,9 +140,9 @@ public class ContainerLoader {
// initialize the container object
try {
- containerObj.init(ofbizCommands, containerCfg.name, null);
+ containerObj.init(ofbizCommands, containerCfg.name(), null);
} catch (ContainerException e) {
- throw new StartupException("Cannot init() " + containerCfg.name, e);
+ throw new StartupException("Cannot init() " + containerCfg.name(), e);
}
return containerObj;
Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/NamingServiceContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/NamingServiceContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/NamingServiceContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/container/NamingServiceContainer.java Fri Oct 18 19:46:32 2019
@@ -58,19 +58,19 @@ public class NamingServiceContainer impl
// get the naming (JNDI) port
- ContainerConfig.Configuration.Property port = cfg.getProperty("port");
- if (port.value != null) {
+ ContainerConfig.Property port = cfg.getProperty("port");
+ if (port.value() != null) {
try {
- this.namingPort = Integer.parseInt(port.value) + Start.getInstance().getConfig().portOffset;
+ this.namingPort = Integer.parseInt(port.value()) + Start.getInstance().getConfig().portOffset;
} catch (Exception e) {
throw new ContainerException("Invalid port defined in container [naming-container] configuration or as portOffset; not a valid int");
}
}
// get the naming (JNDI) server
- ContainerConfig.Configuration.Property host = cfg.getProperty("host");
- if (host != null && host.value != null) {
- this.namingHost = host.value ;
+ ContainerConfig.Property host = cfg.getProperty("host");
+ if (host != null && host.value() != null) {
+ this.namingHost = host.value() ;
}
try {
Modified: ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java Fri Oct 18 19:46:32 2019
@@ -69,7 +69,7 @@ import org.apache.ofbiz.base.concurrent.
import org.apache.ofbiz.base.container.Container;
import org.apache.ofbiz.base.container.ContainerConfig;
import org.apache.ofbiz.base.container.ContainerConfig.Configuration;
-import org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property;
+import org.apache.ofbiz.base.container.ContainerConfig.Property;
import org.apache.ofbiz.base.container.ContainerException;
import org.apache.ofbiz.base.location.FlexibleLocation;
import org.apache.ofbiz.base.start.Start;
@@ -165,7 +165,7 @@ public class CatalinaContainer implement
}
private static Property retrieveTomcatEngineConfig(ContainerConfig.Configuration cc) throws ContainerException {
- List<ContainerConfig.Configuration.Property> engineProps = cc.getPropertiesWithValue("engine");
+ List<ContainerConfig.Property> engineProps = cc.getPropertiesWithValue("engine");
if (UtilValidate.isEmpty(engineProps)) {
throw new ContainerException("Cannot load CatalinaContainer; no engines defined.");
}
@@ -175,9 +175,8 @@ public class CatalinaContainer implement
return engineProps.get(0);
}
- private static Tomcat prepareTomcatServer(ContainerConfig.Configuration cc,
- ContainerConfig.Configuration.Property engineConfig) throws ContainerException {
-
+ private static Tomcat prepareTomcatServer(ContainerConfig.Configuration cc, ContainerConfig.Property engineConfig)
+ throws ContainerException {
System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("ofbiz.home") + "/" +
ContainerConfig.getPropertyValue(cc, "catalina-runtime-home", "runtime/catalina"));
System.setProperty(Globals.CATALINA_BASE_PROP, System.getProperty(Globals.CATALINA_HOME_PROP));
@@ -189,7 +188,7 @@ public class CatalinaContainer implement
if (defaultHostProp == null) {
throw new ContainerException("default-host element of server property is required for catalina!");
}
- tomcat.setHostname(defaultHostProp.value);
+ tomcat.setHostname(defaultHostProp.value());
if (ContainerConfig.getPropertyValue(cc, "use-naming", false)) {
tomcat.enableNaming();
@@ -207,7 +206,7 @@ public class CatalinaContainer implement
private static Engine prepareTomcatEngine(Tomcat tomcat, Property engineConfig) {
Engine engine = tomcat.getEngine();
- engine.setName(engineConfig.name);
+ engine.setName(engineConfig.name());
// set the JVM Route property (JK/JK2)
String jvmRoute = ContainerConfig.getPropertyValue(engineConfig, "jvm-route", null);
@@ -279,7 +278,7 @@ public class CatalinaContainer implement
channel.setMembershipService(prepareChannelMcastService(clusterProp));
SimpleTcpCluster cluster = new SimpleTcpCluster();
- cluster.setClusterName(clusterProp.name);
+ cluster.setClusterName(clusterProp.name());
cluster.setManagerTemplate(prepareClusterManager(clusterProp));
cluster.setChannel(channel);
cluster.addValve(prepareClusterValve(clusterProp));
@@ -416,7 +415,7 @@ public class CatalinaContainer implement
throw new ContainerException("Cannot load CatalinaContainer; no connectors defined!");
}
return connectorProps.stream()
- .filter(connectorProp -> UtilValidate.isNotEmpty(connectorProp.properties))
+ .filter(connectorProp -> UtilValidate.isNotEmpty(connectorProp.properties()))
.map(connectorProp -> prepareConnector(connectorProp))
.collect(Collectors.toList());
}
@@ -428,18 +427,23 @@ public class CatalinaContainer implement
connector.addUpgradeProtocol(new Http2Protocol());
Debug.logInfo("Tomcat " + connector + ": enabled HTTP/2", module);
}
- connectorProp.properties.values().stream()
- .filter(prop -> !"protocol".equals(prop.name) && !"upgradeProtocol".equals(prop.name) && !"port".equals(prop.name))
+ connectorProp.properties().values().stream()
+ .filter(prop -> {
+ String name = prop.name();
+ return !"protocol".equals(name) && !"upgradeProtocol".equals(name) && !"port".equals(name);
+ })
.forEach(prop -> {
- if (IntrospectionUtils.setProperty(connector, prop.name, prop.value)) {
- if (prop.name.indexOf("Pass") != -1) {
+ String name = prop.name();
+ String value = prop.value();
+ if (IntrospectionUtils.setProperty(connector, name, value)) {
+ if (name.indexOf("Pass") != -1) {
// this property may be a password, do not include its value in the logs
- Debug.logInfo("Tomcat " + connector + ": set " + prop.name, module);
+ Debug.logInfo("Tomcat " + connector + ": set " + name, module);
} else {
- Debug.logInfo("Tomcat " + connector + ": set " + prop.name + "=" + prop.value, module);
+ Debug.logInfo("Tomcat " + connector + ": set " + name + "=" + value, module);
}
} else {
- Debug.logWarning("Tomcat " + connector + ": ignored parameter " + prop.name, module);
+ Debug.logWarning("Tomcat " + connector + ": ignored parameter " + name, module);
}
});
return connector;
Modified: ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java Fri Oct 18 19:46:32 2019
@@ -35,7 +35,7 @@ import org.apache.ofbiz.base.component.C
import org.apache.ofbiz.base.container.Container;
import org.apache.ofbiz.base.container.ContainerConfig;
import org.apache.ofbiz.base.container.ContainerConfig.Configuration;
-import org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property;
+import org.apache.ofbiz.base.container.ContainerConfig.Property;
import org.apache.ofbiz.base.container.ContainerException;
import org.apache.ofbiz.base.start.StartupCommand;
import org.apache.ofbiz.base.start.StartupCommandUtil;
@@ -108,7 +108,7 @@ public class EntityDataLoadContainer imp
if ("all-tenants".equals(overrideDelegator)) {
// load data for all tenants
for (GenericValue tenant : getTenantList(delegatorNameProp)) {
- String tenantDelegator = delegatorNameProp.value + "#" + tenant.getString("tenantId");
+ String tenantDelegator = delegatorNameProp.value() + "#" + tenant.getString("tenantId");
loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, tenantDelegator);
}
} else {
@@ -212,11 +212,11 @@ public class EntityDataLoadContainer imp
if (overrideGroup != null) {
return overrideGroup;
} else {
- ContainerConfig.Configuration.Property entityGroupNameProp = cfg.getProperty("entity-group-name");
- if (entityGroupNameProp == null || UtilValidate.isEmpty(entityGroupNameProp.value)) {
+ Property entityGroupNameProp = cfg.getProperty("entity-group-name");
+ if (entityGroupNameProp == null || UtilValidate.isEmpty(entityGroupNameProp.value())) {
throw new ContainerException("Invalid entity-group-name defined in container configuration");
} else {
- return entityGroupNameProp.value;
+ return entityGroupNameProp.value();
}
}
}
@@ -236,12 +236,13 @@ public class EntityDataLoadContainer imp
}
private static Delegator getDelegatorFromProp(Property delegatorNameProp) throws ContainerException {
- if (delegatorNameProp != null && UtilValidate.isNotEmpty(delegatorNameProp.value)) {
- Delegator delegator = DelegatorFactory.getDelegator(delegatorNameProp.value);
+ if (delegatorNameProp != null && UtilValidate.isNotEmpty(delegatorNameProp.value())) {
+ String delegValue = delegatorNameProp.value();
+ Delegator delegator = DelegatorFactory.getDelegator(delegValue);
if (delegator != null) {
return delegator;
} else {
- throw new ContainerException("Invalid delegator name: " + delegatorNameProp.value);
+ throw new ContainerException("Invalid delegator name: " + delegValue);
}
} else {
throw new ContainerException("Invalid delegator name defined in container configuration");
Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/ServiceContainer.java Fri Oct 18 19:46:32 2019
@@ -47,13 +47,13 @@ public class ServiceContainer implements
this.name = name;
// initialize the LocalDispatcherFactory
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name);
- ContainerConfig.Configuration.Property dispatcherFactoryProperty = cfg.getProperty("dispatcher-factory");
- if (dispatcherFactoryProperty == null || UtilValidate.isEmpty(dispatcherFactoryProperty.value)) {
+ ContainerConfig.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");
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
- Class<?> c = loader.loadClass(dispatcherFactoryProperty.value);
+ Class<?> c = loader.loadClass(dispatcherFactoryProperty.value());
dispatcherFactory = (LocalDispatcherFactory) c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new ContainerException(e);
Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/mail/JavaMailContainer.java Fri Oct 18 19:46:32 2019
@@ -107,8 +107,7 @@ public class JavaMailContainer implement
ServiceMcaUtil.readConfig();
// load the listeners
- List<ContainerConfig.Configuration.Property> configs = cfg.getPropertiesWithValue("store-listener");
- for (ContainerConfig.Configuration.Property prop: configs) {
+ for (ContainerConfig.Property prop: cfg.getPropertiesWithValue("store-listener")) {
Session session = this.makeSession(prop);
Store store = this.getStore(session);
stores.put(store, session);
@@ -138,12 +137,12 @@ public class JavaMailContainer implement
}
// java-mail methods
- protected Session makeSession(ContainerConfig.Configuration.Property client) {
+ protected Session makeSession(ContainerConfig.Property client) {
Properties props = new Properties();
- Map<String, ContainerConfig.Configuration.Property> clientProps = client.properties;
+ Map<String, ContainerConfig.Property> clientProps = client.properties();
if (clientProps != null) {
- for (ContainerConfig.Configuration.Property p: clientProps.values()) {
- props.setProperty(p.name.toLowerCase(Locale.getDefault()), p.value);
+ for (ContainerConfig.Property p: clientProps.values()) {
+ props.setProperty(p.name().toLowerCase(Locale.getDefault()), p.value());
}
}
return Session.getInstance(props);
Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/rmi/RmiServiceContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/rmi/RmiServiceContainer.java?rev=1868601&r1=1868600&r2=1868601&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/rmi/RmiServiceContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/rmi/RmiServiceContainer.java Fri Oct 18 19:46:32 2019
@@ -61,29 +61,29 @@ public class RmiServiceContainer impleme
public boolean start() throws ContainerException {
// get the container config
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");
- ContainerConfig.Configuration.Property lookupNameProp = cfg.getProperty("bound-name");
- ContainerConfig.Configuration.Property delegatorProp = cfg.getProperty("delegator-name");
- ContainerConfig.Configuration.Property clientProp = cfg.getProperty("client-factory");
- ContainerConfig.Configuration.Property serverProp = cfg.getProperty("server-factory");
+ ContainerConfig.Property initialCtxProp = cfg.getProperty("use-initial-context");
+ ContainerConfig.Property lookupHostProp = cfg.getProperty("bound-host");
+ ContainerConfig.Property lookupPortProp = cfg.getProperty("bound-port");
+ ContainerConfig.Property lookupNameProp = cfg.getProperty("bound-name");
+ ContainerConfig.Property delegatorProp = cfg.getProperty("delegator-name");
+ ContainerConfig.Property clientProp = cfg.getProperty("client-factory");
+ ContainerConfig.Property serverProp = cfg.getProperty("server-factory");
// check the required lookup-name property
- if (lookupNameProp == null || UtilValidate.isEmpty(lookupNameProp.value)) {
+ if (lookupNameProp == null || UtilValidate.isEmpty(lookupNameProp.value())) {
throw new ContainerException("Invalid lookup-name defined in container configuration");
} else {
- this.name = lookupNameProp.value;
+ this.name = lookupNameProp.value();
}
// check the required delegator-name property
- if (delegatorProp == null || UtilValidate.isEmpty(delegatorProp.value)) {
+ if (delegatorProp == null || UtilValidate.isEmpty(delegatorProp.value())) {
throw new ContainerException("Invalid delegator-name defined in container configuration");
}
- String useCtx = initialCtxProp == null || initialCtxProp.value == null ? "false" : initialCtxProp.value;
- String host = lookupHostProp == null || lookupHostProp.value == null ? "localhost" : lookupHostProp.value;
- String port = lookupPortProp == null || lookupPortProp.value == null ? "1099" : lookupPortProp.value;
+ String useCtx = initialCtxProp == null || initialCtxProp.value() == null ? "false" : initialCtxProp.value();
+ String host = lookupHostProp == null || lookupHostProp.value() == null ? "localhost" : lookupHostProp.value();
+ String port = lookupPortProp == null || lookupPortProp.value() == null ? "1099" : lookupPortProp.value();
if (Start.getInstance().getConfig().portOffset != 0) {
Integer portValue = Integer.valueOf(port);
portValue += Start.getInstance().getConfig().portOffset;
@@ -103,17 +103,17 @@ public class RmiServiceContainer impleme
ClassLoader loader = Thread.currentThread().getContextClassLoader();
// load the factories
- if (clientProp != null && UtilValidate.isNotEmpty(clientProp.value)) {
+ if (clientProp != null && UtilValidate.isNotEmpty(clientProp.value())) {
try {
- Class<?> c = loader.loadClass(clientProp.value);
+ Class<?> c = loader.loadClass(clientProp.value());
csf = (RMIClientSocketFactory) c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new ContainerException(e);
}
}
- if (serverProp != null && UtilValidate.isNotEmpty(serverProp.value)) {
+ if (serverProp != null && UtilValidate.isNotEmpty(serverProp.value())) {
try {
- Class<?> c = loader.loadClass(serverProp.value);
+ Class<?> c = loader.loadClass(serverProp.value());
ssf = (RMIServerSocketFactory) c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new ContainerException(e);
@@ -130,7 +130,7 @@ public class RmiServiceContainer impleme
}
// get the delegator for this container
- Delegator delegator = DelegatorFactory.getDelegator(delegatorProp.value);
+ Delegator delegator = DelegatorFactory.getDelegator(delegatorProp.value());
// create the LocalDispatcher
LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(name, delegator);