Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            ServletWorkerRequest wr             = (ServletWorkerRequest)((IServiceProvider)context).GetService(typeof(HttpWorkerRequest));
            ServletContext       servletContext = wr.GetContext();
            HttpServletRequest   request        = wr.ServletRequest;
            HttpServletResponse  response       = wr.ServletResponse;

            ServletFacesContext facesContext = GetFacesContext(_facesContextFactory, servletContext, request, response, _lifecycle, context, _executionFilePath);

            try {
                try {
                    try {
                        Trace.WriteLine("FacesPageHandler: before execute");
                        _lifecycle.execute(facesContext);
                        Trace.WriteLine("FacesPageHandler: after execute");
                    }
                    finally {
                        UIViewRoot viewRoot = facesContext.getViewRoot();
                        if (viewRoot != null && viewRoot.getChildCount() > 0)
                        {
                            _page = (Page)viewRoot.getChildren().get(0);
                        }
                    }
                    Trace.WriteLine("FacesPageHandler: before render");
                    SetupResponseWriter(facesContext, response.getContentType(), response.getCharacterEncoding());
                    _lifecycle.render(facesContext);
                    Trace.WriteLine("FacesPageHandler: after render");
                }
                catch (FacesException fex) {
                    Exception inner = fex.InnerException;
                    if (inner != null)
                    {
                        TypeUtils.Throw(inner);
                    }
                    throw;
                }
            }
            finally {
                facesContext.release();
            }
        }
Exemplo n.º 2
0
		protected override void service (HttpServletRequest req, HttpServletResponse resp)
		{
			const string assemblies = "/assemblies";
			const string getping = "getping";
			const string setping = "setping";
            const string version = "2.2";
			string servletPath = req.getServletPath ();

			if (String.CompareOrdinal (assemblies, 0, servletPath, 0, assemblies.Length) == 0) {
				if (servletPath.Length == assemblies.Length ||
						servletPath [assemblies.Length] == '/') {
					string requestURI = req.getRequestURI ();
					bool getp = requestURI.EndsWith (getping, StringComparison.Ordinal);
					if (!getp && requestURI.EndsWith (setping, StringComparison.Ordinal)) {
                        getServletContext().setAttribute(getping, version);
						getp = true;
					}

					if (getp) {
						string ping = (string) getServletContext ().getAttribute (getping);
						if (ping == null)
							ping = "0";
						resp.getOutputStream ().print (ping);
						return;
					}
				}
			}
			resp.setContentType ("text/html");

			try 
			{
				// Very important - to update Virtual Path!!!
				AppDomain servletDomain = (AppDomain)this.getServletContext().getAttribute(J2EEConsts.APP_DOMAIN);
				if (!_appVirDirInited) {
					string appVPath = req.getContextPath ();
					if (appVPath == null || appVPath.Length == 0)
						appVPath = "/";
					servletDomain.SetData (IAppDomainConfig.APP_VIRT_DIR, appVPath);
					servletDomain.SetData (".hostingVirtualPath", req.getContextPath ());
					_appVirDirInited = true;
				}

				// Put to the TLS current AppDomain of the servlet, so anyone can use it.
				[email protected](servletDomain);

				// put request to the TLS
				//Thread.SetData(_servletRequestSlot, req);
				//// put response to the TLS
				//Thread.SetData(_servletResponseSlot, resp);
				//// put the servlet object to the TLS
				//Thread.SetData(_servletSlot, this);

				resp.setHeader("X-Powered-By", "ASP.NET");
				resp.setHeader("X-AspNet-Version", "1.1.4322");

				HttpWorkerRequest gwr = new ServletWorkerRequest (this, req, resp);
				CultureInfo culture = (CultureInfo) [email protected] (req.getLocale ());
				Thread currentTread = Thread.CurrentThread;
				currentTread.CurrentCulture = culture;
				currentTread.CurrentUICulture = culture;
				HttpRuntime.ProcessRequest(gwr);
			}
			finally 
			{
				HttpContext.Current = null;
				//Thread.SetData(_servletRequestSlot, null);
				//Thread.SetData(_servletResponseSlot, null);
				//Thread.SetData(_servletSlot, null);
				[email protected]();
			}
		}
Exemplo n.º 3
0
        protected override void service(HttpServletRequest req, HttpServletResponse resp)
        {
            const string assemblies  = "/assemblies";
            const string getping     = "getping";
            const string setping     = "setping";
            const string version     = "2.2";
            string       servletPath = req.getServletPath();

            if (String.CompareOrdinal(assemblies, 0, servletPath, 0, assemblies.Length) == 0)
            {
                if (servletPath.Length == assemblies.Length ||
                    servletPath [assemblies.Length] == '/')
                {
                    string requestURI = req.getRequestURI();
                    bool   getp       = requestURI.EndsWith(getping, StringComparison.Ordinal);
                    if (!getp && requestURI.EndsWith(setping, StringComparison.Ordinal))
                    {
                        getServletContext().setAttribute(getping, version);
                        getp = true;
                    }

                    if (getp)
                    {
                        string ping = (string)getServletContext().getAttribute(getping);
                        if (ping == null)
                        {
                            ping = "0";
                        }
                        resp.getOutputStream().print(ping);
                        return;
                    }
                }
            }
            resp.setContentType("text/html");

            try
            {
                // Very important - to update Virtual Path!!!
                AppDomain servletDomain = (AppDomain)this.getServletContext().getAttribute(J2EEConsts.APP_DOMAIN);
                if (!_appVirDirInited)
                {
                    string appVPath = req.getContextPath();
                    if (appVPath == null || appVPath.Length == 0)
                    {
                        appVPath = "/";
                    }
                    servletDomain.SetData(IAppDomainConfig.APP_VIRT_DIR, appVPath);
                    servletDomain.SetData(".hostingVirtualPath", req.getContextPath());
                    _appVirDirInited = true;
                }

                // Put to the TLS current AppDomain of the servlet, so anyone can use it.
                [email protected](servletDomain);

                // put request to the TLS
                //Thread.SetData(_servletRequestSlot, req);
                //// put response to the TLS
                //Thread.SetData(_servletResponseSlot, resp);
                //// put the servlet object to the TLS
                //Thread.SetData(_servletSlot, this);

                resp.setHeader("X-Powered-By", "ASP.NET");
                resp.setHeader("X-AspNet-Version", "1.1.4322");

                HttpWorkerRequest gwr          = new ServletWorkerRequest(this, req, resp);
                CultureInfo       culture      = (CultureInfo)[email protected](req.getLocale());
                Thread            currentTread = Thread.CurrentThread;
                currentTread.CurrentCulture   = culture;
                currentTread.CurrentUICulture = culture;
                HttpRuntime.ProcessRequest(gwr);
            }
            finally
            {
                HttpContext.Current = null;
                //Thread.SetData(_servletRequestSlot, null);
                //Thread.SetData(_servletResponseSlot, null);
                //Thread.SetData(_servletSlot, null);
                [email protected]();
            }
        }