Package com.sun.jersey.api.model

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


    }

    @Test
    public void testNonConflictingHttpMethodDelete() throws Exception {
        System.out.println("---\nNo issue should be reported if produced mime types differ");
        AbstractResource ar = IntrospectionModeller.createResource(TestNonConflictingHttpMethodDelete.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(validator.getIssueList().isEmpty());
    }
View Full Code Here


    }

    @Test
    public void testAmbiguousParams() throws Exception {
        System.out.println("---\nA warning should be reported if ambiguous source of a parameter is seen");
        AbstractResource ar = IntrospectionModeller.createResource(TestAmbiguousParams.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(!validator.fatalIssuesFound());
        assertEquals(6, validator.getIssueList().size());
View Full Code Here

    }

    @Test
    public void testEmptyPathSegment() throws Exception {
        System.out.println("---\nA warning should be reported if @Path with \"/\" or empty string value is seen");
        AbstractResource ar = IntrospectionModeller.createResource(TestEmptyPathSegment.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(!validator.fatalIssuesFound());
        assertEquals(1, validator.getIssueList().size());
View Full Code Here

    }

    @Test
    public void testTypeVariableResource() throws Exception {
        System.out.println("---\n");
        AbstractResource ar = IntrospectionModeller.createResource(TypeVariableResource.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(!validator.fatalIssuesFound());
        assertEquals(7, validator.getIssueList().size());
View Full Code Here

    }

    @Test
    public void testParameterizedTypeResource() throws Exception {
        System.out.println("---\n");
        AbstractResource ar = IntrospectionModeller.createResource(ConcreteParameterizedTypeResource.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(!validator.fatalIssuesFound());
        assertEquals(0, validator.getIssueList().size());
View Full Code Here

    }

    @Test
    public void testGenericArrayResource() throws Exception {
        System.out.println("---\n");
        AbstractResource ar = IntrospectionModeller.createResource(ConcreteGenericArrayResource.class);
        BasicValidator validator = new BasicValidator();
        validator.validate(ar);
        printIssueList(validator);
        assertTrue(!validator.fatalIssuesFound());
        assertEquals(0, validator.getIssueList().size());
View Full Code Here

        // need to validate possible conflicts in uri templates
        Set<UriTemplate> uriTemplatesUsed = new HashSet<UriTemplate>();

        Set<AbstractResource> rootResources = new HashSet<AbstractResource>();
        for (Object o : singletons) {
            AbstractResource ar = getAbstractResource(o);
            if (!ar.isRootResource()) {
                LOGGER.warning("The singleton, " + o + ", registered as a root resource singleton" +
                        "of the ResourceConfig is not a root resource singleton" +
                        ". This singleton will be ignored");
                continue;
            }

            ComponentInjector ci = new ComponentInjector(injectableFactory, o.getClass());
            ci.inject(o);

            UriTemplate t = new PathTemplate(ar.getPath().getValue());

            ensureTemplateUnused(t, ar, uriTemplatesUsed);

            ResourceClass r = getResourceClass(ar);
            rootResources.add(r.resource);

            PathPattern p = new PathPattern(t);

            rulesMap.put(p, new RightHandPathRule(
                        resourceConfig.getFeature(ResourceConfig.FEATURE_REDIRECT),
                        t.endsWithSlash(),
                        new ResourceObjectRule(t, o)));
        }
       
        for (Class<?> c : classes) {
            AbstractResource ar = getAbstractResource(c);
            if (!ar.isRootResource()) {
                LOGGER.warning("The class, " + c + ", registered as a root resource class " +
                        "of the ResourceConfig is not a root resource class" +
                        ". This class will be ignored");
                continue;
            }
            // TODO this should be moved to the validation
            // as such classes are not root resource classes
            int modifiers = c.getModifiers();
            if (Modifier.isAbstract(modifiers) && !Modifier.isInterface(modifiers)) {
                LOGGER.warning("The " + c + ", registered as a root resource class " +
                        "of the ResourceConfig cannot be instantiated" +
                        ". This class will be ignored");
                continue;
            } else if (Modifier.isInterface(modifiers)) {
                LOGGER.warning("The " + c + ", registered as a root resource class " +
                        "of the ResourceConfig cannot be instantiated" +
                        ". This interface will be ignored");
                continue;
            }

            UriTemplate t = new PathTemplate(ar.getPath().getValue());
            ensureTemplateUnused(t, ar, uriTemplatesUsed);

            ResourceClass r = getResourceClass(ar);
            rootResources.add(r.resource);
View Full Code Here

        final boolean isRootResourceClass = (null != rPathAnnotation);

        final boolean isEncodedAnotOnClass =
                (null != annotatedResourceClass.getAnnotation(Encoded.class));

        AbstractResource resource;

        if (isRootResourceClass) {
            resource = new AbstractResource(resourceClass,
                    new PathValue(rPathAnnotation.value()));
        } else { // just a subresource class
            resource = new AbstractResource(resourceClass);
        }

        workOutConstructorsList(resource, resourceClass.getConstructors(),
                isEncodedAnotOnClass);

        workOutFieldsList(resource, isEncodedAnotOnClass);
       
        final MethodList methodList = new MethodList(resourceClass);

        workOutSetterMethodsList(resource, methodList, isEncodedAnotOnClass);
       
        final Consumes classScopeConsumesAnnotation =
                annotatedResourceClass.getAnnotation(Consumes.class);
        final Produces classScopeProducesAnnotation =
                annotatedResourceClass.getAnnotation(Produces.class);
        workOutResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
        workOutSubResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
        workOutSubResourceLocatorsList(resource, methodList, isEncodedAnotOnClass);

        workOutPostConstructPreDestroy(resource, methodList);
       
        logNonPublicMethods(resourceClass);

        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest(ImplMessages.NEW_AR_CREATED_BY_INTROSPECTION_MODELER(
                    resource.toString()));
        }

        return resource;
    }
View Full Code Here

        }

        public void valueUnbound(HttpSessionBindingEvent hsbe) {
            for (Object o : values()) {
                try {
                    AbstractResource ar = IntrospectionModeller.createResource(o.getClass());
                    ResourceComponentDestructor rcd = new ResourceComponentDestructor(ar);
                    rcd.destroy(o);
                } catch (IllegalAccessException ex) {
                    throw new ContainerException("Unable to destroy resource", ex);
                } catch (InvocationTargetException ex) {
View Full Code Here

        final boolean isRootResourceClass = (null != rPathAnnotation);

        final boolean isEncodedAnotOnClass =
                (null != annotatedResourceClass.getAnnotation(Encoded.class));

        AbstractResource resource;

        if (isRootResourceClass) {
            resource = new AbstractResource(resourceClass,
                    new PathValue(rPathAnnotation.value()));
        } else { // just a subresource class
            resource = new AbstractResource(resourceClass);
        }

        workOutConstructorsList(resource, resourceClass.getConstructors(),
                isEncodedAnotOnClass);

        workOutFieldsList(resource, isEncodedAnotOnClass);
       
        final MethodList methodList = new MethodList(resourceClass);

        workOutSetterMethodsList(resource, methodList, isEncodedAnotOnClass);
       
        final Consumes classScopeConsumesAnnotation =
                annotatedResourceClass.getAnnotation(Consumes.class);
        final Produces classScopeProducesAnnotation =
                annotatedResourceClass.getAnnotation(Produces.class);
        workOutResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
        workOutSubResourceMethodsList(resource, methodList, isEncodedAnotOnClass,
                classScopeConsumesAnnotation, classScopeProducesAnnotation);
        workOutSubResourceLocatorsList(resource, methodList, isEncodedAnotOnClass);

        workOutPostConstructPreDestroy(resource);

        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest(ImplMessages.NEW_AR_CREATED_BY_INTROSPECTION_MODELER(
                    resource.toString()));
        }

        return resource;
    }
View Full Code Here

TOP

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

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.