Package com.alibaba.citrus.service.requestcontext

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


                createProxy(HttpServletResponse.class, beanFactory.getBeanClassLoader(),
                        new ResponseProxyTargetFactory()));

        // ȡ��requestContextsʱ�ἤ��requestContexts�ij�ʼ����
        // ����request/response/session�Ѿ���ע�ᣬ����Ѿ��ɱ�ע�뵽requestContexts���Ӷ����С�
        RequestContextChainingService requestContexts = (RequestContextChainingService) beanFactory.getBean(
                requestContextsName, RequestContextChainingService.class);

        // ����ȫ�ֵ�request contextʵ����
        for (RequestContextInfo<?> info : requestContexts.getRequestContextInfos()) {
            Class<? extends RequestContext> requestContextInterface = info.getRequestContextInterface();
            Class<? extends RequestContext> requestContextProxyInterface = info.getRequestContextProxyInterface();

            // �����û���ӽӿڵ�request context���󴴽�proxy������û�����塣
            if (!RequestContext.class.equals(requestContextProxyInterface)) {
View Full Code Here


    private void render(int type) throws Exception {
        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", "�й�");

            // ��Ⱦ
            switch (type) {
                case 1:
                    assertEquals("", templateService.getText("/test.jsp", context));
                    break;

                case 2:
                    templateService.writeTo("/test.jsp", context, (OutputStream) null);
                    break;

                case 3:
                    templateService.writeTo("/test.jsp", context, (Writer) null);
                    break;

                default:
                    fail();
                    break;
            }
        } finally {
            // �������ύresponse
            requestContexts.commitRequestContext(rc);
        }

        WebResponse webResponse = client.getResponse(ic);

        assertEquals("text/plain", webResponse.getContentType());
View Full Code Here

    private void render(int type, boolean jspx) throws Exception {
        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", "中国");

            String jsp = jspx ? "/test.jspx" : "/test.jsp";

            // 渲染
            switch (type) {
                case 1:
                    assertEquals("", templateService.getText(jsp, context));
                    break;

                case 2:
                    templateService.writeTo(jsp, context, (OutputStream) null);
                    break;

                case 3:
                    templateService.writeTo(jsp, context, (Writer) null);
                    break;

                default:
                    fail();
                    break;
            }
        } finally {
            // 结束并提交response
            requestContexts.commitRequestContext(rc);
        }

        WebResponse webResponse = client.getResponse(ic);

        assertEquals("text/plain", webResponse.getContentType());
View Full Code Here

    private void render(int type, boolean jspx) throws Exception {
        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", "中国");

            String jsp = jspx ? "/test.jspx" : "/test.jsp";

            // 渲染
            switch (type) {
                case 1:
                    assertEquals("", templateService.getText(jsp, context));
                    break;

                case 2:
                    templateService.writeTo(jsp, context, (OutputStream) null);
                    break;

                case 3:
                    templateService.writeTo(jsp, context, (Writer) null);
                    break;

                default:
                    fail();
                    break;
            }
        } finally {
            // 结束并提交response
            requestContexts.commitRequestContext(rc);
        }

        WebResponse webResponse = client.getResponse(ic);

        assertEquals("text/plain", webResponse.getContentType());
View Full Code Here

                createProxy(HttpServletResponse.class, beanFactory.getBeanClassLoader(),
                            new ResponseProxyTargetFactory()));

        // 取得requestContexts时会激活requestContexts的初始化。
        // 由于request/response/session已经被注册,因此已经可被注入到requestContexts的子对象中。
        RequestContextChainingService requestContexts = (RequestContextChainingService) beanFactory.getBean(
                requestContextsName, RequestContextChainingService.class);

        // 创建全局的request context实例。
        for (RequestContextInfo<?> info : requestContexts.getRequestContextInfos()) {
            Class<? extends RequestContext> requestContextInterface = info.getRequestContextInterface();
            Class<? extends RequestContext> requestContextProxyInterface = info.getRequestContextProxyInterface();

            // 避免对没有子接口的request context对象创建proxy,否则没有意义。
            if (!RequestContext.class.equals(requestContextProxyInterface)) {
View Full Code Here

                createProxy(HttpServletResponse.class, beanFactory.getBeanClassLoader(),
                        new ResponseProxyTargetFactory()));

        // ȡ��requestContextsʱ�ἤ��requestContexts�ij�ʼ����
        // ����request/response/session�Ѿ���ע�ᣬ����Ѿ��ɱ�ע�뵽requestContexts���Ӷ����С�
        RequestContextChainingService requestContexts = (RequestContextChainingService) beanFactory.getBean(
                requestContextsName, RequestContextChainingService.class);

        // ����ȫ�ֵ�request contextʵ����
        for (RequestContextInfo<?> info : requestContexts.getRequestContextInfos()) {
            Class<? extends RequestContext> requestContextInterface = info.getRequestContextInterface();
            Class<? extends RequestContext> requestContextProxyInterface = info.getRequestContextProxyInterface();

            // �����û���ӽӿڵ�request context���󴴽�proxy������û�����塣
            if (!RequestContext.class.equals(requestContextProxyInterface)) {
View Full Code Here

TOP

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

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.