@Provider public class GenericDiscoveryContext<T> extends Object implements DiscoveryContext<T>, javax.ws.rs.ext.ContextResolver<DiscoveryContext<T>>
DiscoveryContext
that uses any generic type as the payloadConstructor and Description |
---|
GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery,
ProviderStrategy<T> providerStrategy,
int instanceRefreshMs,
Class<T> payloadType) |
GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery,
ProviderStrategy<T> providerStrategy,
int instanceRefreshMs,
com.google.common.reflect.TypeToken<T> payloadType) |
Modifier and Type | Method and Description |
---|---|
DiscoveryContext<T> |
getContext(Class<?> type) |
int |
getInstanceRefreshMs()
Return the threshold in milliseconds to consider a registration stale
|
ProviderStrategy<T> |
getProviderStrategy()
Return the provider strategy to use for
DiscoveryResource.getAny(String) |
ServiceDiscovery<T> |
getServiceDiscovery()
Return the service singleton
|
void |
marshallJson(com.fasterxml.jackson.databind.node.ObjectNode node,
String fieldName,
T payload)
Serialize your payload
|
T |
unMarshallJson(com.fasterxml.jackson.databind.JsonNode node)
Deserialize your payload
|
public GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, Class<T> payloadType)
public GenericDiscoveryContext(ServiceDiscovery<T> serviceDiscovery, ProviderStrategy<T> providerStrategy, int instanceRefreshMs, com.google.common.reflect.TypeToken<T> payloadType)
public ProviderStrategy<T> getProviderStrategy()
DiscoveryContext
DiscoveryResource.getAny(String)
getProviderStrategy
in interface DiscoveryContext<T>
public int getInstanceRefreshMs()
DiscoveryContext
getInstanceRefreshMs
in interface DiscoveryContext<T>
public ServiceDiscovery<T> getServiceDiscovery()
DiscoveryContext
getServiceDiscovery
in interface DiscoveryContext<T>
public void marshallJson(com.fasterxml.jackson.databind.node.ObjectNode node, String fieldName, T payload) throws Exception
DiscoveryContext
marshallJson
in interface DiscoveryContext<T>
node
- the node to serialize intofieldName
- field name to usepayload
- the payload value (can be null)Exception
- any errorspublic T unMarshallJson(com.fasterxml.jackson.databind.JsonNode node) throws Exception
DiscoveryContext
unMarshallJson
in interface DiscoveryContext<T>
node
- the node that has the payloadException
- any errorspublic DiscoveryContext<T> getContext(Class<?> type)
getContext
in interface javax.ws.rs.ext.ContextResolver<DiscoveryContext<T>>
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.