Package com.alibaba.citrus.service.requestcontext

Examples of com.alibaba.citrus.service.requestcontext.RequestContext


*
* @author Michael Zhou
*/
public class DummyRequestContextFactoryImpl extends AbstractRequestContextFactory<RequestContext> {
    public RequestContext getRequestContextWrapper(final RequestContext wrappedContext) {
        return new RequestContext() {
            public RequestContext getWrappedRequestContext() {
                return wrappedContext;
            }

            public HttpServletRequest getRequest() {
View Full Code Here


     */
    public RequestContext getRequestContext(ServletContext servletContext, HttpServletRequest request,
                                            HttpServletResponse response) {
        assertInitialized();

        RequestContext requestContext = new SimpleRequestContext(servletContext, request, response);

        // ��requestContext����request�У��Ա���ֻ��Ҫ��request�Ϳ���ȡ��requestContext��
        // ��������setRequestContext���Ա�����prepareRequestContext����ʹ�á�
        RequestContextUtil.setRequestContext(requestContext);

        for (RequestContextFactory<?> factory : factories) {
            requestContext = factory.getRequestContextWrapper(requestContext);

            // ����<code>requestContext.prepare()</code>����
            prepareRequestContext(requestContext);

            // ��requestContext����request�У��Ա���ֻ��Ҫ��request�Ϳ���ȡ��requestContext��
            RequestContextUtil.setRequestContext(requestContext);
        }

        setupSpringWebEnvironment(requestContext.getRequest());

        return requestContext;
    }
View Full Code Here

    private final class ResponseProxyTargetFactory extends RequestProxyTargetFactory {
        @Override
        public Object getObject() {
            HttpServletRequest request = (HttpServletRequest) super.getObject();
            RequestContext requestContext = RequestContextUtil.getRequestContext(request);

            if (requestContext == null) {
                throw new IllegalStateException("Current request does not support request context");
            }

            return requestContext.getResponse();
        }
View Full Code Here

    private final class SessionProxyTargetFactory extends RequestProxyTargetFactory {
        @Override
        public Object getObject() {
            HttpServletRequest request = (HttpServletRequest) super.getObject();
            RequestContext requestContext = RequestContextUtil.getRequestContext(request);

            if (requestContext == null) {
                throw new IllegalStateException("Current request does not support request context");
            }

            return requestContext.getRequest().getSession();
        }
View Full Code Here

        @Override
        public Object getObject() {
            HttpServletRequest request = (HttpServletRequest) super.getObject();

            RequestContext requestContext = RequestContextUtil.findRequestContext(request, requestContextInterface);

            if (requestContext == null) {
                throw new IllegalStateException("Current request does not support request context: "
                        + requestContextInterface.getName());
            }
View Full Code Here

        initServlet("webapp/WEB-INF/web.xml");
        initFactory();

        RequestContextChainingService requestContexts = (RequestContextChainingService) factory
                .getBean("requestContexts");
        RequestContext rc = null;

        try {
            // Ԥ��request, response
            rc = requestContexts.getRequestContext(servletContext, request, response);

            // ����contentType��charset����jsp�е����ò�ͬ���Դ�Ϊ׼
            rc.getResponse().setContentType("text/plain; charset=GBK"); // JSP: text/html; charset=UTF-8

            // Ԥ��template context
            TemplateContext context = new MappedTemplateContext();
            context.put("hello", "�й�");
View Full Code Here

            public void commit() {
                commits.add(index);
            }
        }

        RequestContext wrappedRequestContext = createMock(RequestContext.class);
        HttpServletRequest wrappedRequest = createMock(HttpServletRequest.class);
        HttpServletResponse wrappedResponse = createMock(HttpServletResponse.class);
        ServletContext servletContext = createMock(ServletContext.class);

        expect(wrappedRequestContext.getRequest()).andReturn(wrappedRequest).anyTimes();
        expect(wrappedRequestContext.getResponse()).andReturn(wrappedResponse).anyTimes();
        expect(wrappedRequestContext.getServletContext()).andReturn(servletContext).anyTimes();

        replay(wrappedRequestContext);

        BasicRequestContextImpl requestContext = new BasicRequestContextImpl(wrappedRequestContext, new Object[] {
                new MyInterceptor(1), new MyInterceptor(2), new MyInterceptor(3) });
View Full Code Here

    }

    protected final void initRequestContext(ApplicationContext factory) {
        requestContexts = (RequestContextChainingService) factory.getBean("requestContexts");

        RequestContext topRC = requestContexts.getRequestContext(config.getServletContext(), request, response);

        assertNotNull(topRC);

        rundata = findRequestContext(topRC, RunData.class);

        newRequest = topRC.getRequest();
        newResponse = topRC.getResponse();
    }
View Full Code Here

    }

    protected final void initRequestContext(ApplicationContext factory) {
        requestContexts = (RequestContextChainingService) factory.getBean("requestContexts");

        RequestContext topRC = requestContexts.getRequestContext(config.getServletContext(), request, response);

        assertNotNull(topRC);

        rundata = findRequestContext(topRC, RunData.class);

        newRequest = topRC.getRequest();
        newResponse = topRC.getResponse();

        // 创建turbine rundata
        TurbineUtil.getTurbineRunData(newRequest, true);

        // 设置当前component
View Full Code Here

    /** 取得request context。 */
    protected final void initRequestContext() {
        requestContexts = (RequestContextChainingService) factory.getBean("requestContexts");

        RequestContext topRC = requestContexts.getRequestContext(context, request, response);

        assertNotNull(topRC);

        newRequest = topRC.getRequest();
        newResponse = topRC.getResponse();

        rundata = (TurbineRunDataInternal) TurbineUtil.getTurbineRunData(newRequest, true);

        WebxUtil.setCurrentComponent(newRequest, component);

View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.requestcontext.RequestContext

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.