Package org.apache.wink.server.internal

Examples of org.apache.wink.server.internal.DeploymentConfiguration


        @Override
        protected DeploymentConfiguration getDeploymentConfiguration()
            throws ClassNotFoundException, InstantiationException, IllegalAccessException,
            IOException {
            DeploymentConfiguration deploymentConfiguration = super.getDeploymentConfiguration();
            deploymentConfiguration.setFilterConfig(filterConfig);
            return deploymentConfiguration;
        }
View Full Code Here


        getRequestProcessor().handleRequest(httpServletRequest, httpServletResponse);
    }

    protected RequestProcessor createRequestProcessor() throws ClassNotFoundException,
        InstantiationException, IllegalAccessException, IOException {
        DeploymentConfiguration deploymentConfiguration = getDeploymentConfiguration();
        // order of next two lines is important to allow Application to have
        // control over priority order of Providers
        Application app = getApplication();
        if (app == null) {
            app = getApplication(deploymentConfiguration);
        }
        deploymentConfiguration.addApplication(app, false);
        RequestProcessor requestProcessor = new RequestProcessor(deploymentConfiguration);
        logger.debug("Creating request processor {} for servlet {}", requestProcessor, this); //$NON-NLS-1$
        return requestProcessor;
    }
View Full Code Here

        return requestProcessor;
    }

    protected DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException,
        InstantiationException, IllegalAccessException, IOException {
        DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration();
        deploymentConfiguration.setServletConfig(getServletConfig());
        deploymentConfiguration.setServletContext(getServletContext());
        deploymentConfiguration.setProperties(getProperties());
        deploymentConfiguration.init();
        return deploymentConfiguration;
    }
View Full Code Here

            // use ClassUtils.loadClass instead of Class.forName so we have
            // classloader visibility into the Web module in J2EE environments
            Class<?> confClass = ClassUtils.loadClass(initParameter);
            return (DeploymentConfiguration)confClass.newInstance();
        }
        return new DeploymentConfiguration();
    }
View Full Code Here

                                     getDeploymentConfiguration(null));
        assertEquals("HTTP method", HttpMethod.POST, context.getHttpMethod());
    }

    private DeploymentConfiguration getDeploymentConfiguration(String winkhttpMethodOverrideHeader) {
        DeploymentConfiguration configuration = new DeploymentConfiguration();
        Properties properties = new Properties();
        if (winkhttpMethodOverrideHeader != null) {
            properties.setProperty("wink.httpMethodOverrideHeaders", winkhttpMethodOverrideHeader);
        }
        configuration.setProperties(properties);
        configuration.init();
        return configuration;
    }
View Full Code Here

        // reflection and hacking.  We'll at least confirm that only 5 (due to AssetProvider) are in the ProvidersRegistry.

        RestServlet servlet = (RestServlet)this.getServlet();
        ServletContext context = servlet.getServletContext();
        RequestProcessor processor = (RequestProcessor) context.getAttribute(RequestProcessor.class.getName());
        DeploymentConfiguration config = processor.getConfiguration();
        ProvidersRegistry providersRegistry = config.getProvidersRegistry();
        // to confirm that the ignores are indeed happening, I need to get the private field
        // "messageBodyReaders" object, then it's superclass "data" object and inspect it:
        Field field = providersRegistry.getClass().getDeclaredField("messageBodyReaders");
        field.setAccessible(true);
        Object messageBodyReaders = field.get(providersRegistry);
View Full Code Here

        return propFile;
    }

    public void testInjectServletContfig() {
        RestServlet restServlet = (RestServlet)this.getServlet();
        DeploymentConfiguration configuration =
            restServlet.getRequestProcessor().getConfiguration();

        assertNotNull(configuration.getServletContext());
        assertNotNull(configuration.getServletConfig());
    }
View Full Code Here

        RestServlet servlet =
            (RestServlet)Class.forName("org.apache.wink.server.internal.servlet.RestServlet")
                .newInstance();

        String requestProcessorAttribute = "MOCK_REQUEST_PROCESSOR";
        DeploymentConfiguration configuration = new DeploymentConfiguration();
        configuration.init();

        RequestProcessor requestProcessor = new RequestProcessor(configuration);

        MockServletContext servletContext = new MockServletContext();
        servletContext.setAttribute(requestProcessorAttribute, requestProcessor);

        MockServletConfig servletConfig = new MockServletConfig(servletContext);
        servletConfig.addInitParameter("javax.ws.rs.Application", getApplicationClassName());
        servletConfig.addInitParameter("requestProcessorAttribute", requestProcessorAttribute);

        String propertiesFile = getPropertiesFile();
        if (propertiesFile != null) {
            servletConfig.addInitParameter("propertiesLocation", propertiesFile);
        }

        assertNull(configuration.getServletContext());
        assertNull(configuration.getServletConfig());

        ThreadLocal<MockServletInvocationTest> tls = new ThreadLocal<MockServletInvocationTest>();
        tls.set(this);
        servlet.init(servletConfig);

        DeploymentConfiguration servletConfiguration =
            servlet.getRequestProcessor().getConfiguration();

        assertEquals(configuration, servletConfiguration);

        assertNotNull(servletConfiguration.getServletContext());
        assertNotNull(servletConfiguration.getServletConfig());
    }
View Full Code Here

            }

            public void addCookie(Cookie arg0) {

            }
        }, new DeploymentConfiguration() {
        });

        HttpHeadersImpl headers = new HttpHeadersImpl(context);
        List<MediaType> mediaTypes = headers.getAcceptableMediaTypes();
        assertEquals(1, mediaTypes.size());
View Full Code Here

                                                     registry.getServiceDiscovery(),
                                                     "javax.ws.rs.ext.RuntimeDelegate",
                                                     "/META-INF/wink-alternate-shortcuts.properties",
                                                     "/META-INF/server/wink-providers");

        DeploymentConfiguration config = null;
        try {
            config = super.getDeploymentConfiguration();
        } finally {
            if (cl != null) {
                // return previous classLoader
                Thread.currentThread().setContextClassLoader(cl);
            }
        }

        // [rfeng] FIXME: This is a hack to fool Apache wink to not remove the servlet path
        config.setFilterConfig(new FilterConfig() {

            public ServletContext getServletContext() {
                return getServletContext();
            }

            public Enumeration getInitParameterNames() {
                return getInitParameterNames();
            }

            public String getInitParameter(String arg0) {
                return getInitParameter(arg0);
            }

            public String getFilterName() {
                return getServletName();
            }
        });

        ProvidersRegistry providers = config.getProvidersRegistry();
        providers.addProvider(new DataBindingJAXRSReader(registry), 0.001, true);
        providers.addProvider(new DataBindingJAXRSWriter(registry), 0.001, true);

        config.getResponseUserHandlers().add(new TuscanyResponseHandler());

        return config;
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.server.internal.DeploymentConfiguration

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.