You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2012/08/19 11:59:32 UTC
svn commit: r1374720 -
/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
Author: adrianc
Date: Sun Aug 19 09:59:31 2012
New Revision: 1374720
URL: http://svn.apache.org/viewvc?rev=1374720&view=rev
Log:
More work on Start.java - added the capability for client code to query the class for server state.
Modified:
ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
Modified: ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java?rev=1374720&r1=1374719&r2=1374720&view=diff
==============================================================================
--- ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java (original)
+++ ofbiz/trunk/framework/start/src/org/ofbiz/base/start/Start.java Sun Aug 19 09:59:31 2012
@@ -35,10 +35,12 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
/**
- * Start - OFBiz Container(s) Startup Class
+ * OFBiz startup class.
*
*/
-public class Start {
+public final class Start {
+
+ private static final Start instance = new Start();
private static Command checkCommand(Command command, Command wanted) {
if (wanted == Command.HELP || wanted.equals(command)) {
@@ -51,6 +53,13 @@ public class Start {
}
}
+ /**
+ * Returns the <code>Start</code> instance.
+ */
+ public static Start getInstance() {
+ return instance;
+ }
+
private static void help(PrintStream out) {
out.println("");
out.println("Usage: java -jar ofbiz.jar [command] [arguments]");
@@ -100,16 +109,15 @@ public class Start {
help(System.err);
System.exit(1);
}
- Start start = new Start();
- start.init(args, command == Command.COMMAND);
+ instance.init(args, command == Command.COMMAND);
try {
if (command == Command.STATUS) {
- System.out.println("Current Status : " + start.status());
+ System.out.println("Current Status : " + instance.status());
} else if (command == Command.SHUTDOWN) {
- System.out.println("Shutting down server : " + start.shutdown());
+ System.out.println("Shutting down server : " + instance.shutdown());
} else {
// general start
- start.start();
+ instance.start();
}
} catch (Exception e) {
e.printStackTrace();
@@ -120,9 +128,9 @@ public class Start {
// ---------------------------------------------- //
private Config config = null;
- private List<String> loaderArgs = new ArrayList<String>();
+ private final List<String> loaderArgs = new ArrayList<String>();
private final ArrayList<StartupLoader> loaders = new ArrayList<StartupLoader>();
- private AtomicReference<ServerState> serverState = new AtomicReference<ServerState>(ServerState.STARTING);
+ private final AtomicReference<ServerState> serverState = new AtomicReference<ServerState>(ServerState.STARTING);
private Thread adminPortThread = null;
private Start() {}
@@ -145,6 +153,13 @@ public class Start {
}
}
+ /**
+ * Returns the server's current state.
+ */
+ public ServerState getCurrentState() {
+ return serverState.get();
+ }
+
private void init(String[] args, boolean fullInit) throws StartupException {
String globalSystemPropsFileName = System.getProperty("ofbiz.system.props");
if (globalSystemPropsFileName != null) {