containerResponseFilterRegistry.registerClass(provider, priority);
newContracts.put(ContainerResponseFilter.class, priority);
}
if (isA(provider, ReaderInterceptor.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, ReaderInterceptor.class, provider);
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerClass(provider, priority);
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerClass(provider, priority);
}
if (constrainedTo == null)
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerClass(provider, priority);
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerClass(provider, priority);
}
newContracts.put(ReaderInterceptor.class, priority);
}
if (isA(provider, WriterInterceptor.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, WriterInterceptor.class, provider);
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerClass(provider, priority);
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerClass(provider, priority);
}
if (constrainedTo == null)
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerClass(provider, priority);
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerClass(provider, priority);
}
newContracts.put(WriterInterceptor.class, priority);
}
if (isA(provider, MessageBodyWriterInterceptor.class, contracts))
{
if (provider.isAnnotationPresent(ServerInterceptor.class))
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerLegacy(provider);
}
if (provider.isAnnotationPresent(ClientInterceptor.class))
{
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerLegacy(provider);
}
if (!provider.isAnnotationPresent(ServerInterceptor.class) && !provider.isAnnotationPresent(ClientInterceptor.class))
{
throw new RuntimeException("Interceptor class must be annotated with @ServerInterceptor and/or @ClientInterceptor");
}
newContracts.put(MessageBodyWriterInterceptor.class, 0);
}
if (isA(provider, MessageBodyReaderInterceptor.class, contracts))
{
if (provider.isAnnotationPresent(ServerInterceptor.class))
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerLegacy(provider);
}
if (provider.isAnnotationPresent(ClientInterceptor.class))
{
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerLegacy(provider);
}
if (!provider.isAnnotationPresent(ServerInterceptor.class) && !provider.isAnnotationPresent(ClientInterceptor.class))
{
throw new RuntimeException("Interceptor class must be annotated with @ServerInterceptor and/or @ClientInterceptor");
}
newContracts.put(MessageBodyReaderInterceptor.class, 0);
}
if (isA(provider, ContextResolver.class, contracts))
{
try
{
addContextResolver(provider, true);
int priority = getPriority(priorityOverride, contracts, ContextResolver.class, provider);
newContracts.put(ContextResolver.class, priority);
}
catch (Exception e)
{
throw new RuntimeException("Unable to instantiate ContextResolver", e);
}
}
if (isA(provider, StringConverter.class, contracts))
{
addStringConverter(provider);
int priority = getPriority(priorityOverride, contracts, StringConverter.class, provider);
newContracts.put(StringConverter.class, priority);
}
if (isA(provider, StringParameterUnmarshaller.class, contracts))
{
addStringParameterUnmarshaller(provider);
int priority = getPriority(priorityOverride, contracts, StringParameterUnmarshaller.class, provider);
newContracts.put(StringParameterUnmarshaller.class, priority);
}
if (isA(provider, InjectorFactory.class, contracts))
{
try
{
this.injectorFactory = (InjectorFactory) provider.newInstance();
newContracts.put(InjectorFactory.class, 0);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
if (isA(provider, DynamicFeature.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, DynamicFeature.class, provider);
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverDynamicFeatures == null)
{
serverDynamicFeatures = new CopyOnWriteArraySet<DynamicFeature>(parent.getServerDynamicFeatures());
}
serverDynamicFeatures.add((DynamicFeature) injectedInstance(provider));
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientDynamicFeatures == null)
{
clientDynamicFeatures = new CopyOnWriteArraySet<DynamicFeature>(parent.getServerDynamicFeatures());
}