Create the service tracker.
@param context
@param httpContext
@param dictionary
@return
348481
public HttpServiceTracker createServiceTracker(BundleContext context, HttpContext httpContext, Dictionary<String, String> dictionary)
    {
        if (httpContext == null)
            httpContext = getHttpContext();
        return new HttpServiceTracker(context, httpContext, dictionary);
    }
185840
public static Function<Service<HttpRequest, HttpResponse>, HttpTracingService>
    newDecorator(Tracing tracing) {
        ensureScopeUsesRequestContext(tracing);
        return service -> new HttpTracingService(service, tracing);
    }
981878
@NonNull public Context createContext(@NonNull Object key, @NonNull Context baseContext) {
    return new FlowContextWrapper(keyManager.findServices(key), baseContext);
  }
173188
public static void storeTracerInfo(ClientRequestContext requestContext) {

        // tracer信息放入request 发到服务端
        SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
        SofaTracerSpan clientSpan = sofaTraceContext.getCurrentSpan();
        RpcInternalContext context = RpcInternalContext.getContext();
        if (clientSpan != null) {
            requestContext.getHeaders().add(RemotingConstants.NEW_RPC_TRACE_NAME,
                clientSpan.getSofaTracerSpanContext().serializeSpanContext());
        }
        // 客户端发送自己的应用名
        String appName = (String) context.getAttachment(INTERNAL_KEY_APP_NAME);
        if (appName != null) {
            requestContext.getHeaders().add(RemotingConstants.HEAD_APP_NAME, appName);
        }
    }
37488
protected RequestStat createRequestStat() {
        BasicRequestStat basicRequestStat = new BasicRequestStat(origin.getName());
        RequestStat.putInSessionContext(basicRequestStat, context);
        return basicRequestStat;
    }
107479
private void createManagedServiceFactory(BundleContext context) {
		// sanity check
		if (managedServiceFactoryReg != null) {
			managedServiceFactoryReg.unregister();
			managedServiceFactoryReg = null;
		}
		final Dictionary<String, String> props = new Hashtable<>();
		props.put(Constants.SERVICE_PID, HttpContextProcessing.PID);
		httpContextProcessing = new HttpContextProcessing(bundleContext, serverController);
		managedServiceFactoryReg = context.registerService(ManagedServiceFactory.class, httpContextProcessing, props);
	}
56518
public static WebApplicationService getService(final RequestContext context) {
        return context != null ? (WebApplicationService) context.getFlowScope().get(PARAMETER_SERVICE) : null;
    }
1250056
public Object createContext(ApplicationRequest request,
                                ApplicationResponse response) {
        
        return new CookieContext(
            request, response, mDomain, mPath, mIsSecure);
    }
797381
public static RequestQueue newRequestQueue(Context context) {
		HttpStack stack;
		if (Build.VERSION.SDK_INT >= 9) {
			stack = new HurlStack();
		} else {
			stack = new HttpClientStack(AndroidHttpClient.newInstance("volley"));
		}
		return newRequestQueue(context, stack);
	}
1025820
public static WebApplicationService getService(final List<ArgumentExtractor> argumentExtractors, final RequestContext context) {
        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        return HttpRequestUtils.getService(argumentExtractors, request);
    }
1075171
private ApiResponse buildResponseFromContext(Context c) {
		Map<String, String> fields = new HashMap<>();
		fields.put("name", c.getName());
		fields.put("id", Integer.toString(c.getIndex()));
		fields.put("description", c.getDescription());
		fields.put("inScope", Boolean.toString(c.isInScope()));
		fields.put("excludeRegexs", jsonEncodeList(c.getExcludeFromContextRegexs()));
		fields.put("includeRegexs", jsonEncodeList(c.getIncludeInContextRegexs()));
		
		AuthenticationMethod authenticationMethod = c.getAuthenticationMethod();
		if(authenticationMethod != null){
			Pattern pattern = authenticationMethod.getLoggedInIndicatorPattern();
			fields.put("loggedInPattern",  pattern == null ? "" : pattern.toString());
			pattern = authenticationMethod.getLoggedOutIndicatorPattern();
			fields.put("loggedOutPattern", pattern == null ? "" : pattern.toString());
			AuthenticationMethodType type = authenticationMethod.getType();
			fields.put("authType", type == null ? "" : type.getName());
		}
		
		AuthorizationDetectionMethod authorizationDetectionMethod = c.getAuthorizationDetectionMethod();
		if(authorizationDetectionMethod != null){
			fields.put("authenticationDetectionMethodId",String.valueOf(authorizationDetectionMethod.getMethodUniqueIdentifier()));
		}
		
		fields.put("urlParameterParserClass", c.getUrlParamParser().getClass().getCanonicalName());
		fields.put("urlParameterParserConfig", c.getUrlParamParser().getConfig());
		fields.put("postParameterParserClass", c.getPostParamParser().getClass().getCanonicalName());
		fields.put("postParameterParserConfig", c.getPostParamParser().getConfig());
		
		return new ApiResponseSet<String>("context", fields);
	}
181614
public Servlet makeServlet(String alias, Dictionary<String, String> dictionary)
    {
        String servletClass = dictionary.get(BundleConstants.SERVICE_CLASS);
        return (Servlet)ClassServiceUtility.getClassService().makeObjectFromClassName(servletClass);        
    }
1240544
public void initialize(HttpContext context)
    {
        SessionManager sessionManager=getSessionManager();
        

        if (_httpContext!=null&& _httpContext!=context)
            throw new IllegalStateException("Can't initialize handler for different context");
        _httpContext=context;
        
        sessionManager.initialize(this);
    }
79805
protected HttpClientContext createHttpContext(InternalRequest request) {
        HttpClientContext context = HttpClientContext.create();
        context.setRequestConfig(this.requestConfigBuilder.setExpectContinueEnabled(request.isExpectContinueEnabled())
                .build());
        if (this.credentialsProvider != null) {
            context.setCredentialsProvider(this.credentialsProvider);
        }
        if (this.config.isProxyPreemptiveAuthenticationEnabled()) {
            AuthCache authCache = new BasicAuthCache();
            authCache.put(this.proxyHttpHost, new BasicScheme());
            context.setAuthCache(authCache);
        }
        return context;
    }
405433
public ServiceTracker makeServletTracker(String alias, Dictionary<String, String> properties)
    {

//?        dictionary.put(HttpServiceTracker.SERVICE_PID, getServicePid(context));
//?        dictionary.put(HttpServiceTracker.SERVLET_CLASS, getServletClass(context));
        properties.put(BaseWebappServlet.ALIAS, alias); 
        
        Servlet servlet = null;
        HttpContext httpContext = null;
        HttpServiceTracker serviceTracker = null; 
        try {
            String servicePid = DBConstants.BLANK;

            if ((BaseServlet.IMAGES.equalsIgnoreCase(alias)) 
                    || (BaseServlet.LIB.equalsIgnoreCase(alias))
                    || (BaseServlet.COM.equalsIgnoreCase(alias))
                    || (BaseServlet.ORG.equalsIgnoreCase(alias))
                    || (BaseServlet.DOCS.equalsIgnoreCase(alias)))
            {
                serviceTracker = new ResourceHttpServiceTracker(context, httpContext, properties);
            }
            if (BaseServlet.FAVICON.equalsIgnoreCase(alias))
            {
                servlet = new BaseOsgiServlet();
                properties.put(BaseOsgiServlet.BASE_PATH, BaseServlet.JBUNDLE_RESOURCES + "/images/icons/");    // Prepend this to the path
                ((BaseWebappServlet)servlet).init(context, servicePid, properties);
                httpContext = new org.jbundle.util.webapp.base.FileHttpContext(servlet, context.getBundle());
            }
            if ((BaseServlet.JBUNDLE_RESOURCES.equalsIgnoreCase(alias)) 
                || (BaseServlet.TOURGEEK_RESOURCES.equalsIgnoreCase(alias)))
            {
                servlet = new BaseOsgiServlet();
                properties.put(BaseOsgiServlet.BASE_PATH, alias + '/');    // Prepend this to the path
                ((BaseWebappServlet)servlet).init(context, servicePid, properties);
                httpContext = new org.jbundle.util.webapp.base.FileHttpContext(servlet, context.getBundle());
            }
            if (BaseServlet.PROXY.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.remote.proxy.ProxyServlet();
                properties.put("remotehost", "localhost");  // Default value
            }
            if ((BaseServlet.TABLE.equalsIgnoreCase(alias)) 
                    || (BaseServlet.IMAGE.equalsIgnoreCase(alias))
                    || (BaseServlet.JNLP.equalsIgnoreCase(alias))
                    || (BaseServlet.WSDL.equalsIgnoreCase(alias))
                    || (BaseServlet.TOURGEEK_WSDL.equalsIgnoreCase(alias))
                    || (BaseServlet.HTML.equalsIgnoreCase(alias))
                    || (BaseServlet.HTML2.equalsIgnoreCase(alias))
                    || (BaseServlet.TOURGEEK_JNLP.equalsIgnoreCase(alias))
                    || (BaseServlet.TOURGEEK.equalsIgnoreCase(alias)))
            {
                servlet = new org.jbundle.base.screen.control.servlet.html.HTMLServlet();
                properties.put("remotehost", "localhost");  // Default value
            }
            if (BaseServlet.XML.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.screen.control.servlet.xml.XMLServlet();
//x             dictionary.put("stylesheet-path", "org/jbundle/res/docs/styles/xsl/flat/base/");    // Since stylesheets are in resources
                properties.put("remotehost", "localhost");
            }
            if ((BaseServlet.XSL.equalsIgnoreCase(alias)) 
                || (BaseServlet.XHTML.equalsIgnoreCase(alias)))
            {
                servlet = new org.jbundle.base.screen.control.xslservlet.XSLServlet();
                properties.put("remotehost", "localhost");
            }
            if (BaseServlet.JNLP_DOWNLOAD.equalsIgnoreCase(alias))
            {
              servlet = new jnlp.sample.servlet.JnlpDownloadServlet();
              httpContext = new JnlpHttpContext(context.getBundle());
            }
            if (BaseServlet.AJAX.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.remote.proxy.AjaxServlet();
                properties.put("remotehost", "localhost");
                properties.put("stylesheet-path", "org/jbundle/res/docs/styles/xsl/flat/base/");    // Since webkit still can't handle import
            }
            if ((BaseServlet.ROOT.equalsIgnoreCase(alias)) 
                    || (BaseServlet.INDEX.equalsIgnoreCase(alias)))
            {
                // This redirects a www request to /demo/index.html
                properties.put("regex", "www.+.tourgeek.com");
                properties.put("regexTarget", "demo/index.html");
                // This redirects non-matching requests to the proper servlet
                properties.put(BaseWebappServlet.IE, BaseServlet.XSL);
                properties.put(BaseWebappServlet.FIREFOX, BaseServlet.XSL);
                //properties.put("chrome", "appxsl");
                //properties.put("safari", "appxsl");
                properties.put(BaseWebappServlet.WEBKIT, BaseServlet.XSL);
                properties.put(BaseWebappServlet.MOBILE, BaseServlet.XHTML);
                properties.put(BaseWebappServlet.JAVA, BaseServlet.XHTML);
                servlet = new org.jbundle.util.webapp.redirect.RegexRedirectServlet();
            }
            if (BaseServlet.MESSAGE.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.screen.control.servlet.message.trx.transport.html.MessageServlet();
                properties.put("remotehost", "localhost");
            }
            if (BaseServlet.WS.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.message.trx.transport.jaxm.MessageReceivingServlet();
                properties.put("remotehost", "localhost");
            }
            if (BaseServlet.XMLWS.equalsIgnoreCase(alias))
            {
                servlet = new org.jbundle.base.screen.control.servlet.message.trx.transport.xml.XMLMessageReceivingServlet();
                properties.put("remotehost", "localhost");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (httpContext == null)   
            httpContext = this.getHttpContext();
        if (serviceTracker == null)
            serviceTracker = this.createServiceTracker(context, httpContext, properties);
        serviceTracker.setServlet(servlet);
        return serviceTracker;
    }
909811
@Override
    public Object createContext(ApplicationRequest request,
                                ApplicationResponse response) {
    	mLog.debug("Creating DirectoryBrowserContext...");
        return new DirectoryBrowserContext(request, response, this);
    }
1182779
public static Tracing getTracing(String serviceName, CurrentTraceContext context) {
        Tracing tracing = Tracing.current();
        if (tracing == null) {
            // TODO reporter based on prop/config
            tracing = getBuilder(serviceName, context).build();
        }
        return tracing;
    }