From e77a91ea3842e46e93e03ce89fb6b4b0d90c2999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Mon, 30 Apr 2012 11:43:29 +0200 Subject: Add removeService() to SimpleProtobufServer. --- src/main/java/com/orbekk/protobuf/ServiceHolder.java | 11 ++++++++++- src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/com/orbekk/protobuf/ServiceHolder.java b/src/main/java/com/orbekk/protobuf/ServiceHolder.java index cab9a5e..e43c7a9 100644 --- a/src/main/java/com/orbekk/protobuf/ServiceHolder.java +++ b/src/main/java/com/orbekk/protobuf/ServiceHolder.java @@ -14,7 +14,7 @@ public class ServiceHolder { public ServiceHolder() { } - public void registerService (Service service) { + public void registerService(Service service) { String serviceName = service.getDescriptorForType().getFullName(); Service previousService = services.put(serviceName, service); if (previousService != null) { @@ -23,6 +23,15 @@ public class ServiceHolder { } } + public void removeService(Service service) { + String serviceName = service.getDescriptorForType().getFullName(); + removeService(serviceName); + } + + public void removeService(String serviceName) { + services.remove(serviceName); + } + public Service get(String fullServiceName) { return services.get(fullServiceName); } diff --git a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java index 14887d8..6ea427d 100644 --- a/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java +++ b/src/main/java/com/orbekk/protobuf/SimpleProtobufServer.java @@ -82,6 +82,14 @@ public class SimpleProtobufServer extends Thread { public void registerService(Service service) { services.registerService(service); } + + public void removeService(Service service) { + services.removeService(service); + } + + public void removeService(String fullServiceName) { + services.removeService(fullServiceName); + } private synchronized void handleConnection(Socket connection) { if (serverSocket.isClosed()) { -- cgit v1.2.3