Class GenericDiscoveryContext<T>
java.lang.Object
org.apache.curator.x.discovery.server.contexts.GenericDiscoveryContext<T>
- All Implemented Interfaces:
javax.ws.rs.ext.ContextResolver<DiscoveryContext<T>>
,DiscoveryContext<T>
- Direct Known Subclasses:
MapDiscoveryContext
@Provider
public class GenericDiscoveryContext<T>
extends Object
implements DiscoveryContext<T>, javax.ws.rs.ext.ContextResolver<DiscoveryContext<T>>
For convenience, a version of
DiscoveryContext
that uses any generic type as the payload-
Constructor Summary
ConstructorDescriptionGenericDiscoveryContext
(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, com.google.common.reflect.TypeToken<T> payloadType) GenericDiscoveryContext
(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, Class<T> payloadType) -
Method Summary
Modifier and TypeMethodDescriptiongetContext
(Class<?> type) int
Return the threshold in milliseconds to consider a registration staleReturn the provider strategy to use forDiscoveryResource.getAny(String)
Return the service singletonvoid
marshallJson
(com.fasterxml.jackson.databind.node.ObjectNode node, String fieldName, T payload) Serialize your payloadunMarshallJson
(com.fasterxml.jackson.databind.JsonNode node) Deserialize your payload
-
Constructor Details
-
GenericDiscoveryContext
public GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, Class<T> payloadType) -
GenericDiscoveryContext
public GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, com.google.common.reflect.TypeToken<T> payloadType)
-
-
Method Details
-
getProviderStrategy
Description copied from interface:DiscoveryContext
Return the provider strategy to use forDiscoveryResource.getAny(String)
- Specified by:
getProviderStrategy
in interfaceDiscoveryContext<T>
- Returns:
- strategy
-
getInstanceRefreshMs
public int getInstanceRefreshMs()Description copied from interface:DiscoveryContext
Return the threshold in milliseconds to consider a registration stale- Specified by:
getInstanceRefreshMs
in interfaceDiscoveryContext<T>
- Returns:
- number of milliseconds
-
getServiceDiscovery
Description copied from interface:DiscoveryContext
Return the service singleton- Specified by:
getServiceDiscovery
in interfaceDiscoveryContext<T>
- Returns:
- service
-
marshallJson
public void marshallJson(com.fasterxml.jackson.databind.node.ObjectNode node, String fieldName, T payload) throws Exception Description copied from interface:DiscoveryContext
Serialize your payload- Specified by:
marshallJson
in interfaceDiscoveryContext<T>
- Parameters:
node
- the node to serialize intofieldName
- field name to usepayload
- the payload value (can be null)- Throws:
Exception
- any errors
-
unMarshallJson
Description copied from interface:DiscoveryContext
Deserialize your payload- Specified by:
unMarshallJson
in interfaceDiscoveryContext<T>
- Parameters:
node
- the node that has the payload- Returns:
- the payload or null
- Throws:
Exception
- any errors
-
getContext
- Specified by:
getContext
in interfacejavax.ws.rs.ext.ContextResolver<T>
-