
net.sf.jstuff.integration.serviceregistry.ServiceRegistry Maven / Gradle / Ivy
/*
* Copyright 2010-2022 by Sebastian Thomschke and contributors.
* SPDX-License-Identifier: EPL-2.0
*/
package net.sf.jstuff.integration.serviceregistry;
import java.util.Collection;
import org.eclipse.jdt.annotation.NonNull;
/**
* @author Sebastian Thomschke
*/
public interface ServiceRegistry {
/**
* This method is intended for troubleshooting/debugging purposes only
*
*
* @return a snapshot list of all service end points with registered services.
*/
Collection getActiveServiceEndpoints();
<@NonNull SERVICE_INTERFACE> ServiceProxy getService(String serviceEndpointId,
Class serviceInterface);
/**
* Adds the given service using the fully qualified class name of the serviceInterface as service endpoint id.
*
* @return true
if the serviceInstance was added, false
if the serviceInstance was added already
*
* @throws IllegalStateException if another service was already registered for the given service Id
*/
<@NonNull SERVICE_INTERFACE> boolean addService(Class serviceInterface, SERVICE_INTERFACE serviceInstance)
throws IllegalArgumentException, IllegalStateException;
/**
* @return true
if the serviceInstance was added, false
if the serviceInstance was added already
*
* @throws IllegalArgumentException if serviceEndpointId == null or serviceInstance == null
* @throws IllegalStateException if another service was already registered for the given service Id
*/
<@NonNull SERVICE_INTERFACE> boolean addService(String serviceEndpointId, Class serviceInterface,
SERVICE_INTERFACE serviceInstance) throws IllegalArgumentException, IllegalStateException;
/**
* @return true
if the serviceInstance was removed successfully, false
if the given serviceInstance was not registered
*
* @throws IllegalArgumentException if serviceEndpointId == null or serviceInstance == null
*/
boolean removeService(String serviceEndpointId, Object serviceInstance) throws IllegalArgumentException;
}