Sugar for shutdown hook
MODIFY
runtime/src/jycessing/mode/run/RMIUtils.java
runtime/src/jycessing/mode/run/RMIUtils.java
@@ -19,16 +19,14 @@ public class RMIUtils {
static final int RMI_PORT = 8220;
- private static final RMIClientSocketFactory clientFactory =
- new RMIClientSocketFactory() {
+ private static final RMIClientSocketFactory clientFactory = new RMIClientSocketFactory() {
@Override
public Socket createSocket(final String host, final int port) throws IOException {
return new Socket(host, port);
}
};
- private static final RMIServerSocketFactory serverFactory =
- new RMIServerSocketFactory() {
+ private static final RMIServerSocketFactory serverFactory = new RMIServerSocketFactory() {
@Override
public ServerSocket createServerSocket(final int port) throws IOException {
return new ServerSocket(port, 50, InetAddress.getLoopbackAddress());
@@ -84,25 +82,16 @@ public class RMIUtils {
final String registryKey = remoteInterface.getSimpleName();
try {
export(remote);
- log(
- "Attempting to bind instance of "
- + remote.getClass().getName()
- + " to registry as "
+ log("Attempting to bind instance of " + remote.getClass().getName() + " to registry as "
+ registryKey);
registry().bind(registryKey, remote);
log("Bound.");
- Runtime.getRuntime()
- .addShutdownHook(
- new Thread(
- new Runnable() {
- @Override
- public void run() {
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
log("Unbinding " + registryKey + " from registry.");
registry().unbind(registryKey);
} catch (final Exception e) {
}
- }
}));
} catch (final Exception e) {
throw new RMIProblem(e);

Sugar for shutdown hook