Package com.sun.jersey.api.core

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


    this.dbPort = dbPort;
  }

  public void run() throws Exception {
    URI baseUri = getBaseUrl(port);
    ResourceConfig rc = new PackagesResourceConfig("hello", "org.eluder.jersey.mustache");
    rc.setPropertiesAndFeatures(properties());
    rc.getContainerResponseFilters().add(new ServerResponseFilter());
    HttpServer server = GrizzlyServerFactory.createHttpServer(baseUri, rc);

    try {
        server.start();
View Full Code Here


    public static GrizzlyAdapter exposeContext(Set classes, ServerContext sc)
            throws EndpointRegistrationException {

        Adapter adapter = null;

        ResourceConfig rc = new DefaultResourceConfig(classes);

        //Use common classloader. Jersey artifacts are not visible through
        //module classloader
        ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
        try {
View Full Code Here

      e.printStackTrace();
    }
  }

  private void setupServer(Application application) {
    ResourceConfig rc = new ApplicationAdapter(application);

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(ResourceConfig.FEATURE_TRACE, "true");
    rc.setPropertiesAndFeatures(properties);

    Properties serverProperties = readProperties();
    int port = Integer.parseInt(serverProperties.getProperty(PORT_PROPERTY));
    URI serverUri = UriBuilder.fromPath(ROOT_RESOURCE_PATH).scheme("http").host("localhost").port(port).build();
    try {
View Full Code Here

    private ApplicationDescription 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(null, s);
        } catch(Exception e) {
View Full Code Here

     * @throws java.io.IOException if there is an error starting the Grizzly
     *         HTTP container.
     */
    protected static HttpServer startServer() throws IOException {

        ResourceConfig rc = new PackagesResourceConfig("com.sun.jersey.samples.optimisticconcurrency.resources");
        System.out.println("Starting grizzly...");
        return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
    }
View Full Code Here

    private void addServletWithExistingRegistration(ServletContext sc, ServletRegistration sr,
            Class<? extends Application> a, Set<Class<?>> classes) {
        if (sr.getClassName() == null) {

            final ResourceConfig rc = new DeferredResourceConfig(a, getRootResourceAndProviderClasses(classes));
            final Map<String, Object> initParams = new HashMap<String, Object>();
            for(Map.Entry<String, String> entry : sr.getInitParameters().entrySet())
                initParams.put(entry.getKey(), entry.getValue());

            rc.setPropertiesAndFeatures(initParams);

            final ServletContainer s = new ServletContainer(rc);
            sr = sc.addServlet(a.getName(), s);
            if (sr.getMappings().isEmpty()) {
                final ApplicationPath ap = a.getAnnotation(ApplicationPath.class);
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 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

                LOGGER.info("Instantiated the Application class " + appClass.getName());
                adaptedApp = null;
            }

            if (originalApp instanceof ResourceConfig) {
                final ResourceConfig rc = (ResourceConfig)originalApp;

                getFeatures().putAll(rc.getFeatures());
                getProperties().putAll(rc.getProperties());

                getExplicitRootResources().putAll(rc.getExplicitRootResources());
                getMediaTypeMappings().putAll(rc.getMediaTypeMappings());
                getLanguageMappings().putAll(rc.getLanguageMappings());
            }
        }
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.