[jboss-remoting-commits] JBoss Remoting SVN: r6144 - remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3.
jboss-remoting-commits at lists.jboss.org
jboss-remoting-commits at lists.jboss.org
Sat Nov 13 11:24:35 EST 2010
Author: ron.sigal at jboss.com
Date: 2010-11-13 11:24:35 -0500 (Sat, 13 Nov 2010)
New Revision: 6144
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
Log:
JBREM-1256: (1) Added getConfiguredEndpoint(OptionMap optionMap); (2) keeps a map from OptionMap to created EndPoints.
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java 2010-11-13 00:55:53 UTC (rev 6143)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/Remoting.java 2010-11-13 16:24:35 UTC (rev 6144)
@@ -30,6 +30,7 @@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -65,8 +66,8 @@
private static final Logger log = Logger.getLogger("org.jboss.remoting");
- private static Endpoint configuredEndpoint;
private static final Object lock = new Object();
+ private static final Map<OptionMap, Endpoint> configuredEndpoints = new HashMap<OptionMap, Endpoint>();
private static final RemotingPermission CREATE_ENDPOINT_PERM = new RemotingPermission("createEndpoint");
private static final RemotingPermission GET_CONFIGURED_ENDPOINT_PERM = new RemotingPermission("getConfiguredEndpoint");
@@ -92,20 +93,29 @@
};
public static Endpoint getConfiguredEndpoint() throws IOException {
- final SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(GET_CONFIGURED_ENDPOINT_PERM);
- }
- synchronized (lock) {
- final Endpoint endpoint = configuredEndpoint;
- if (endpoint != null) {
- return endpoint;
- }
- return configuredEndpoint = createConfigured();
- }
+ return getConfiguredEndpoint(OptionMap.EMPTY);
}
+
+ public static Endpoint getConfiguredEndpoint(OptionMap optionMap) throws IOException {
+ if (optionMap == null) {
+ throw new NullPointerException("map is null");
+ }
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(GET_CONFIGURED_ENDPOINT_PERM);
+ }
+ synchronized (lock) {
+ final Endpoint endpoint = configuredEndpoints.get(optionMap);
+ if (endpoint != null) {
+ return endpoint;
+ }
+ Endpoint configuredEndpoint = createConfigured(optionMap);
+ configuredEndpoints.put(optionMap, configuredEndpoint);
+ return configuredEndpoint;
+ }
+ }
- private static Endpoint createConfigured() throws IOException {
+ private static Endpoint createConfigured(final OptionMap optionMap) throws IOException {
try {
return AccessController.doPrivileged(new PrivilegedAction<Endpoint>() {
public Endpoint run() {
@@ -132,6 +142,10 @@
} catch (IOException e) {
throw new RuntimeException(e);
}
+ for (Iterator<Option<?>> it = optionMap.iterator(); it.hasNext();) {
+ Option<?> key = it.next();
+ props.put(key.getName(), optionMap.get(key));
+ }
final ThreadPoolExecutor executor = new ThreadPoolExecutor(
Integer.parseInt(props.getProperty("endpoint.threadpool.coresize", "8")),
Integer.parseInt(props.getProperty("endpoint.threadpool.maxsize", "64")),
More information about the jboss-remoting-commits
mailing list