Package org.glassfish.jersey.server

Examples of org.glassfish.jersey.server.ResourceConfig$State


        connector.setPort(port);
        return connector;
    }

    private static ServletContainer createJerseyServlet() throws IOException {
        ResourceConfig resourceConfig = new ResourceConfig();
        resourceConfig.register(JacksonFeature.class);

        resourceConfig.register(new ApiResource());

        return new ServletContainer(resourceConfig);
    }
View Full Code Here


    public ResourceConfig getResourceConfig(Set<Class<?>> classes,
                                            final ServerContext sc,
                                            final ServiceLocator habitat,
                                            final Class<? extends Factory<Ref<Subject>>> subjectReferenceFactory)
            throws EndpointRegistrationException {
        ResourceConfig rc = super.getResourceConfig(classes, sc, habitat, subjectReferenceFactory);
        rc.addClasses(ExceptionFilter.class);
        return rc;
    }
View Full Code Here

        sslContext.setKeyStoreFile("./keystore_server"); // contains server keypair
        sslContext.setKeyStorePass("asdfgh");
        sslContext.setTrustStoreFile("./truststore_server"); // contains client certificate
        sslContext.setTrustStorePass("asdfgh");

        ResourceConfig rc = new ResourceConfig();
        rc.registerClasses(RootResource.class, SecurityFilter.class, AuthenticationExceptionMapper.class);

        try {
            webServer = GrizzlyHttpServerFactory.createHttpServer(
                    getBaseURI(),
                    rc,
View Full Code Here

     * @throws TestContainerException if the default test container factory
     *                                cannot be obtained, or the application descriptor is not
     *                                supported by the test container factory.
     */
    public JerseyTest() throws TestContainerException {
        ResourceConfig config = getResourceConfig(configure());
        config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class));

        if (isLogRecordingEnabled()) {
            registerLogHandler();
        }
        this.application = new ApplicationHandler(config);
View Full Code Here

     *                                supported by the test container factory.
     */
    public JerseyTest(TestContainerFactory testContainerFactory) {
        setTestContainerFactory(testContainerFactory);

        ResourceConfig config = getResourceConfig(configure());
        config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class));
        if (isLogRecordingEnabled()) {
            registerLogHandler();
        }
        this.application = new ApplicationHandler(config);
        this.tc = getContainer(application, testContainerFactory);
View Full Code Here

     * @throws TestContainerException if the default test container factory
     *                                cannot be obtained, or the application descriptor is not
     *                                supported by the test container factory.
     */
    public JerseyTest(Application jaxrsApplication) throws TestContainerException {
        ResourceConfig config = getResourceConfig(jaxrsApplication);
        config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class));
        if (isLogRecordingEnabled()) {
            registerLogHandler();
        }
        this.application = new ApplicationHandler(config);
        this.tc = getContainer(application, getTestContainerFactory());
View Full Code Here

     * @throws TestContainerException if the default test container factory
     *                                cannot be obtained, or the application descriptor is not
     *                                supported by the test container factory.
     */
    public JerseyTest(Class<? extends Application> jaxrsApplicationClass) throws TestContainerException {
        ResourceConfig config = ResourceConfig.forApplicationClass(jaxrsApplicationClass);
        config.register(new ServiceFinderBinder<TestContainerFactory>(TestContainerFactory.class));
        if (isLogRecordingEnabled()) {
            registerLogHandler();
        }
        this.application = new ApplicationHandler(config);
        this.tc = getContainer(application, getTestContainerFactory());
View Full Code Here

        String[] resourceArr = new String[resources.size()];
        for (int i = 0; i < resources.size(); i++) {
            resourceArr[i] = String.valueOf(resources.get(i));
        }

        ResourceConfig rc = new ResourceConfig();
        rc.packages(resourceArr);

        ClassLoader cl = Thread.currentThread().getContextClassLoader();

        JsonArray features = config.getArray(CONFIG_FEATURES, null);
        if (features != null && features.size() > 0) {
            for (int i = 0; i < features.size(); i++) {
                try {
                    Class<?> clazz = cl.loadClass(String.valueOf(features.get(i)));
                    rc.register(clazz);
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        JsonArray binders = config.getArray(CONFIG_BINDERS, null);
        if (binders != null && binders.size() > 0) {
            for (int i = 0; i < binders.size(); i++) {
                try {
                    Class<?> clazz = cl.loadClass(String.valueOf(binders.get(i)));
                    rc.register(clazz.newInstance());
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                    throw new RuntimeException(e);
                }
            }
        }
View Full Code Here

        // check if the JAX-RS application config class property is present
        String jaxrsApplicationClassName = config.getInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS);

        if (jaxrsApplicationClassName == null) {
            // If no resource config class property is present, create default config
            final ResourceConfig rc = new ResourceConfig().addProperties(initParams).addProperties(contextParams);

            final String webApp = config.getInitParameter(ServletProperties.PROVIDER_WEB_APP);
            if (webApp != null && !"false".equals(webApp)) {
                rc.registerFinder(new WebAppResourcesScanner(config.getServletContext()));
            }
            return rc;
        }

        try {
View Full Code Here

    private static void addServletWithDefaultConfiguration(final ServletContext sc, final Set<Class<?>> classes)
            throws ServletException {
        ServletRegistration appReg = sc.getServletRegistration(Application.class.getName());
        if (appReg != null && appReg.getClassName() == null) {
            final Set<Class<?>> appClasses = getRootResourceAndProviderClasses(classes);
            final ResourceConfig resourceConfig = ResourceConfig.forApplicationClass(ResourceConfig.class, appClasses)
                    .addProperties(getInitParams(appReg))
                    .addProperties(WebComponent.getContextParams(sc));
            final ServletContainer s = new ServletContainer(resourceConfig);
            appReg = sc.addServlet(appReg.getName(), s);
            ((ServletRegistration.Dynamic) appReg).setLoadOnStartup(1);
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.ResourceConfig$State

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.