Browse Source

RmiServiceExporter and RmiRegistryFactoryBean synchronize registry lookup/creation

pull/23217/head
Juergen Hoeller 17 years ago
parent
commit
6ca253e3e6
  1. 4
      org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java
  2. 6
      org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java

4
org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiRegistryFactoryBean.java

@ -215,6 +215,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi @@ -215,6 +215,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi
if (logger.isInfoEnabled()) {
logger.info("Looking for RMI registry at port '" + registryPort + "', using custom socket factory");
}
synchronized (LocateRegistry.class) {
try {
// Retrieve existing registry.
Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
@ -229,6 +230,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi @@ -229,6 +230,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi
return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);
}
}
}
else {
return getRegistry(registryPort);
@ -250,6 +252,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi @@ -250,6 +252,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi
if (logger.isInfoEnabled()) {
logger.info("Looking for RMI registry at port '" + registryPort + "'");
}
synchronized (LocateRegistry.class) {
try {
// Retrieve existing registry.
Registry reg = LocateRegistry.getRegistry(registryPort);
@ -264,6 +267,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi @@ -264,6 +267,7 @@ public class RmiRegistryFactoryBean implements FactoryBean<Registry>, Initializi
return LocateRegistry.createRegistry(registryPort);
}
}
}
/**
* Test the given RMI registry, calling some operation on it to

6
org.springframework.context/src/main/java/org/springframework/remoting/rmi/RmiServiceExporter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -352,6 +352,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -352,6 +352,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
if (logger.isInfoEnabled()) {
logger.info("Looking for RMI registry at port '" + registryPort + "', using custom socket factory");
}
synchronized (LocateRegistry.class) {
try {
// Retrieve existing registry.
Registry reg = LocateRegistry.getRegistry(null, registryPort, clientSocketFactory);
@ -365,6 +366,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -365,6 +366,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
return LocateRegistry.createRegistry(registryPort, clientSocketFactory, serverSocketFactory);
}
}
}
else {
return getRegistry(registryPort);
@ -385,6 +387,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -385,6 +387,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
if (logger.isInfoEnabled()) {
logger.info("Looking for RMI registry at port '" + registryPort + "'");
}
synchronized (LocateRegistry.class) {
try {
// Retrieve existing registry.
Registry reg = LocateRegistry.getRegistry(registryPort);
@ -398,6 +401,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing @@ -398,6 +401,7 @@ public class RmiServiceExporter extends RmiBasedExporter implements Initializing
return LocateRegistry.createRegistry(registryPort);
}
}
}
/**
* Test the given RMI registry, calling some operation on it to

Loading…
Cancel
Save