Package com.sun.jersey.api.core

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


    }

    public static final URI BASE_URI = getBaseURI();
   
    protected static HttpServer startServer() throws IOException {
        ResourceConfig resourceConfig = new PackagesResourceConfig("$package");

        System.out.println("Starting grizzly2...");
        return GrizzlyServerFactory.createHttpServer(BASE_URI, resourceConfig);
    }
View Full Code Here


            if (packages != null) {
                props.put(PackagesResourceConfig.PROPERTY_PACKAGES, packages);
                return new PackagesResourceConfig(props);
            }

            ResourceConfig defaultConfig = webConfig.getDefaultResourceConfig(props);
            if (defaultConfig != null)
                return defaultConfig;
           
            return getDefaultResourceConfig(props, webConfig);
        }

        try {
            Class resourceConfigClass = ReflectionHelper.
                    classForNameWithException(resourceConfigClassName);

            if (resourceConfigClass == ClasspathResourceConfig.class) {
                String[] paths = getPaths(webConfig.getInitParameter(
                        ClasspathResourceConfig.PROPERTY_CLASSPATH));
                props.put(ClasspathResourceConfig.PROPERTY_CLASSPATH, paths);
                return new ClasspathResourceConfig(props);
            } else if (ResourceConfig.class.isAssignableFrom(resourceConfigClass)) {
                try {
                    Constructor constructor = resourceConfigClass.getConstructor(Map.class);
                    if (ClasspathResourceConfig.class.isAssignableFrom(resourceConfigClass)) {
                        String[] paths = getPaths(webConfig.getInitParameter(
                                ClasspathResourceConfig.PROPERTY_CLASSPATH));
                        props.put(ClasspathResourceConfig.PROPERTY_CLASSPATH, paths);
                    }
                    return (ResourceConfig)constructor.newInstance(props);
                } catch (NoSuchMethodException ex) {
                    // Pass through and try the default constructor
                } catch (Exception e) {
                    throw new ServletException(e);
                }

                try {
                    return (ResourceConfig)resourceConfigClass.newInstance();
                } catch(Exception e) {
                    throw new ServletException(e);
                }
            } else if (Application.class.isAssignableFrom(resourceConfigClass)) {
                try {
                    ResourceConfig rc = new ApplicationAdapter(
                            (Application)resourceConfigClass.newInstance());
                    rc.getProperties().putAll(props);
                    return rc;
                } catch(Exception e) {
                    throw new ServletException(e);
                }
            } else {
View Full Code Here

    private Application createApplication(String[] paths) {
        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        final ClassLoader ncl = new Loader(classpath.list(), this.getClass().getClassLoader());
        Thread.currentThread().setContextClassLoader(ncl);
        try {
            ResourceConfig rc = new ClasspathResourceConfig(classpath.list());
            rc.validate();
            Set<AbstractResource> s = new HashSet<AbstractResource>();
            for (Class c : rc.getRootResourceClasses()) {
                s.add(IntrospectionModeller.createResource(c));
            }
            return new WadlBuilder().generate(s);
        } catch(Exception e) {
            throw new BuildException(e);
View Full Code Here

    }

    private ResourceConfig createResourceConfig(WebConfig webConfig)
            throws ServletException {
        final Map<String, Object> props = getInitParams(webConfig);
        final ResourceConfig rc = createResourceConfig(webConfig, props);
        rc.setPropertiesAndFeatures(props);
        return rc;
    }
View Full Code Here

            if (packages != null) {
                props.put(PackagesResourceConfig.PROPERTY_PACKAGES, packages);
                return new PackagesResourceConfig(props);
            }

            ResourceConfig defaultConfig = webConfig.getDefaultResourceConfig(props);
            if (defaultConfig != null)
                return defaultConfig;
           
            return getDefaultResourceConfig(props, webConfig);
        }
View Full Code Here

    public static <A> A createContainer(Class<A> type, String packageName)
    throws ContainerException, IllegalArgumentException {
        String resourcesClassName = packageName + ".WebResources";
        try {
            Class<?> resourcesClass = ContainerFactory.class.getClassLoader().loadClass(resourcesClassName);
            ResourceConfig config = (ResourceConfig) resourcesClass.newInstance();
            return createContainer(type, config, null);
        } catch (ClassNotFoundException e) {
            throw new ContainerException(e);
        } catch (InstantiationException e) {
            throw new ContainerException(e);
View Full Code Here

    private Application createApplication(String[] paths) {
        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        final ClassLoader ncl = new Loader(classpath.list(), this.getClass().getClassLoader());
        Thread.currentThread().setContextClassLoader(ncl);
        try {
            ResourceConfig rc = new ClasspathResourceConfig(classpath.list());
            rc.validate();
            Set<AbstractResource> s = new HashSet<AbstractResource>();
            for (Class c : rc.getRootResourceClasses()) {
                s.add(IntrospectionModeller.createResource(c));
            }
            return new WadlBuilder().generate(s);
        } catch(Exception e) {
            throw new BuildException(e);
View Full Code Here

    }

    private ApplicationDescription createApplicationDescription( String[] paths, WadlGenerator wadlGenerator ) throws MojoExecutionException {
        final Map<String, Object> map = new HashMap<String, Object>();
        map.put( PackagesResourceConfig.PROPERTY_PACKAGES, paths );
        final ResourceConfig rc = new PackagesResourceConfig( map );
        final Set<AbstractResource> s = new HashSet<AbstractResource>();
        for (Class<?> c : rc.getRootResourceClasses()) {
            getLog().debug( "Adding class " + c.getName() );
            s.add( IntrospectionModeller.createResource(c) );
        }
        return new WadlBuilder( wadlGenerator ).generate( null, s );
    }
View Full Code Here

    public static final URI BASE_URI = getBaseURI();
  
    public static HttpServer startServer() throws IOException{

        ResourceConfig rc = new PackagesResourceConfig("com.sun.jersey.samples.jsonp");
        return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
    }
View Full Code Here

    public static final URI BASE_URI = getBaseURI();
       
    public static HttpServer startServer() throws IOException {

        ResourceConfig rc = new PackagesResourceConfig(JAXBResource.class.getPackage().getName());
        return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.core.ResourceConfig

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.