Package com.sun.jersey.api.core

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


            if ((originalApp.getClasses() == null || originalApp.getClasses().isEmpty()) &&
                    (originalApp.getSingletons() == null || originalApp.getSingletons().isEmpty())) {
                LOGGER.info("Instantiated the Application class " + appClass.getName() +
                        ". The following root resource and provider classes are registered: " + defaultClasses);
                this.adaptedApp = new DefaultResourceConfig(defaultClasses);
                adaptedApp.add(originalApp);
            } else {
                LOGGER.info("Instantiated the Application class " + appClass.getName());
                adaptedApp = null;
            }
View Full Code Here


    public static <A> A createContainer(Class<A> type, Class<?>... resourceClasses)
    throws ContainerException, IllegalArgumentException {
        Set<Class<?>> resourceClassesSet = new HashSet<Class<?>>(
                Arrays.asList(resourceClasses));
       
        return createContainer(type, new DefaultResourceConfig(resourceClassesSet),
                null);
    }
View Full Code Here

     * @throws IllegalArgumentException if no container provider supports the type.
     */
    @SuppressWarnings("unchecked")
    public static <A> A createContainer(Class<A> type, Set<Class<?>> resourceClasses)
    throws ContainerException, IllegalArgumentException {
        return createContainer(type, new DefaultResourceConfig(resourceClasses),
                null);
    }
View Full Code Here

    public static final String CONTEXT_CONFIG_LOCATION = "contextConfigLocation";

    @Override
    protected ResourceConfig getDefaultResourceConfig(Map<String, Object> props,
            WebConfig webConfig) throws ServletException {
        return new DefaultResourceConfig();
    }
View Full Code Here

    public static final String CONTEXT_CONFIG_LOCATION = "contextConfigLocation";

    @Override
    protected ResourceConfig getDefaultResourceConfig(Map<String, Object> props,
            WebConfig webConfig) throws ServletException {
        return new DefaultResourceConfig();
    }
View Full Code Here


        Adapter adapter = null;
        Reloader r = new Reloader();

        ResourceConfig rc = new DefaultResourceConfig(classes);
        rc.getMediaTypeMappings().put("xml", MediaType.APPLICATION_XML_TYPE);
        rc.getMediaTypeMappings().put("json", MediaType.APPLICATION_JSON_TYPE);
        rc.getMediaTypeMappings().put("html", MediaType.TEXT_HTML_TYPE);
        rc.getMediaTypeMappings().put("js", new MediaType("application", "x-javascript"));

        RestConfig restConf = getRestConfig(habitat);
        if (restConf != null) {
            if (restConf.getLogOutput().equalsIgnoreCase("true")) { //enable output logging
                rc.getContainerResponseFilters().add(LoggingFilter.class);
            }
            if (restConf.getLogInput().equalsIgnoreCase("true")) { //enable input logging
                rc.getContainerRequestFilters().add(LoggingFilter.class);
            }
            if (restConf.getWadlGeneration().equalsIgnoreCase("false")) { //disable WADL
                rc.getFeatures().put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.TRUE);
            }
        }

        rc.getProperties().put(ResourceConfig.PROPERTY_CONTAINER_NOTIFIER, r);
        rc.getClasses().add(ReloadResource.class);

        //We can only inject these 4 extra classes in Jersey resources...
        rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, Reloader>(Reloader.class, r) {});
        rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, ServerContext>(ServerContext.class, sc) {});
        rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, Habitat>(Habitat.class, habitat) {});
        rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, SessionManager>(SessionManager.class, habitat.getComponent(SessionManager.class)) {});
        rc.getSingletons().add(new SingletonTypeInjectableProvider<Context, SessionManager>(SessionManager.class, habitat.getComponent(SessionManager.class)) {});

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

        builder.shutdownProc(makeShutdownProc(this));
        exhibitor = new Exhibitor(configProvider, null, backupProvider, builder.build());
        exhibitor.start();

        DefaultResourceConfig   application = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
        ServletContainer        container = new ServletContainer(application);
        server = new Server(httpPort);
        Context root = new Context(server, "/", Context.SESSIONS);
        root.addServlet(new ServletHolder(container), "/*");
        if ( security != null )
View Full Code Here

    private final Logger                    log = LoggerFactory.getLogger(getClass());
    private final DefaultResourceConfig     config;

    public ExhibitorResourceConfig(@Context ServletContext context)
    {
        DefaultResourceConfig   localConfig;
        Exhibitor               exhibitor = (Exhibitor)context.getAttribute(ExhibitorServletContextListener.class.getName());
        if ( exhibitor != null )
        {
            log.info("Adding Exhibitor Jersey resources");
            localConfig = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
        }
        else
        {
            log.info("Using DefaultResourceConfig");
            localConfig = new DefaultResourceConfig();
        }
        config = localConfig;
    }
View Full Code Here

    public static DefaultResourceConfig newApplicationConfig(UIContext context)
    {
        final Set<Object> singletons = getSingletons(context);
        final Set<Class<?>> classes = getClasses();

        return new DefaultResourceConfig()
        {
            @Override
            public Set<Class<?>> getClasses()
            {
                return classes;
View Full Code Here

    super.init(config);
  }

  @Override
  protected ResourceConfig getDefaultResourceConfig(Map<String, Object> props, WebConfig webConfig) throws ServletException {
    DefaultResourceConfig cfg = new DefaultResourceConfig();
    if (props.containsKey(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS) == false) {
      props.put(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, new ArrayList<Object>(Arrays.asList(new HttpMethodFilter(), new UrlSuffixFilter())));
    }
    if (props.containsKey(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS) == false) {
      props.put(ResourceConfig.PROPERTY_CONTAINER_RESPONSE_FILTERS, new ArrayList<Object>(Arrays.asList(new NoCachingFilter())));
    }
    cfg.setPropertiesAndFeatures(props);
    return cfg;
  }
View Full Code Here

TOP

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

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.