Author: mbrohl
Date: Sun Dec 17 19:14:33 2017
New Revision: 1818509

URL: http://svn.apache.org/viewvc?rev=1818509&view=rev
Log:
Improved: General refactoring and code improvements, package 
org.apache.ofbiz.base.start.
(OFBIZ-9937)

Thanks Dennis Balkir for reporting and providing the patches.

Modified:
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminClient.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Start.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommand.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
    
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupException.java

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminClient.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminClient.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminClient.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminClient.java
 Sun Dec 17 19:14:33 2017
@@ -37,7 +37,7 @@ import org.apache.ofbiz.base.start.Admin
 class AdminClient {
 
     /**
-     * Send a command through network to OFBiz server 
+     * Send a command through network to OFBiz server
      * to show its status (running, stopping, ...)
      *
      * @param config OFBiz configuration
@@ -60,7 +60,7 @@ class AdminClient {
      * to shut itself down.
      *
      * @param config OFBiz configuration
-     * @return shutdownMessage message from server 
+     * @return shutdownMessage message from server
      *   on receiving shutdown request
      */
     static String requestShutdown(Config config) {

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/AdminServer.java
 Sun Dec 17 19:14:33 2017
@@ -70,7 +70,7 @@ final class AdminServer extends Thread {
         while (!Thread.interrupted()) {
             try (Socket clientSocket = serverSocket.accept()){
 
-                System.out.println("Received connection from - " 
+                System.out.println("Received connection from - "
                         + clientSocket.getInetAddress() + " : "
                         + clientSocket.getPort());
 

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Classpath.java
 Sun Dec 17 19:14:33 2017
@@ -29,8 +29,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
-import org.apache.poi.util.LocaleUtil;
-
 /**
  * A class path accumulator.
  * <p>You can build a class path by repeatedly calling the addXxx methods,
@@ -49,7 +47,7 @@ public final class Classpath {
     /**
      * Adds a class path component. The component may be a directory or a file.
      * If <code>component</code> does not exist, the method does nothing.
-     * 
+     *
      * @param component The class path component to add
      * @return <code>true</code> if the component was added
      * @throws IOException if there was a problem parsing the component
@@ -76,7 +74,7 @@ public final class Classpath {
     /**
      * Adds a class path component. The component may be a directory or a file.
      * If <code>component</code> does not exist, the method does nothing.
-     * 
+     *
      * @param component The class path component to add
      * @return <code>true</code> if the component was added
      * @throws IOException if there was a problem parsing the component
@@ -93,7 +91,7 @@ public final class Classpath {
      * Scans a directory and adds all files ending with ".jar" or ".zip" to
      * the class path.
      * If <code>path</code> is not a directory, the method does nothing.
-     * 
+     *
      * @param path the directory to scan
      * @throws IOException if there was a problem processing the directory
      * @throws IllegalArgumentException if <code>path</code> is null
@@ -138,7 +136,7 @@ public final class Classpath {
 
     /**
      * Returns a list of class path component URLs.
-     * 
+     *
      * @return A list of class path component URLs
      * @throws MalformedURLException
      */

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Start.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Start.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Start.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/Start.java
 Sun Dec 17 19:14:33 2017
@@ -35,14 +35,14 @@ import java.util.concurrent.atomic.Atomi
  * </p>
  * <p>
  * This class uses a singleton pattern to guarantee that only one server 
instance
- * is running in the VM. Client code retrieves the instance by using the 
+ * is running in the VM. Client code retrieves the instance by using the
  * <tt>getInstance()</tt> static method.
  * </p>
  */
 public final class Start {
 
     private Config config = null;
-    private final AtomicReference<ServerState> serverState = new 
AtomicReference<ServerState>(ServerState.STARTING);
+    private final AtomicReference<ServerState> serverState = new 
AtomicReference<>(ServerState.STARTING);
 
     // Singleton, do not change
     private static final Start instance = new Start();
@@ -50,9 +50,9 @@ public final class Start {
     }
 
     /**
-     * main is the entry point to execute high level OFBiz commands 
+     * main is the entry point to execute high level OFBiz commands
      * such as starting, stopping or checking the status of the server.
-     * 
+     *
      * @param args The commands for OFBiz
      */
     public static void main(String[] args) {

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommand.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommand.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommand.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommand.java
 Sun Dec 17 19:14:33 2017
@@ -23,9 +23,9 @@ import java.util.Map;
 
 /**
  * A command line argument passed to OFBiz
- * 
+ *
  * <p>
- * A <tt>StartupCommand</tt> represents a processed command line argument 
passed 
+ * A <tt>StartupCommand</tt> represents a processed command line argument 
passed
  * to OFBiz such that it is no longer a raw string but an instance of this 
class.
  * For example: <code>java -jar build/libs/ofbiz.jar --status</code> where 
status is a command.
  * </p>
@@ -50,7 +50,7 @@ public final class StartupCommand {
         //required parameters
         private final String name;
 
-        //optional parameters       
+        //optional parameters
         private Map<String,String> properties;
 
         public Builder(String name) {
@@ -61,8 +61,8 @@ public final class StartupCommand {
             return this;
         }
         public Builder addProperty(String key, String value) {
-            if(properties == null) {
-                properties = new HashMap<String,String>();
+            if (properties == null) {
+                properties = new HashMap<>();
             }
             properties.put(key, value);
             return this;

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java
 Sun Dec 17 19:14:33 2017
@@ -218,7 +218,7 @@ public final class StartupCommandUtil {
     }
 
     private static final List<StartupCommand> 
mapCommonsCliOptionsToStartupCommands(final CommandLine commandLine) {
-        Set<Option> uniqueOptions = new 
HashSet<Option>(Arrays.asList(commandLine.getOptions()));
+        Set<Option> uniqueOptions = new 
HashSet<>(Arrays.asList(commandLine.getOptions()));
         return uniqueOptions.stream()
                 .map(option -> new StartupCommand.Builder(option.getLongOpt())
                     
.properties(populateMapFromProperties(commandLine.getOptionProperties(option.getLongOpt())))

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupControlPanel.java
 Sun Dec 17 19:14:33 2017
@@ -63,7 +63,7 @@ final class StartupControlPanel {
             List<StartupCommand> ofbizCommands) throws StartupException {
 
         //TODO loaders should be converted to a single loader
-        List<StartupLoader> loaders = new ArrayList<StartupLoader>();
+        List<StartupLoader> loaders = new ArrayList<>();
         Thread adminServer = createAdminServer(config, serverState, loaders);
 
         createLogDirectoryIfMissing(config);
@@ -110,9 +110,9 @@ final class StartupControlPanel {
      * - Printing the stack trace for users to see what happened
      * - Executing the shutdown hooks (if existing) through System.exit
      * - Terminating any lingering threads (if existing) through System.exit
-     * - Providing an exit code that is not 0 to signal to the build system 
+     * - Providing an exit code that is not 0 to signal to the build system
      *   or user of failure to execute.
-     * 
+     *
      * @param e The startup exception that cannot / should not be handled
      *   except by terminating the system
      */
@@ -200,7 +200,7 @@ final class StartupControlPanel {
         }
     }
 
-    private static void loadStartupLoaders(Config config, 
+    private static void loadStartupLoaders(Config config,
             List<StartupLoader> loaders,
             List<StartupCommand> ofbizCommands,
             AtomicReference<ServerState> serverState) throws StartupException {
@@ -221,7 +221,7 @@ final class StartupControlPanel {
                 throw new StartupException(e);
             }
         }
-        serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING); 
+        serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
     }
 
     private static void executeShutdownAfterLoadIfConfigured(

Modified: 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupException.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupException.java?rev=1818509&r1=1818508&r2=1818509&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupException.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupException.java
 Sun Dec 17 19:14:33 2017
@@ -21,8 +21,8 @@ package org.apache.ofbiz.base.start;
 /**
  * StartupException is an exception that is thrown when something wrong happens
  * during executing any OFBiz high level commands.
- * 
- * If StartupException is not handled then it will bubble up to main 
+ *
+ * If StartupException is not handled then it will bubble up to main
  * and lead to system termination.
  */
 @SuppressWarnings("serial")
@@ -65,9 +65,8 @@ public final class StartupException exte
     public String getMessage() {
         if (getCause() != null) {
             return super.getMessage() + " (" + getCause().getMessage() + ")";
-        } else {
-            return super.getMessage();
         }
+        return super.getMessage();
     }
 
     /** Returns the detail message, NOT including the message from the nested 
exception. */


Reply via email to