Package com.sun.jersey.api.container

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


                Object o = rcc.construct(hc);
                rci.inject(hc, o);
                Object po = ipcp.proxy(o);
                    return po;
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InvocationTargetException ex) {
                // Propagate the target exception so it may be mapped to a response
                throw new MappableContainerException(ex.getTargetException());
            } catch (WebApplicationException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here


            try {
                this.resource = rcc.construct(null);
                rci.inject(null, resource);
            } catch (InvocationTargetException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here

            try {
                Object o = rcc.construct(null);
                rci.inject(null, o);
                resource = ipcp.proxy(o);
            } catch (InvocationTargetException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here

                if (f.get(o) == null) {
                    f.set(o, singletonFieldValues[i]);
                }
                i++;
            } catch (IllegalAccessException ex) {
                throw new ContainerException(ex);
            }
        }
       
        i = 0;
        for (Field f : perRequestFields) {
            try {
                if (perRequestPrimitive[i] || f.get(o) == null) {
                    f.set(o, perRequestFieldInjectables[i].getValue(c));
                }
                i++;
            } catch (IllegalAccessException ex) {
                throw new ContainerException(ex);
            }
        }
       
        i = 0;
        for (Method m : singletonSetters) {
            try {
                m.invoke(o, singletonSetterValues[i++]);
            } catch (Exception ex) {
                throw new ContainerException(ex);
            }
        }
       
        i = 0;
        for (Method m : perRequestSetters) {
            try {
                m.invoke(o, perRequestSetterInjectables[i++].getValue(c));
            } catch (Exception ex) {
                throw new ContainerException(ex);
            }
        }
    }
View Full Code Here

        for (WebApplicationProvider wap : ServiceFinder.find(WebApplicationProvider.class)) {
            // Use the first provider found
            return wap.createWebApplication();
        }
               
        throw new ContainerException("No WebApplication provider is present");
    }
View Full Code Here

        private void destroy(Object o) {
            try {
                rcd.destroy(o);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to destroy resource", ex);
            } catch (InvocationTargetException ex) {
                throw new ContainerException("Unable to destroy resource", ex);
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to destroy resource", ex);
            }
        }
View Full Code Here

            try {
                Object o = rcc.construct(hc);
                rci.inject(hc, o);
                return o;
            } catch (InstantiationException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (IllegalAccessException ex) {
                throw new ContainerException("Unable to create resource", ex);
            } catch (InvocationTargetException ex) {
                // Propagate the target exception so it may be mapped to a response
                throw new MappableContainerException(ex.getTargetException());
            } catch (WebApplicationException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                throw new ContainerException("Unable to create resource", ex);
            }
        }
View Full Code Here

                }
            }
        } // eof model validation
        if (fatalIssueFound) {
            LOGGER.severe(ImplMessages.FATAL_ISSUES_FOUND_AT_RES_CLASS(ar.getResourceClass().getName()));
            throw new ContainerException(ImplMessages.FATAL_ISSUES_FOUND_AT_RES_CLASS(ar.getResourceClass().getName()));
        }
        return new ResourceClass(
                resourceConfig,
                dispatcherFactory,
                injectableFactory,
View Full Code Here

        final String encodedBasePath = UriComponent.encode(decodedBasePath,
                UriComponent.Type.PATH);

        if (!decodedBasePath.equals(encodedBasePath)) {
            throw new ContainerException("The servlet context path and/or the " +
                    "servlet path contain characters that are percent enocded");
        }

        final URI baseUri = absoluteUriBuilder.replacePath(encodedBasePath).
                build();
View Full Code Here

        if (resourceConfig == null) {
            throw new IllegalArgumentException("ResourceConfig instance MUST NOT be null");
        }

        if (initiated) {
            throw new ContainerException(ImplMessages.WEB_APP_ALREADY_INITIATED());
        }
        this.initiated = true;
       
        // Validate the resource config
        resourceConfig.validate();

        // Check the resource configuration
        this.resourceConfig = resourceConfig;

        this.provider = _provider;
       
        // Set up the component provider factory to be
        // used with non-resource class components
        this.cpFactory = (_provider == null)
                ? new ProviderFactory(injectableFactory)
                : new IoCProviderFactory(injectableFactory, _provider);

        // Set up the resource component provider factory
        this.rcpFactory = (_provider == null)
                ? new ResourceFactory(this.resourceConfig, this.injectableFactory)
                : new IoCResourceFactory(this.resourceConfig, this.injectableFactory, _provider);
               
        this.resourceContext = new ResourceContext() {
            public <T> T getResource(Class<T> c) {
                final ResourceClass rc = getResourceClass(c);
                if (rc == null) {
                    LOGGER.severe("No resource class found for class " + c.getName());
                    throw new ContainerException("No resource class found for class " + c.getName());
                }
                final Object instance = rc.rcProvider.getInstance(context);
                return instance != null ? c.cast(instance) : null;
            }
        };

        ProviderServices providerServices = new ProviderServices(
                this.injectableFactory,
                this.cpFactory,
                resourceConfig.getProviderClasses(),
                resourceConfig.getProviderSingletons());

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

                    @SuppressWarnings("unchecked")
                    public Injectable<Object> getInjectable(ComponentContext ic, Inject a, final Type c) {
                        if (!(c instanceof Class))
                            return null;

                        if (provider == null)
                            return null;
                       
                        final IoCComponentProvider p = provider.getComponentProvider(ic, (Class)c);
                        return new Injectable<Object>() {
                            public Object getValue() {
                                try {
                                    return p.getInstance();
                                } catch (Exception e) {
                                    LOGGER.log(Level.SEVERE, "Could not get instance from IoC component provider for type " +
                                            c, e);
                                    throw new ContainerException("Could not get instance from IoC component provider for type " +
                                            c, e);
                                }
                            }
                        };
                    }
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.