int priority = getPriority(priorityOverride, contracts, ContainerResponseFilter.class, provider.getClass());
newContracts.put(ContainerResponseFilter.class, priority);
}
if (isA(provider, ReaderInterceptor.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getClass().getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, ReaderInterceptor.class, provider.getClass());
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerSingleton((ReaderInterceptor) provider, priority);
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerSingleton((ReaderInterceptor) provider, priority);
}
if (constrainedTo == null)
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerSingleton((ReaderInterceptor) provider, priority);
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerSingleton((ReaderInterceptor) provider, priority);
}
newContracts.put(ReaderInterceptor.class, priority);
}
if (isA(provider, WriterInterceptor.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getClass().getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, WriterInterceptor.class, provider.getClass());
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerSingleton((WriterInterceptor) provider, priority);
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerSingleton((WriterInterceptor) provider, priority);
}
if (constrainedTo == null)
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerSingleton((WriterInterceptor) provider, priority);
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerSingleton((WriterInterceptor) provider, priority);
}
newContracts.put(WriterInterceptor.class, priority);
}
if (isA(provider, MessageBodyWriterInterceptor.class, contracts))
{
if (provider.getClass().isAnnotationPresent(ServerInterceptor.class))
{
if (serverWriterInterceptorRegistry == null)
{
serverWriterInterceptorRegistry = parent.getServerWriterInterceptorRegistry().clone(this);
}
serverWriterInterceptorRegistry.registerLegacy((MessageBodyWriterInterceptor) provider);
}
if (provider.getClass().isAnnotationPresent(ClientInterceptor.class))
{
if (clientWriterInterceptorRegistry == null)
{
clientWriterInterceptorRegistry = parent.getClientWriterInterceptorRegistry().clone(this);
}
clientWriterInterceptorRegistry.registerLegacy((MessageBodyWriterInterceptor) provider);
}
if (!provider.getClass().isAnnotationPresent(ServerInterceptor.class) && !provider.getClass().isAnnotationPresent(ClientInterceptor.class))
{
throw new RuntimeException("Interceptor class " + provider.getClass() + " must be annotated with @ServerInterceptor and/or @ClientInterceptor");
}
newContracts.put(MessageBodyWriterInterceptor.class, 0);
}
if (isA(provider, MessageBodyReaderInterceptor.class, contracts))
{
if (provider.getClass().isAnnotationPresent(ServerInterceptor.class))
{
if (serverReaderInterceptorRegistry == null)
{
serverReaderInterceptorRegistry = parent.getServerReaderInterceptorRegistry().clone(this);
}
serverReaderInterceptorRegistry.registerLegacy((MessageBodyReaderInterceptor) provider);
}
if (provider.getClass().isAnnotationPresent(ClientInterceptor.class))
{
if (clientReaderInterceptorRegistry == null)
{
clientReaderInterceptorRegistry = parent.getClientReaderInterceptorRegistry().clone(this);
}
clientReaderInterceptorRegistry.registerLegacy((MessageBodyReaderInterceptor) provider);
}
if (!provider.getClass().isAnnotationPresent(ServerInterceptor.class) && !provider.getClass().isAnnotationPresent(ClientInterceptor.class))
{
throw new RuntimeException("Interceptor class " + provider.getClass() + " must be annotated with @ServerInterceptor and/or @ClientInterceptor");
}
newContracts.put(MessageBodyReaderInterceptor.class, 0);
}
if (isA(provider, StringConverter.class, contracts))
{
addStringConverter((StringConverter) provider);
newContracts.put(StringConverter.class, 0);
}
if (isA(provider, InjectorFactory.class, contracts))
{
this.injectorFactory = (InjectorFactory) provider;
newContracts.put(InjectorFactory.class, 0);
}
if (isA(provider, DynamicFeature.class, contracts))
{
ConstrainedTo constrainedTo = (ConstrainedTo) provider.getClass().getAnnotation(ConstrainedTo.class);
int priority = getPriority(priorityOverride, contracts, DynamicFeature.class, provider.getClass());
if (constrainedTo != null && constrainedTo.value() == RuntimeType.SERVER)
{
if (serverDynamicFeatures == null)
{
serverDynamicFeatures = new CopyOnWriteArraySet<DynamicFeature>(parent.getServerDynamicFeatures());
}
serverDynamicFeatures.add((DynamicFeature) provider);
}
if (constrainedTo != null && constrainedTo.value() == RuntimeType.CLIENT)
{
if (clientDynamicFeatures == null)
{
clientDynamicFeatures = new CopyOnWriteArraySet<DynamicFeature>(parent.getServerDynamicFeatures());
}