Improved: General refactoring and code improvements, package

org.apache.ofbiz.base.container.
(OFBIZ-9861)

Thanks Dennis Balkir for reporting and providing the patch.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1817744 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Brohl
2017-12-11 06:41:08 +00:00
parent 7cc0b229a6
commit ca83629678
4 changed files with 13 additions and 13 deletions
@@ -173,7 +173,7 @@ public class ComponentContainer implements Container {
}
/**
* Load all components in a directory because it does not contain
* Load all components in a directory because it does not contain
* a load-components.xml file. The components are sorted alphabetically
* for loading purposes
*
@@ -194,7 +194,7 @@ public class ComponentContainer implements Container {
if (componentPath.isDirectory() && !componentName.startsWith(".") && configFile.exists()) {
ComponentConfig config = retrieveComponentConfig(null, componentLocation);
if (config != null) {
if (config != null) {
loadComponent(config);
}
}
@@ -260,7 +260,7 @@ public class ComponentContainer implements Container {
}
location = location.startsWith("/") ? location.substring(1) : location;
String dirLoc = location.endsWith("/*") ? location.substring(0, location.length() - 2) : location;
String dirLoc = location.endsWith("/*") ? location.substring(0, location.length() - 2) : location;
File path = FileUtil.getFile(configRoot + dirLoc);
if (path.exists()) {
@@ -24,7 +24,7 @@ import org.apache.ofbiz.base.start.StartupCommand;
/**
* An OFBiz container. A container can be thought of as a background process.
*
*
* <p>
* When OFBiz starts, the main thread will create the <code>Container</code> instance and
* then call the container's <code>init</code> method. If the method returns without
@@ -35,7 +35,7 @@ import org.apache.ofbiz.base.start.StartupCommand;
* Implementations should anticipate asynchronous calls to the methods by different
* threads.
* </p>
*
*
* <p>Containers might be loaded more than once (have more than one instance).<p>
*/
public interface Container {
@@ -36,7 +36,7 @@ import edu.emory.mathcs.backport.java.util.Collections;
/**
* An object that loads containers (background processes).
*
*
* <p>Normally, instances of this class are created by OFBiz startup code, and
* client code should not create instances of this class. Client code is
* responsible for making sure containers are shut down properly. </p>
@@ -46,7 +46,7 @@ public class ContainerLoader implements StartupLoader {
public static final String module = ContainerLoader.class.getName();
private final List<Container> loadedContainers = new LinkedList<Container>();
private final List<Container> loadedContainers = new LinkedList<>();
/**
* @see org.apache.ofbiz.base.start.StartupLoader#load(Config, List)
@@ -78,11 +78,11 @@ public class ContainerLoader implements StartupLoader {
return ContainerConfig.getConfigurations(configFile);
} catch (ContainerException e) {
throw new StartupException(e);
}
}
}
private List<ContainerConfig.Configuration> filterContainersHavingMatchingLoaders(List<String> loaders,
Collection<ContainerConfig.Configuration> containerConfigs) throws StartupException {
Collection<ContainerConfig.Configuration> containerConfigs) {
return containerConfigs.stream()
.filter(containerCfg ->
UtilValidate.isEmpty(containerCfg.loaders) &&
@@ -94,7 +94,7 @@ public class ContainerLoader implements StartupLoader {
private List<Container> loadContainersFromConfigurations(List<ContainerConfig.Configuration> containerConfigs,
Config config, List<StartupCommand> ofbizCommands) throws StartupException {
List<Container> loadContainers = new ArrayList<Container>();
List<Container> loadContainers = new ArrayList<>();
for (ContainerConfig.Configuration containerCfg : containerConfigs) {
Debug.logInfo("Loading container: " + containerCfg.name, module);
Container tmpContainer = loadContainer(config.containerConfig, containerCfg, ofbizCommands);
@@ -104,7 +104,7 @@ public class ContainerLoader implements StartupLoader {
return loadContainers;
}
private Container loadContainer(String configFile,
private Container loadContainer(String configFile,
ContainerConfig.Configuration containerCfg,
List<StartupCommand> ofbizCommands) throws StartupException {
// load the container class
@@ -160,7 +160,7 @@ public class ContainerLoader implements StartupLoader {
public synchronized void unload() throws StartupException {
Debug.logInfo("Shutting down containers", module);
List<Container> reversedContainerList = new ArrayList<Container>(loadedContainers);
List<Container> reversedContainerList = new ArrayList<>(loadedContainers);
Collections.reverse(reversedContainerList);
for(Container loadedContainer : reversedContainerList) {
@@ -56,7 +56,7 @@ public class NamingServiceContainer implements Container {
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFileLocation);
// get the naming (JNDI) port
ContainerConfig.Configuration.Property port = cfg.getProperty("port");
if (port.value != null) {
try {