예제 #1
0
 @Override
 public void remove(Endpoint endpoint) {
   lock.writeLock().lock();
   try {
     endpointsById.remove(endpoint.id());
     endpointsByPath.remove(endpoint.path());
     endpointsByResourceName.remove(endpoint.resourceId());
   } finally {
     lock.writeLock().unlock();
   }
 }
예제 #2
0
 @Override
 public void add(Endpoint endpoint) {
   lock.writeLock().lock();
   try {
     if (endpointsById.containsKey(endpoint.id())) {
       throw new IllegalArgumentException(
           "An endpoint with id '" + endpoint.id() + "' already exists");
     }
     if (endpointsByPath.containsKey(endpoint.path())) {
       throw new IllegalArgumentException(
           "An endpoint with path '" + endpoint.path() + "' already exists");
     }
     if (endpointsByResourceName.containsKey(endpoint.resourceId())) {
       throw new IllegalArgumentException(
           "An endpoint with resource name '" + endpoint.resourceId() + "' already exists");
     }
     endpointsById.put(endpoint.id(), endpoint);
     endpointsByPath.put(endpoint.path(), endpoint.id());
     endpointsByResourceName.put(endpoint.resourceId(), endpoint.id());
   } finally {
     lock.writeLock().unlock();
   }
 }