Examples of ExtendedUriInfo


Examples of com.sun.jersey.api.core.ExtendedUriInfo

                }
            }

            @Override
            public Object matchResource(URI u) throws ContainerException {
                ExtendedUriInfo ui = matchUriInfo(u);
                return (ui != null) ? ui.getMatchedResources().get(0) : null;
            }

            @Override
            public <T> T matchResource(URI u, Class<T> c) throws ContainerException, ClassCastException {
                return c.cast(matchResource(u));
            }

            @Override
            public <T> T getResource(Class<T> c) {
                return c.cast(getResourceComponentProvider(c).getInstance(context));
            }
        };

        final ProviderServices providerServices = new ProviderServices(
                ServerSide.class,
                this.cpFactory,
                resourceConfig.getProviderClasses(),
                resourceConfig.getProviderSingletons());

        injectableFactory.add(new ContextInjectableProvider<ProviderServices>(
                ProviderServices.class, providerServices));

        injectableFactory.add(new ContextInjectableProvider<ResourceMethodCustomInvokerDispatchFactory>(
                ResourceMethodCustomInvokerDispatchFactory.class, new ResourceMethodCustomInvokerDispatchFactory(providerServices)));

        // Add injectable provider for @ParentRef
        injectableFactory.add(
                new InjectableProvider<ParentRef, Type>() {
                    @Override
                    public ComponentScope getScope() {
                        return ComponentScope.PerRequest;
                    }

                    @Override
                    public Injectable<Object> getInjectable(ComponentContext cc, ParentRef a, Type t) {
                        if (!(t instanceof Class))
                            return null;

                        final Class target = ReflectionHelper.getDeclaringClass(cc.getAccesibleObject());
                        final Class inject = (Class)t;
                        return new Injectable<Object>() {
                            @Override
                            public Object getValue() {
                                final UriInfo ui = context.getUriInfo();
                                final List l = ui.getMatchedResources();

                                final Object parent = getParent(l, target);
                                if (parent == null) return null;
                                try {
                                    return inject.cast(parent);
View Full Code Here

Examples of com.sun.jersey.api.core.ExtendedUriInfo

                }
            }

            @Override
            public Object matchResource(URI u) throws ContainerException {
                ExtendedUriInfo ui = matchUriInfo(u);
                return (ui != null) ? ui.getMatchedResources().get(0) : null;
            }

            @Override
            public <T> T matchResource(URI u, Class<T> c) throws ContainerException, ClassCastException {
                return c.cast(matchResource(u));
            }

            @Override
            public <T> T getResource(Class<T> c) {
                return c.cast(getResourceComponentProvider(c).getInstance(context));
            }
        };

        final ProviderServices providerServices = new ProviderServices(
                ServerSide.class,
                this.cpFactory,
                resourceConfig.getProviderClasses(),
                resourceConfig.getProviderSingletons());

        injectableFactory.add(new ContextInjectableProvider<ProviderServices>(
                ProviderServices.class, providerServices));

        injectableFactory.add(new ContextInjectableProvider<ResourceMethodCustomInvokerDispatchFactory>(
                ResourceMethodCustomInvokerDispatchFactory.class, new ResourceMethodCustomInvokerDispatchFactory(providerServices)));

        // Add injectable provider for @ParentRef
        injectableFactory.add(
                new InjectableProvider<ParentRef, Type>() {
                    @Override
                    public ComponentScope getScope() {
                        return ComponentScope.PerRequest;
                    }

                    @Override
                    public Injectable<Object> getInjectable(ComponentContext cc, ParentRef a, Type t) {
                        if (!(t instanceof Class))
                            return null;

                        final Class target = ReflectionHelper.getDeclaringClass(cc.getAccesibleObject());
                        final Class inject = (Class)t;
                        return new Injectable<Object>() {
                            @Override
                            public Object getValue() {
                                final UriInfo ui = context.getUriInfo();
                                final List l = ui.getMatchedResources();

                                final Object parent = getParent(l, target);
                                if (parent == null) return null;
                                try {
                                    return inject.cast(parent);
View Full Code Here

Examples of com.sun.jersey.api.core.ExtendedUriInfo

                }
            }

            @Override
            public Object matchResource(URI u) throws ContainerException {
                ExtendedUriInfo ui = matchUriInfo(u);
                return (ui != null) ? ui.getMatchedResources().get(0) : null;
            }

            @Override
            public <T> T matchResource(URI u, Class<T> c) throws ContainerException, ClassCastException {
                return c.cast(matchResource(u));
            }

            @Override
            public <T> T getResource(Class<T> c) {
                return c.cast(getResourceComponentProvider(c).getInstance(context));
            }
        };

        final ProviderServices providerServices = new ProviderServices(
                ServerSide.class,
                this.cpFactory,
                resourceConfig.getProviderClasses(),
                resourceConfig.getProviderSingletons());

        injectableFactory.add(new ContextInjectableProvider<ProviderServices>(
                ProviderServices.class, providerServices));

        injectableFactory.add(new ContextInjectableProvider<ResourceMethodCustomInvokerDispatchFactory>(
                ResourceMethodCustomInvokerDispatchFactory.class, new ResourceMethodCustomInvokerDispatchFactory(providerServices)));

        // Add injectable provider for @ParentRef
        injectableFactory.add(
                new InjectableProvider<ParentRef, Type>() {
                    @Override
                    public ComponentScope getScope() {
                        return ComponentScope.PerRequest;
                    }

                    @Override
                    public Injectable<Object> getInjectable(ComponentContext cc, ParentRef a, Type t) {
                        if (!(t instanceof Class))
                            return null;

                        final Class target = ReflectionHelper.getDeclaringClass(cc.getAccesibleObject());
                        final Class inject = (Class)t;
                        return new Injectable<Object>() {
                            @Override
                            public Object getValue() {
                                final UriInfo ui = context.getUriInfo();
                                final List l = ui.getMatchedResources();

                                final Object parent = getParent(l, target);
                                if (parent == null) return null;
                                try {
                                    return inject.cast(parent);
View Full Code Here

Examples of com.sun.jersey.api.core.ExtendedUriInfo

                    throw new ContainerException(ex);
                }
            }

            public Object matchResource(URI u) throws ContainerException {
                ExtendedUriInfo ui = matchUriInfo(u);
                return (ui != null) ? ui.getMatchedResources().get(0) : null;
            }

            public <T> T matchResource(URI u, Class<T> c) throws ContainerException, ClassCastException {
                return c.cast(matchResource(u));
            }
View Full Code Here

Examples of com.sun.jersey.api.core.ExtendedUriInfo

   * query parameter and for POST requests it's a form parameter.
   * @see HttpMethodFilter
   */
  /* package */ static String getClientId(ContainerRequest request, HttpContext httpContext) {
    List<String> clientIds = null;
    ExtendedUriInfo uriInfo = httpContext.getUriInfo();
    // try to get the client ID from the query params (for a GET request)
    MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
    clientIds = queryParameters.get(LongPollingServlet.CLIENT_ID);
    if (clientIds == null || clientIds.size() != 1) {
      // try to get the client ID from the form params (in case it's a POST request disguised as a GET)
      clientIds = httpContext.getRequest().getFormParameters().get(LongPollingServlet.CLIENT_ID, String.class);
    }
View Full Code Here

Examples of org.glassfish.jersey.server.ExtendedUriInfo

            this.resourceInstance = resourceInstance;
        }

        @Override
        public Response apply(ContainerRequestContext requestContext) {
            final ExtendedUriInfo extendedUriInfo = extendedUriInfoProvider.get();

            final List<String> templateNames = getTemplateNames(requestContext);

            final Object model = getModel(extendedUriInfo);
            final Class<?> resolvingClass = Object.class.equals(this.resolvingClass) || this.resolvingClass == null
View Full Code Here

Examples of org.glassfish.jersey.server.ExtendedUriInfo

            if (this.templateName != null && !"".equals(this.templateName)) {
                templateNames.add(this.templateName);
            }

            // Sub-resource path.
            final ExtendedUriInfo uriInfo = extendedUriInfoProvider.get();
            final List<RuntimeResource> matchedRuntimeResources = uriInfo.getMatchedRuntimeResources();
            if (matchedRuntimeResources.size() > 1) {
                // > 1 to check that we matched sub-resource
                final RuntimeResource lastMatchedRuntimeResource = matchedRuntimeResources.get(0);
                final Resource lastMatchedResource = lastMatchedRuntimeResource.getResources().get(0);
View Full Code Here

Examples of org.glassfish.jersey.server.ExtendedUriInfo

            if (this.templateName != null && !"".equals(this.templateName)) {
                templateNames.add(this.templateName);
            }

            // Sub-resource path.
            final ExtendedUriInfo uriInfo = extendedUriInfoProvider.get();
            final List<RuntimeResource> matchedRuntimeResources = uriInfo.getMatchedRuntimeResources();
            if (matchedRuntimeResources.size() > 1) {
                // > 1 to check that we matched sub-resource
                final RuntimeResource lastMatchedRuntimeResource = matchedRuntimeResources.get(0);
                final Resource lastMatchedResource = lastMatchedRuntimeResource.getResources().get(0);
View Full Code Here

Examples of org.glassfish.jersey.server.ExtendedUriInfo

     * Get an {@link ErrorTemplate} annotation from resource method / class the throwable was raised from.
     *
     * @return an error template annotation or {@code null} if the method is not annotated.
     */
    private ErrorTemplate getErrorTemplate() {
        final ExtendedUriInfo uriInfo = uriInfoProvider.get();
        final ResourceMethod matchedResourceMethod = uriInfo.getMatchedResourceMethod();

        if (matchedResourceMethod != null) {
            final Invocable invocable = matchedResourceMethod.getInvocable();

            ErrorTemplate errorTemplate = invocable.getHandlingMethod().getAnnotation(ErrorTemplate.class);
View Full Code Here

Examples of org.glassfish.jersey.server.ExtendedUriInfo

        @Override
        public WebTarget provide() {
            // no need for try-catch - unlike for @*Param annotations, any issues with @Uri would usually be caused
            // by incorrect server code, so the default runtime exception mapping to 500 is appropriate
            final ExtendedUriInfo uriInfo = getContainerRequest().getUriInfo();

            final Map<String, Object> pathParamValues = Maps.transformValues(uriInfo.getPathParameters(),
                    new Function<List<String>, Object>() {

                @Override
                public Object apply(List<String> input) {
                    return input.isEmpty() ? null : input.get(0);
                }
            });
            JerseyUriBuilder uriBuilder = new JerseyUriBuilder().uri(this.uri).resolveTemplates(pathParamValues);

            final ManagedClient managedClient = client.get();

            if (!uriBuilder.isAbsolute()) {
                final String customBaseUri = managedClient.customBaseUri;
                final String rootUri = customBaseUri.isEmpty() ? uriInfo.getBaseUri().toString() : customBaseUri;

                uriBuilder = new JerseyUriBuilder().uri(rootUri).path(uriBuilder.toTemplate());
            }

            return managedClient.instance.target(uriBuilder);
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.