Package com.sun.jersey.api.container

Examples of com.sun.jersey.api.container.ContainerException


    private void ensureTemplateUnused(UriTemplate t, AbstractResource ar, Set<UriTemplate> templates) {
        if (!templates.contains(t)) {
            templates.add(t);
        } else {
            LOGGER.severe(ImplMessages.AMBIGUOUS_RR_PATH(ar.getResourceClass(), t));
            throw new ContainerException(ImplMessages.AMBIGUOUS_RR_PATH(ar.getResourceClass(), t));
        }
    }
View Full Code Here


    private RulesMap<UriRule> processRootResources() {
        Set<Class<?>> classes = resourceConfig.getRootResourceClasses();
        Set<Object> singletons = resourceConfig.getRootResourceSingletons();
        if (classes.isEmpty() && singletons.isEmpty()) {
            LOGGER.severe(ImplMessages.NO_ROOT_RES_IN_RES_CFG());
            throw new ContainerException(ImplMessages.NO_ROOT_RES_IN_RES_CFG());
        }

        RulesMap<UriRule> rulesMap = new RulesMap<UriRule>();

        // need to validate possible conflicts in uri templates
View Full Code Here

* @author Paul.Sandoz@Sun.Com
*/
public final class ErrorHelper {
   
    public static ContainerException objectNotAWebResource(Class resourceClass) {
        return new ContainerException(ImplMessages.OBJECT_NOT_A_WEB_RESOURCE(resourceClass.getName()));
    }
View Full Code Here

    public static ContainerException objectNotAWebResource(Class resourceClass) {
        return new ContainerException(ImplMessages.OBJECT_NOT_A_WEB_RESOURCE(resourceClass.getName()));
    }
   
    public static ContainerException badClassConsumes(Exception e, Class resourceClass, Consumes c) {
        return new ContainerException(ImplMessages.BAD_CLASS_CONSUMEMIME(resourceClass,
                                                                                           c.value()), e);
    }
View Full Code Here

        return new ContainerException(ImplMessages.BAD_CLASS_CONSUMEMIME(resourceClass,
                                                                                           c.value()), e);
    }
   
    public static ContainerException badClassProduces(Exception e, Class resourceClass, Produces p) {
        return new ContainerException(ImplMessages.BAD_CLASS_PRODUCEMIME(resourceClass,
                                                                                           p.value()), e);
    }
View Full Code Here

        return new ContainerException(ImplMessages.BAD_CLASS_PRODUCEMIME(resourceClass,
                                                                                           p.value()), e);
    }
   
    public static ContainerException badMethodHttpMethod(Class resourceClass, Method m, HttpMethod hm) {
        return new ContainerException(ImplMessages.BAD_METHOD_HTTPMETHOD(resourceClass,
                                                                                           hm.value(),
                                                                                           m.toString()));
    }
View Full Code Here

                                                                                           hm.value(),
                                                                                           m.toString()));
    }
   
    public static ContainerException badMethodConsumes(Exception e, Class resourceClass, Method m, Consumes c) {
        return new ContainerException(ImplMessages.BAD_METHOD_CONSUMEMIME(resourceClass,
                                                                                   c.value(),
                                                                                   m.toString()), e);
    }
View Full Code Here

                                                                                   c.value(),
                                                                                   m.toString()), e);
    }
   
    public static ContainerException badMethodProduces(Exception e, Class resourceClass, Method m, Produces p) {
        return new ContainerException(ImplMessages.BAD_METHOD_PRODUCEMIME(resourceClass,
                                                                                   p.value(),
                                                                                   m.toString()), e);
    }
View Full Code Here

            }
        } catch (InvocationTargetException e) {
            // Propagate the target exception so it may be mapped to a response
            throw new MappableContainerException(e.getTargetException());
        } catch (IllegalAccessException e) {
            throw new ContainerException(e);
        } catch (WebApplicationException e) {
            throw e;
        } catch (RuntimeException e) {
            throw new ContainerException("Exception injecting parameters for sub-locator method: " + m, e);
        }
    }
View Full Code Here

            ResourceComponentProviderFactoryClass rf = annotationClass.getAnnotation(
                    ResourceComponentProviderFactoryClass.class);
            if (rf != null && providerFactoryClass == null)
                providerFactoryClass = rf.value();
            else if (rf != null && providerFactoryClass != null)
                throw new ContainerException(c.toString()+
                        " has multiple ResourceComponentProviderClass annotations");
        }

        if (providerFactoryClass == null) {
            Object v = config.getProperties().
                    get(ResourceConfig.PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS);
            if (v == null) {
                // Use default provider if none specified
                providerFactoryClass = PerRequestFactory.class;
            } else if (v instanceof Class) {
                Class<?> _c = (Class<?>)v;
                if (ResourceComponentProviderFactory.class.isAssignableFrom(_c)) {
                    providerFactoryClass = _c.asSubclass(ResourceComponentProviderFactory.class);
                } else {
                    throw new IllegalArgumentException("Property value for "
                            + ResourceConfig.PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS
                            + " of type " + v.getClass() + " not of a subclass of " + ResourceComponentProviderFactory.class);
                }
            } else {
                throw new IllegalArgumentException("Property value for "
                        + ResourceConfig.PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS
                        + " of type " + v.getClass() + " not of a subclass of " + ResourceComponentProviderFactory.class);
            }
        }

        try {
            ComponentConstructor<ResourceComponentProviderFactory> cc =
                    new ComponentConstructor(ipc, providerFactoryClass);
            ResourceComponentProviderFactory rcpf = cc.getInstance();

            ComponentInjector<ResourceComponentProviderFactory> ci =
                    new ComponentInjector(ipc, providerFactoryClass);
            ci.inject(rcpf);

            return rcpf;
        } catch (IllegalArgumentException ex) {
            throw new ContainerException("Unable to create resource component provider", ex);
        } catch (InvocationTargetException ex) {
            throw new ContainerException("Unable to create resource component provider", ex);
        } catch (IllegalAccessException ex) {
            throw new ContainerException("Unable to create resource component provider", ex);
        } catch (InstantiationException ex) {
            throw new ContainerException("Unable to create resource component provider", ex);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.container.ContainerException

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.