Package com.sun.jersey.api.model

Examples of com.sun.jersey.api.model.AbstractSubResourceMethod


        assertEquals(int.class, locator.getParameters().get(1).getParameterClass());
        assertEquals(int.class, locator.getParameters().get(1).getParameterType());
        assertEquals(Parameter.Source.HEADER, locator.getParameters().get(2).getSource());
        assertEquals("p3", locator.getParameters().get(2).getSourceName());

        AbstractSubResourceMethod putSubResMethod1 = null;
        AbstractSubResourceMethod putSubResMethod2 = null;
        AbstractSubResourceMethod getSubResMethod = null;
        for (AbstractSubResourceMethod m: rootResource.getSubResourceMethods()) {
            if (m.getMethod().getName().equals("putSubResourceMethod"))
                putSubResMethod1 = m;
            else if (m.getMethod().getName().equals("putSubResourceMethod2"))
                putSubResMethod2 = m;
            else if (m.getMethod().getName().equals("getSubResourceMethodWithParams"))
                getSubResMethod = m;
        }
//        @PUT
//        @Path("/subres-method")
//        public String getSubResourceMethod(String entityParam) {
//            return "Hi there, here is a subresource method!";
//        }
        assertEquals("/subres-method", putSubResMethod1.getPath().getValue());
        assertEquals("PUT", putSubResMethod1.getHttpMethod());
        assertEquals(1, putSubResMethod1.getParameters().size());
        assertEquals(Parameter.Source.ENTITY, putSubResMethod1.getParameters().get(0).getSource());
//        @PUT
//        @Path("/subres-method2")
//        public String getSubResourceMethod(@ApplicationAnnotation String entityParam) {
//            return "Hi there, here is a subresource method!";
//        }
        assertEquals("/subres-method2", putSubResMethod2.getPath().getValue());
        assertEquals("PUT", putSubResMethod2.getHttpMethod());
        assertEquals(1, putSubResMethod2.getParameters().size());
        assertEquals(Parameter.Source.ENTITY, putSubResMethod2.getParameters().get(0).getSource());
//        @HttpMethod
//        @Path("/with-params/{one}")
//        @Produces("text/plain")
//        public String getSubResourceMethodWithParams(@PathParam("one") String paramOne) {
//            return "Hi there, here is a subresource method!";
//        }
        assertEquals("/with-params/{one}", getSubResMethod.getPath().getValue());
        assertEquals("GET", getSubResMethod.getHttpMethod());
        assertEquals(1, getSubResMethod.getParameters().size());
        assertEquals(Parameter.Source.PATH, getSubResMethod.getParameters().get(0).getSource());
        assertEquals("one", getSubResMethod.getParameters().get(0).getSourceName());
        assertEquals("text/plain", getSubResMethod.getSupportedOutputTypes().get(0).toString());
    }
View Full Code Here


            final boolean emptySegmentCase =  "/".equals(pv.getValue()) || "".equals(pv.getValue());
           
            if (!emptySegmentCase) {
                final ReflectionHelper.ClassTypePair ct = getGenericReturnType(resource.getResourceClass(), m.getMethod());
                final AbstractSubResourceMethod abstractSubResourceMethod = new AbstractSubResourceMethod(
                        resource,
                        m.getMethod(),
                        ct.c, ct.t,
                        pv,
                        m.getMetaMethodAnnotations(HttpMethod.class).get(0).value(),
                        m.getAnnotations());

                addConsumes(m, abstractSubResourceMethod, classScopeConsumesAnnotation);
                addProduces(m, abstractSubResourceMethod, classScopeProducesAnnotation);
                processParameters(
                        abstractSubResourceMethod.getResource().getResourceClass(),
                        abstractSubResourceMethod.getMethod().getDeclaringClass(),
                        abstractSubResourceMethod, m, isEncoded);

                resource.getSubResourceMethods().add(abstractSubResourceMethod);

            } else { // treat the sub-resource method as a resource method
View Full Code Here

            final boolean emptySegmentCase =  "/".equals(pv.getValue()) || "".equals(pv.getValue());
           
            if (!emptySegmentCase) {
                final ReflectionHelper.ClassTypePair ct = getGenericReturnType(resource.getResourceClass(), m.getMethod());
                final AbstractSubResourceMethod abstractSubResourceMethod = new AbstractSubResourceMethod(
                        resource,
                        m.getMethod(),
                        ct.c, ct.t,
                        pv,
                        m.getMetaMethodAnnotations(HttpMethod.class).get(0).value(),
                        m.getAnnotations());

                addConsumes(m, abstractSubResourceMethod, classScopeConsumesAnnotation);
                addProduces(m, abstractSubResourceMethod, classScopeProducesAnnotation);
                processParameters(
                        abstractSubResourceMethod.getResource().getResourceClass(),
                        abstractSubResourceMethod.getMethod().getDeclaringClass(),
                        abstractSubResourceMethod, m, isEncoded);

                resource.getSubResourceMethods().add(abstractSubResourceMethod);

            } else { // treat the sub-resource method as a resource method
View Full Code Here

            Consumes classScopeConsumesAnnotation,
            Produces classScopeProducesAnnotation) {
        for (AnnotatedMethod m : methodList.hasMetaAnnotation(HttpMethod.class).
                hasAnnotation(Path.class)) {
            final Path mPathAnnotation = m.getAnnotation(Path.class);
            final AbstractSubResourceMethod subResourceMethod = new AbstractSubResourceMethod(
                    resource,
                    m.getMethod(),
                    new PathValue(
                        mPathAnnotation.value()),
                    m.getMetaMethodAnnotations(HttpMethod.class).get(0).value(),
View Full Code Here

            final boolean emptySegmentCase =  "/".equals(pv.getValue()) || "".equals(pv.getValue());
           
            if (!emptySegmentCase) {
                final ReflectionHelper.ClassTypePair ct = getGenericReturnType(resource.getResourceClass(), m.getMethod());
                final AbstractSubResourceMethod abstractSubResourceMethod = new AbstractSubResourceMethod(
                        resource,
                        m.getMethod(),
                        ct.c, ct.t,
                        pv,
                        m.getMetaMethodAnnotations(HttpMethod.class).get(0).value(),
                        m.getAnnotations());

                addConsumes(m, abstractSubResourceMethod, classScopeConsumesAnnotation);
                addProduces(m, abstractSubResourceMethod, classScopeProducesAnnotation);
                processParameters(
                        abstractSubResourceMethod.getResource().getResourceClass(),
                        abstractSubResourceMethod.getMethod().getDeclaringClass(),
                        abstractSubResourceMethod, m, isEncoded);

                resource.getSubResourceMethods().add(abstractSubResourceMethod);

            } else { // treat the sub-resource method as a resource method
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.model.AbstractSubResourceMethod

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.