[lsc-changes] r508 - in lsc/trunk/src/main/java/org/lsc: beans/syncoptions utils

jclarke at lsc-project.org jclarke at lsc-project.org
Mon Nov 30 01:32:59 CET 2009


Author: jclarke
Date: 2009-11-30 01:32:59 +0100 (Mon, 30 Nov 2009)
New Revision: 508

Modified:
   lsc/trunk/src/main/java/org/lsc/beans/syncoptions/SyncOptionsFactory.java
   lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java
Log:
Improve static initializations and some minor optimizations

Modified: lsc/trunk/src/main/java/org/lsc/beans/syncoptions/SyncOptionsFactory.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/syncoptions/SyncOptionsFactory.java	2009-11-30 00:24:27 UTC (rev 507)
+++ lsc/trunk/src/main/java/org/lsc/beans/syncoptions/SyncOptionsFactory.java	2009-11-30 00:32:59 UTC (rev 508)
@@ -55,7 +55,7 @@
 
 public final class SyncOptionsFactory {
 
-    private static SyncOptionsFactory INSTANCE;
+    private static SyncOptionsFactory INSTANCE = new SyncOptionsFactory();
 
     private Map<String, ISyncOptions> cache; 
 
@@ -63,6 +63,7 @@
 
     private SyncOptionsFactory() {
         cache = new HashMap<String, ISyncOptions>();
+        this.loadOptions();
     }
 
     private void loadOptions() {
@@ -88,10 +89,6 @@
     }
 
     public static ISyncOptions getInstance(String syncName) {
-        if(INSTANCE == null) {
-            INSTANCE = new SyncOptionsFactory();
-            INSTANCE.loadOptions();
-        }
         return INSTANCE.get(syncName);
     }
 

Modified: lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java	2009-11-30 00:24:27 UTC (rev 507)
+++ lsc/trunk/src/main/java/org/lsc/utils/JScriptEvaluator.java	2009-11-30 00:32:59 UTC (rev 508)
@@ -72,7 +72,7 @@
 	private static final Logger LOGGER = LoggerFactory.getLogger(JScriptEvaluator.class);
 
 	/** The private unique instance. */
-	private static JScriptEvaluator instance;
+	private static JScriptEvaluator instance = new JScriptEvaluator();
 
 	/** The precompiled Javascript cache. */
 	private Map<String, Script> cache;
@@ -97,9 +97,6 @@
 	 * @return the instance
 	 */
 	public static JScriptEvaluator getInstance() {
-		if (instance == null) {
-			instance = new JScriptEvaluator();
-		}
 		return instance;
 	}
 
@@ -153,8 +150,7 @@
 		} // try next approach
 
 		try {
-			Object resultsArray = Context.jsToJava(result, List.class);
-			return (List<String>) resultsArray;
+			return (List<String>) Context.jsToJava(result, List.class);
 		} catch (Exception e) {
 		} // try next approach
 



More information about the lsc-changes mailing list