/// <summary> /// Create a handler instance for the given URL. /// </summary> /// <param name="appContext">the application context corresponding to the current request</param> /// <param name="context">The <see cref="HttpContext"/> instance for this request.</param> /// <param name="requestType">The HTTP data transfer method (GET, POST, ...)</param> /// <param name="rawUrl">The requested <see cref="HttpRequest.RawUrl"/>.</param> /// <param name="physicalPath">The physical path of the requested resource.</param> /// <returns>A handler instance for the current request.</returns> protected override IHttpHandler CreateHandlerInstance(IConfigurableApplicationContext appContext, HttpContext context, string requestType, string rawUrl, string physicalPath) { IHttpHandler handler; string appRelativeVirtualPath = WebUtils.GetAppRelativePath(rawUrl); NamedObjectDefinition namedPageDefinition = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory); if (namedPageDefinition != null) { // is this a nested call (HttpServerUtility.Transfer() or HttpServerUtility.Execute())? if (context.Handler != null) { // all deps can/must be resolved now handler = (IHttpHandler)appContext.GetObject(namedPageDefinition.Name, typeof(IHttpHandler), null); } else { // execution pipeline "entry-point" - create page instance only // and defer configuration to PreRequestHandlerExecute step handler = (IHttpHandler)appContext.CreateObject(namedPageDefinition.Name, typeof(IHttpHandler), null); WebSupportModule.ConfigureHandler(context, handler, appContext, namedPageDefinition.Name, true); } } else { handler = WebObjectUtils.CreateHandler(rawUrl); // let WebSupportModule handle configuration handler = WebSupportModule.ConfigureHandler(context, handler, appContext, rawUrl, false); } return(handler); }
/// <summary> /// Create a handler instance for the given URL. /// </summary> /// <param name="appContext">the application context corresponding to the current request</param> /// <param name="context">The <see cref="HttpContext"/> instance for this request.</param> /// <param name="requestType">The HTTP data transfer method (GET, POST, ...)</param> /// <param name="rawUrl">The requested <see cref="HttpRequest.RawUrl"/>.</param> /// <param name="physicalPath">The physical path of the requested resource.</param> /// <returns>A handler instance for processing the current request.</returns> protected override IHttpHandler CreateHandlerInstance(IConfigurableApplicationContext appContext, HttpContext context, string requestType, string rawUrl, string physicalPath) { IHttpHandler handler = _innerFactory.GetHandler(context, requestType, rawUrl, physicalPath); // find a matching object definition string appRelativeVirtualPath = WebUtils.GetAppRelativePath(rawUrl); NamedObjectDefinition nod = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory); string objectDefinitionName = (nod != null) ? nod.Name : rawUrl; handler = WebSupportModule.ConfigureHandler(context, handler, appContext, objectDefinitionName, (nod != null)); return(handler); }
/// <summary> /// Retrieves an instance of the <see cref="System.Web.IHttpHandler"/> /// implementation for handling web service requests /// for both Spring and ASP.NET AJAX 1.0 web services. /// </summary> /// <param name="context">The current HTTP context.</param> /// <param name="requestType">The type of HTTP request (GET or POST).</param> /// <param name="url">The url of the web service.</param> /// <param name="pathTranslated">The physical application path for the web service.</param> /// <returns>The web service handler object.</returns> public override IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated) { string filename = VirtualPathUtility.ToAbsolute(context.Request.FilePath); string cacheKey = (string)webServiceData_GetCacheKey.Invoke(null, new object[] { filename }); object webServiceData = context.Cache.Get(cacheKey); if (webServiceData == null) { IConfigurableApplicationContext appContext = base.GetCheckedApplicationContext(url); string appRelativeVirtualPath = WebUtils.GetAppRelativePath(url); NamedObjectDefinition nod = FindWebObjectDefinition(appRelativeVirtualPath, appContext.ObjectFactory); if (nod != null) { Type serviceType = null; if (appContext.IsTypeMatch(nod.Name, typeof(WebServiceExporter))) { WebServiceExporter wse = (WebServiceExporter)appContext.GetObject(nod.Name); serviceType = wse.GetExportedType(); } else { serviceType = appContext.GetType(nod.Name); } object[] attrs = serviceType.GetCustomAttributes(typeof(ScriptServiceAttribute), false); if (attrs.Length > 0) { webServiceData = webServiceData_ctor.Invoke(new object[] { serviceType, false }); context.Cache.Insert(cacheKey, webServiceData); } } } return(this.scriptHandlerFactory.GetHandler(context, requestType, url, pathTranslated)); }