Package javax.ws.rs

Examples of javax.ws.rs.RuntimeType


    }

    private static RuntimeType getContractConstraint(final Class<?> clazz, final RuntimeType defaultConstraint) {
        final ProviderRuntime jaxRsProvider = EXTERNAL_PROVIDER_INTERFACE_WHITELIST.get(clazz);

        RuntimeType result = null;
        if (jaxRsProvider != null) {
            result = jaxRsProvider.getRuntime();
        } else if (clazz.getAnnotation(Contract.class) != null) {
            final ConstrainedTo constrainedToAnnotation = clazz.getAnnotation(ConstrainedTo.class);
            if (constrainedToAnnotation != null) {
View Full Code Here


    @Test
    public void testPropertiesWithMessageContext() throws IOException {
        final int size = 20;
        Map<String, Object> properties = Maps.newHashMap();
        properties.put(CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, size);
        final RuntimeType runtime = RuntimeType.CLIENT;

        checkBufferSize(size, properties, runtime);
    }
View Full Code Here

    @Test
    public void testPropertiesWithMessageContextVeryBigBuffer() throws IOException {
        final int size = 200000;
        Map<String, Object> properties = Maps.newHashMap();
        properties.put(CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, size);
        final RuntimeType runtime = RuntimeType.CLIENT;

        checkBufferSize(size, properties, runtime);
    }
View Full Code Here

    }

    @Test
    public void testPropertiesWithMessageContextDefaultNoProps() throws IOException {
        Map<String, Object> properties = Maps.newHashMap();
        final RuntimeType runtime = RuntimeType.CLIENT;

        checkBufferSize(CommittingOutputStream.DEFAULT_BUFFER_SIZE, properties, runtime);
    }
View Full Code Here

*/
public class MultiPartFeature implements Feature {

    @Override
    public boolean configure(final FeatureContext context) {
        final RuntimeType runtime = context.getConfiguration().getRuntimeType();

        if (RuntimeType.SERVER.equals(runtime)) {
            context.register(FormDataParameterInjectionFeature.class);
            context.register(MultiPartReaderServerSide.class);
        } else {
View Full Code Here

public class MetaInfServicesAutoDiscoverable implements ForcedAutoDiscoverable {

    @Override
    public void configure(final FeatureContext context) {
        final Map<String, Object> properties = context.getConfiguration().getProperties();
        final RuntimeType runtimeType = context.getConfiguration().getRuntimeType();

        context.register(new AbstractBinder() {
            @Override
            protected void configure() {
                // Message Body providers.
View Full Code Here

   protected void addMessageBodyReader(MessageBodyReader provider, Class<?> providerClass, boolean isBuiltin)
   {
      SortedKey<MessageBodyReader> key = new SortedKey<MessageBodyReader>(MessageBodyReader.class, provider, providerClass, isBuiltin);
      injectProperties(providerClass, provider);
      Consumes consumeMime = provider.getClass().getAnnotation(Consumes.class);
      RuntimeType type = null;
      ConstrainedTo constrainedTo = providerClass.getAnnotation(ConstrainedTo.class);
      if (constrainedTo != null) type = constrainedTo.value();

      if (type == null)
      {
View Full Code Here

   protected void addMessageBodyWriter(MessageBodyWriter provider, Class<?> providerClass, boolean isBuiltin)
   {
      injectProperties(providerClass, provider);
      Produces consumeMime = provider.getClass().getAnnotation(Produces.class);
      SortedKey<MessageBodyWriter> key = new SortedKey<MessageBodyWriter>(MessageBodyWriter.class, provider, providerClass, isBuiltin);
      RuntimeType type = null;
      ConstrainedTo constrainedTo = providerClass.getAnnotation(ConstrainedTo.class);
      if (constrainedTo != null) type = constrainedTo.value();
      if (type == null)
      {
         addClientMessageBodyWriter(consumeMime, key);
View Full Code Here

                                               RuntimeType runtimeConstraint,
                                               boolean scanned,
                                               boolean isResource) {
        final Set<Class<?>> contracts = model.getContracts();
        final ConstrainedTo constrainedTo = component.getAnnotation(ConstrainedTo.class);
        final RuntimeType componentConstraint = constrainedTo == null ? null : constrainedTo.value();
        if (Feature.class.isAssignableFrom(component)) {
            // TODO: solve after implementation
            return true;
        }

        final StringBuilder warnings = new StringBuilder();
        try {
            /**
             * Indicates that the provider implements at least one contract compatible
             * with it's implementation class constraint.
             */
            boolean foundComponentCompatible = componentConstraint == null;
            boolean foundRuntimeCompatibleContract = isResource && runtimeConstraint == RuntimeType.SERVER;
            for (Class<?> contract : contracts) {
                // if the contract is common/not constrained, default to provider constraint
                final RuntimeType contractConstraint = getContractConstraint(contract, componentConstraint);
                foundRuntimeCompatibleContract |= contractConstraint == null || contractConstraint == runtimeConstraint;

                if (componentConstraint != null) {
                    if (contractConstraint != componentConstraint) {
                        warnings.append(LocalizationMessages.WARNING_PROVIDER_CONSTRAINED_TO_WRONG_PACKAGE(
                                component.getName(),
                                componentConstraint.name(),
                                contract.getName(),
                                contractConstraint.name()))
                                .append(" ");
                    } else {
                        foundComponentCompatible = true;
                    }
                }
View Full Code Here

    }

    private static RuntimeType getContractConstraint(Class<?> clazz, RuntimeType defaultConstraint) {
        final ProviderRuntime jaxRsProvider = EXTERNAL_PROVIDER_INTERFACE_WHITELIST.get(clazz);

        RuntimeType result = null;
        if (jaxRsProvider != null) {
            result = jaxRsProvider.getRuntime();
        } else if (clazz.getAnnotation(Contract.class) != null) {
            final ConstrainedTo constrainedToAnnotation = clazz.getAnnotation(ConstrainedTo.class);
            if (constrainedToAnnotation != null) {
View Full Code Here

TOP

Related Classes of javax.ws.rs.RuntimeType

Copyright © 2018 www.massapicom. 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.