diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java index e1e7899a6a372a327e3eb5ce8e1c40d2d51776be..86f113d02f75ca8502b851e097a9df55d844d416 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Config.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -1288,64 +1289,103 @@ public class Config { return (LinkedBlockingQueue) initialContext().lookup(RESOURCE_NODE_EVENTQUEUE); } - public static synchronized JsonElement resource_node_applications() throws Exception { - Object o = initialContext().lookup(RESOURCE_NODE_APPLICATIONS); - if (null != o) { - return (JsonElement) o; - } - return null; + @SuppressWarnings("unchecked") + public static JsonElement resource_node_applications() throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + return (JsonElement) map.get(RESOURCE_NODE_APPLICATIONS); +// Object o = initialContext().lookup(RESOURCE_NODE_APPLICATIONS); +// if (null != o) { +// return (JsonElement) o; +// } +// return null; } - public static synchronized void resource_node_applications(JsonElement jsonElement) throws Exception { - initialContext().rebind(RESOURCE_NODE_APPLICATIONS, jsonElement); + @SuppressWarnings("unchecked") + public static void resource_node_applications(JsonElement jsonElement) throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + map.put(RESOURCE_NODE_APPLICATIONS, jsonElement); + // initialContext().rebind(RESOURCE_NODE_APPLICATIONS, jsonElement); } - public static synchronized Date resource_node_applicationsTimestamp() throws Exception { - Object o = initialContext().lookup(RESOURCE_NODE_APPLICATIONSTIMESTAMP); - if (null != o) { - return (Date) o; - } - return null; + @SuppressWarnings("unchecked") + public static Date resource_node_applicationsTimestamp() throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + return (Date) map.get(RESOURCE_NODE_APPLICATIONSTIMESTAMP); + // Object o = initialContext().lookup(RESOURCE_NODE_APPLICATIONSTIMESTAMP); +// if (null != o) { +// return (Date) o; +// } +// return null; } - public static synchronized void resource_node_applicationsTimestamp(Date date) throws Exception { - initialContext().rebind(RESOURCE_NODE_APPLICATIONSTIMESTAMP, date); + @SuppressWarnings("unchecked") + public static void resource_node_applicationsTimestamp(Date date) throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + map.put(RESOURCE_NODE_APPLICATIONSTIMESTAMP, date); + // initialContext().rebind(RESOURCE_NODE_APPLICATIONSTIMESTAMP, date); } - public static synchronized String resource_node_centersPirmaryNode() throws Exception { - Object o = initialContext().lookup(RESOURCE_NODE_CENTERSPRIMARYNODE); - if (null != o) { - return (String) o; - } - return null; + @SuppressWarnings("unchecked") + public static String resource_node_centersPirmaryNode() throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + return (String) map.get(RESOURCE_NODE_CENTERSPRIMARYNODE); +// Object o = initialContext().lookup()RESOURCE_NODE_CENTERSPRIMARYNODE; +// if (null != o) { +// return (String) o; +// } +// return null; } - public static synchronized void resource_node_centersPirmaryNode(String node) throws Exception { - initialContext().rebind(RESOURCE_NODE_CENTERSPRIMARYNODE, node); + @SuppressWarnings("unchecked") + public static void resource_node_centersPirmaryNode(String node) throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + map.put(RESOURCE_NODE_CENTERSPRIMARYNODE, node); } - public static synchronized Integer resource_node_centersPirmaryPort() throws Exception { - Object o = initialContext().lookup(RESOURCE_NODE_CENTERSPRIMARYPORT); - if (null != o) { - return (Integer) o; - } - return null; + @SuppressWarnings("unchecked") + public static Integer resource_node_centersPirmaryPort() throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + return (Integer) map.get(RESOURCE_NODE_CENTERSPRIMARYPORT); + // Object o = initialContext().lookup(RESOURCE_NODE_CENTERSPRIMARYPORT); +// if (null != o) { +// return (Integer) o; +// } +// return null; } - public static synchronized void resource_node_centersPirmaryPort(Integer port) throws Exception { - initialContext().rebind(RESOURCE_NODE_CENTERSPRIMARYPORT, port); + @SuppressWarnings("unchecked") + public static void resource_node_centersPirmaryPort(Integer port) throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + map.put(RESOURCE_NODE_CENTERSPRIMARYPORT, port); + // initialContext().rebind(RESOURCE_NODE_CENTERSPRIMARYPORT, port); } - public static synchronized Boolean resource_node_centersPirmarySslEnable() throws Exception { - Object o = initialContext().lookup(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE); - if (null != o) { - return (Boolean) o; - } - return null; + @SuppressWarnings("unchecked") + public static Boolean resource_node_centersPirmarySslEnable() throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + return (Boolean) map.get(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE); + // Object o = initialContext().lookup(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE); +// if (null != o) { +// return (Boolean) o; +// } +// return null; } - public static synchronized void resource_node_centersPirmarySslEnable(Boolean sslEnable) throws Exception { - initialContext().rebind(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE, sslEnable); + @SuppressWarnings("unchecked") + public static void resource_node_centersPirmarySslEnable(Boolean sslEnable) throws Exception { + ConcurrentHashMap map = (ConcurrentHashMap) initialContext() + .lookup(RESOURCE_NODE_APPLICATIONS); + map.put(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE, sslEnable); + // initialContext().rebind(RESOURCE_NODE_CENTERSPRIMARYSSLENABLE, sslEnable); } public static synchronized ExecutorService[] resource_node_processPlatformExecutors() throws Exception { diff --git a/o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java b/o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java index 31a3b5c384224d19d1cd4297778029be654f5f3d..0e1dba9b62ce9a4512f4a79d94c9088a321b140b 100644 --- a/o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java +++ b/o2server/x_console/src/main/java/com/x/server/console/ResourceFactory.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; @@ -96,12 +97,15 @@ public class ResourceFactory { eventQueueExecutor.start(); new Resource(Config.RESOURCE_NODE_EVENTQUEUE, eventQueue); new Resource(Config.RESOURCE_NODE_EVENTQUEUEEXECUTOR, eventQueueExecutor); - new Resource(Config.RESOURCE_NODE_APPLICATIONS, null); - new Resource(Config.RESOURCE_NODE_APPLICATIONSTIMESTAMP, null); + new Resource(Config.RESOURCE_NODE_APPLICATIONS, new ConcurrentHashMap()); + // new Resource(Config.RESOURCE_NODE_APPLICATIONSTIMESTAMP, null); Entry entry = Config.nodes().centerServers().first(); - new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYNODE, entry.getKey()); - new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYPORT, entry.getValue().getPort()); - new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYSSLENABLE, entry.getValue().getSslEnable()); + Config.resource_node_centersPirmaryNode(entry.getKey()); + Config.resource_node_centersPirmaryPort(entry.getValue().getPort()); + Config.resource_node_centersPirmarySslEnable(entry.getValue().getSslEnable()); +// new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYNODE, entry.getKey()); +// new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYPORT, entry.getValue().getPort()); +// new Resource(Config.RESOURCE_NODE_CENTERSPRIMARYSSLENABLE, entry.getValue().getSslEnable()); } private static void containerEntityNames(ClassLoader classLoader, ScanResult sr) throws Exception {