@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 payload| Constructor 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(org.codehaus.jackson.node.ObjectNode node,
String fieldName,
T payload)
Serialize your payload
|
T |
unMarshallJson(org.codehaus.jackson.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()
DiscoveryContextDiscoveryResource.getAny(String)getProviderStrategy in interface DiscoveryContext<T>public int getInstanceRefreshMs()
DiscoveryContextgetInstanceRefreshMs in interface DiscoveryContext<T>public ServiceDiscovery<T> getServiceDiscovery()
DiscoveryContextgetServiceDiscovery in interface DiscoveryContext<T>public void marshallJson(org.codehaus.jackson.node.ObjectNode node,
String fieldName,
T payload)
throws Exception
DiscoveryContextmarshallJson 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(org.codehaus.jackson.JsonNode node) throws Exception
DiscoveryContextunMarshallJson 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–2021 The Apache Software Foundation. All rights reserved.