Examples of ContractProvider


Examples of org.glassfish.jersey.model.ContractProvider

            // OK.
        }

        config.register(ComplexEmptyProvider.class,
                ReaderInterceptor.class, ContainerRequestFilter.class, WriterInterceptor.class);
        final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class);
        final Set<Class<?>> contracts = contractProvider.getContracts();
        assertEquals(2, contracts.size());
        assertTrue(ReaderInterceptor.class + " is not registered.", contracts.contains(ReaderInterceptor.class));
        assertTrue(ContainerRequestFilter.class + " is not registered.", contracts.contains(ContainerRequestFilter.class));
        assertFalse(WriterInterceptor.class + " should not be registered.", contracts.contains(WriterInterceptor.class));
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

        }

        final ComplexEmptyProvider complexEmptyProvider = new ComplexEmptyProvider();
        config.register(complexEmptyProvider,
                ReaderInterceptor.class, ContainerRequestFilter.class, WriterInterceptor.class);
        final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class);
        final Set<Class<?>> contracts = contractProvider.getContracts();
        assertEquals(2, contracts.size());
        assertTrue(ReaderInterceptor.class + " is not registered.", contracts.contains(ReaderInterceptor.class));
        assertTrue(ContainerRequestFilter.class + " is not registered.", contracts.contains(ContainerRequestFilter.class));
        assertFalse(WriterInterceptor.class + " should not be registered.", contracts.contains(WriterInterceptor.class));
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

    @Test
    public void testRegisterClassNullContracts() throws Exception {
        config.register(ComplexEmptyProvider.class, (Class) null);

        final ContractProvider contractProvider =
                config.getComponentBag().getModel(ComplexEmptyProvider.class);
        final Set<Class<?>> contracts = contractProvider.getContracts();

        assertEquals(0, contracts.size());
    }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

    @Test
    @SuppressWarnings("unchecked")
    public void testRegisterInstanceNullContracts() throws Exception {
        config.register(new ComplexEmptyProvider(), (Class) null);

        final ContractProvider contractProvider =
                config.getComponentBag().getModel(ComplexEmptyProvider.class);
        final Set<Class<?>> contracts = contractProvider.getContracts();

        assertEquals(0, contracts.size());
    }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

                            Severity.WARNING);
                    return false;
                }

                // Register contracts
                final ContractProvider model = modelFor(componentClass, defaultPriority, contractMap, modelEnhancer);

                // Apply registration strategy
                if (!registrationStrategy.apply(model)) {
                    return false;
                }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

     */
    public Set<Class<?>> getClasses(final Predicate<ContractProvider> filter) {
        return Sets.filter(classesView, new Predicate<Class<?>>() {
            @Override
            public boolean apply(Class<?> input) {
                final ContractProvider model = getModel(input);
                return filter.apply(model);
            }
        });
    }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

     */
    public Set<Object> getInstances(final Predicate<ContractProvider> filter) {
        return Sets.filter(instancesView, new Predicate<Object>() {
            @Override
            public boolean apply(Object input) {
                final ContractProvider model = getModel(input.getClass());
                return filter.apply(model);
            }
        });
    }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

        return componentBag.getRegistrations().contains(componentClass);
    }

    @Override
    public Map<Class<?>, Integer> getContracts(Class<?> componentClass) {
        final ContractProvider model = componentBag.getModel(componentClass);
        return (model == null) ? Collections.<Class<?>, Integer>emptyMap() : model.getContractMap();
    }
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

        return this;
    }

    private void processFeatureRegistration(Object component, Class<?> componentClass) {
        ContractProvider model = componentBag.getModel(componentClass);
        if (model.getContracts().contains(Feature.class)) {
            @SuppressWarnings("unchecked")
            final FeatureRegistration registration = (component != null) ?
                    new FeatureRegistration((Feature) component) :
                    new FeatureRegistration((Class<? extends Feature>) componentClass);
            newFeatureRegistrations.add(registration);
View Full Code Here

Examples of org.glassfish.jersey.model.ContractProvider

                            false);
                }
            });
        }
        for (Class<?> providerClass : classes) {
            final ContractProvider model = componentBag.getModel(providerClass);
            ProviderBinder.bindProvider(providerClass, model, dynamicConfiguration);
        }

        // Bind pure provider instances except for pure meta-providers and providers with empty contract models (e.g. resources)
        Set<Object> instances = componentBag.getInstances(filter);
        if (constrainedTo != null) {
            instances = Sets.filter(instances, new Predicate<Object>() {
                @Override
                public boolean apply(Object component) {
                    final Class<?> componentClass = component.getClass();
                    return Providers.checkProviderRuntime(
                            componentClass,
                            componentBag.getModel(componentClass),
                            constrainedTo,
                            registeredClasses == null || !registeredClasses.contains(componentClass),
                            false);
                }
            });
        }
        for (Object provider : instances) {
            final ContractProvider model = componentBag.getModel(provider.getClass());
            ProviderBinder.bindProvider(provider, model, dynamicConfiguration);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.