Customizer for registering servlet at a HttpService
774826
private Dictionary<String,String> getConfiguration() {
        Dictionary<String,String> config = new Hashtable<String,String>();
        for (ConfigKey key : ConfigKey.values()) {
            String value = getConfiguration(key);
            if (value != null) {
                config.put(key.getKeyValue(),value);
            }
        }
        String jolokiaId = NetworkUtil.replaceExpression(config.get(ConfigKey.AGENT_ID.getKeyValue()));
        if (jolokiaId == null) {
            config.put(ConfigKey.AGENT_ID.getKeyValue(),
                       NetworkUtil.getAgentId(hashCode(),"osgi"));
        }
        config.put(ConfigKey.AGENT_TYPE.getKeyValue(),"osgi");
        return config;
    }
867960
private static Class registerTypeMapping(Class clazz) throws PageException {
	PageContext pc = ThreadLocalPageContext.get();
	WSServer server = ((ConfigImpl) ThreadLocalPageContext.getConfig(pc)).getWSHandler().getWSServer(pc);
	return registerTypeMapping(server, clazz);
    }
531739
public SC registerServlet(Class<? extends HttpServlet> servletClass, String urlPattern) {
        __throwIfInitialized();

        if (servletMap.containsKey(urlPattern) && servletMap.get(urlPattern) != servletClass)
            throw new IllegalArgumentException(String.format("URL pattern is already associated with another servlet class: %s => %s", urlPattern, servletMap.get(urlPattern)));

        servletMap.put(urlPattern, servletClass);
        return (SC) this;
    }
460810
public void addDynamicServlet(
		String servletName,
		String servletClass,
		String mappingURI,
		Properties initParameters)
		throws ServletException, SecurityException
	{
		context.addDynamicServlet(servletName, servletClass, mappingURI, initParameters);
	}
405138
public void register(String pattern, HttpRequestHandler handler) {
        registry.register(pattern, handler);
        registry.register(pattern + "/", handler);
    }
469509
@Override
	public void registerServlet(final String alias, final Servlet servlet,
								@SuppressWarnings("rawtypes") final Dictionary initParams,
								final HttpContext httpContext) throws ServletException,
			NamespaceException {
		synchronized (lock) {
			this.registerServlet(alias, servlet, initParams, null, null,
					httpContext);
		}
	}
278808
public void addServlet(final WebAppServlet servlet) {
		NullArgumentException.validateNotNull(servlet, "Servlet");
		NullArgumentException.validateNotNull(servlet.getServletName(),
				"Servlet name");
		if (servlet instanceof WebAppJspServlet) {
			NullArgumentException.validateNotNull(
					((WebAppJspServlet) servlet).getJspPath(), "JSP-path");
		} else {
			NullArgumentException.validateNotNull(
					servlet.getServletClassName(), "Servlet class");
		}
		servlets.put(servlet.getServletName(), servlet);
		// add aliases for servlet mappings added before servlet
		for (WebAppServletMapping mapping : getServletMappings(servlet
				.getServletName())) {
			servlet.addUrlPattern(mapping.getUrlPattern());
		}
	}
1312314
public ServerBuilder annotatedService(String pathPrefix, Object service,
                                          Function<Service<HttpRequest, HttpResponse>,
                                                  ? extends Service<HttpRequest, HttpResponse>> decorator,
                                          Iterable<?> exceptionHandlersAndConverters) {
        requireNonNull(pathPrefix, "pathPrefix");
        requireNonNull(service, "service");
        requireNonNull(decorator, "decorator");
        requireNonNull(exceptionHandlersAndConverters, "exceptionHandlersAndConverters");

        defaultVirtualHostBuilderUpdated();
        defaultVirtualHostBuilder.annotatedService(pathPrefix, service, decorator,
                                                   exceptionHandlersAndConverters);
        return this;
    }
529910
def service(req, res)
      if req.unparsed_uri == "*"
        if req.request_method == "OPTIONS"
          do_OPTIONS(req, res)
          raise HTTPStatus::OK
        end
        raise HTTPStatus::NotFound, "`#{req.unparsed_uri}' not found."
      end

      servlet, options, script_name, path_info = search_servlet(req.path)
      raise HTTPStatus::NotFound, "`#{req.path}' not found." unless servlet
      req.script_name = script_name
      req.path_info = path_info
      si = servlet.get_instance(self, *options)
      @logger.debug(format("%s is invoked.", si.class.name))
      si.service(req, res)
    end
275626
protected void dispatch(String pathInContext,
                            HttpServletRequest request,
                            HttpServletResponse response,
                            ServletHolder servletHolder, 
                            int type)
        throws ServletException, UnavailableException, IOException
    {
        if (type == Dispatcher.__REQUEST)
        {
            // This is NOT a dispatched request (it it is an initial request)
            ServletHttpRequest servletHttpRequest= (ServletHttpRequest)request;
            ServletHttpResponse servletHttpResponse= (ServletHttpResponse)response;  
            
            // protect web-inf and meta-inf
            if (StringUtil.startsWithIgnoreCase(pathInContext, "/web-inf") || StringUtil.startsWithIgnoreCase(pathInContext, "/meta-inf"))
            {
                response.sendError(HttpResponse.__404_Not_Found);
                return;
            }
            
            // Security Check
            if (!getHttpContext().checkSecurityConstraints(
                            pathInContext,
                            servletHttpRequest.getHttpRequest(),
                            servletHttpResponse.getHttpResponse()))
                return;
        }
        else
        {
            // This is a dispatched request.
            
            // Handle dispatch to j_security_check
            HttpContext context= getHttpContext();
            if (context != null
                    && context instanceof ServletHttpContext
                    && pathInContext != null
                    && pathInContext.endsWith(FormAuthenticator.__J_SECURITY_CHECK))
            {
                ServletHttpRequest servletHttpRequest=
                    (ServletHttpRequest)context.getHttpConnection().getRequest().getWrapper();
                ServletHttpResponse servletHttpResponse= servletHttpRequest.getServletHttpResponse();
                ServletHttpContext servletContext= (ServletHttpContext)context;
                
                if (!servletContext.jSecurityCheck(pathInContext,servletHttpRequest.getHttpRequest(),servletHttpResponse.getHttpResponse()))
                    return;
            }
        }
        
        // Build and/or cache filter chain
        FilterChain chain=null;
        if (pathInContext != null) {
            chain = getChainForPath(type, pathInContext, servletHolder);
        } else {
            chain = getChainForName(type, servletHolder);
        }

        if (log.isDebugEnabled()) log.debug("chain="+chain);
        
        // Do the handling thang
        if (chain!=null)
            chain.doFilter(request, response);
        else if (servletHolder != null)
            servletHolder.handle(request, response);    
        else // Not found
            notFound(request, response);
    }
682141
private AuthConfigProvider getAuthConfigProvider(String appContext) {
        AuthConfigProvider provider = null;
        AuthConfigFactory providerFactory = getAuthConfigFactory();
        if (providerFactory != null) {
            if (providerConfigModified &&
                providerFactory instanceof ProviderRegistry) {
                ((ProviderRegistry) providerFactory).setProvider(jaspiProviderServiceRef.getService());
                providerConfigModified = false;
            }
            provider = providerFactory.getConfigProvider("HttpServlet", appContext, (RegistrationListener) null);
        }
        return provider;
    }
105393
private function registerProviders ()
    {
        $this->register(new TwigServiceProvider());
        $this->register(new UrlGeneratorServiceProvider());
        $this->register(new ServiceControllerServiceProvider());
    }
1168187
public <T extends RESTDataProvider> void registerProvider(Class<T> providerClass, Class<?> providerInterface) {
        try {
            final Constructor<T> constructor = providerClass.getConstructor(RESTProviderFactory.class);
            final T instance = constructor.newInstance(this);

            providerMap.put(providerClass, instance);
            if (providerInterface != null) {
                providerMap.put(providerInterface, instance);
            }
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
819959
private void writeParamsToRegistryService(SessionProvider sessionProvider) throws IOException, SAXException,
      ParserConfigurationException, RepositoryException
   {

      Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      Element root = doc.createElement(SERVICE_NAME);
      doc.appendChild(root);

      Element element = doc.createElement(ADMIN_INDENTITY);
      setAttributeSmart(element, "value", adminIdentity);
      root.appendChild(element);

      element = doc.createElement(DEFAULT_INDENTITY);
      setAttributeSmart(element, "value", defaultIdentity);
      root.appendChild(element);

      RegistryEntry serviceEntry = new RegistryEntry(doc);
      registryService.createEntry(sessionProvider, RegistryService.EXO_SERVICES, serviceEntry);
   }
1154239
public ServletModule.ServletKeyBindingBuilder serve(List<String> urlPatterns) {
    return new ServletKeyBindingBuilderImpl(parsePatterns(UriPatternType.SERVLET, urlPatterns));
  }
796540
public HttpServlet initServlet() throws Exception {

		servlet = (HttpServlet) servletClass.newInstance();
		servlet.init(servletConfig);
		return servlet;
	}
1353357
protected function registerHorizonServiceProvider()
    {
        $namespace = Str::replaceLast('\\', '', $this->getAppNamespace());

        $appConfig = file_get_contents(config_path('app.php'));

        if (Str::contains($appConfig, $namespace.'\\Providers\\HorizonServiceProvider::class')) {
            return;
        }

        file_put_contents(config_path('app.php'), str_replace(
            "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL,
            "{$namespace}\\Providers\EventServiceProvider::class,".PHP_EOL."        {$namespace}\Providers\HorizonServiceProvider::class,".PHP_EOL,
            $appConfig
        ));

        file_put_contents(app_path('Providers/HorizonServiceProvider.php'), str_replace(
            "namespace App\Providers;",
            "namespace {$namespace}\Providers;",
            file_get_contents(app_path('Providers/HorizonServiceProvider.php'))
        ));
    }