Start the SRE without an agent. This function prepare the default context.

@return the context that is created by the bootstrap. If {@code null} there is no context created.
@since 2.0.7.0
354589
public static Kernel startWithoutAgent() {
		final Class<? extends Module> startupModule = JanusConfig.getSystemPropertyAsClass(Module.class,
				JanusConfig.INJECTION_MODULE_NAME,
				JanusConfig.INJECTION_MODULE_NAME_VALUE);
		assert startupModule != null : "No platform injection module"; //$NON-NLS-1$
		try {
			return startWithoutAgent(startupModule.newInstance());
		} catch (Exception exception) {
			throw new IllegalStateException(exception);
		}
	}
800949
public Object startupService(BundleContext bundleContext)
    {
        try {
            Environment env = (Environment)this.getService(Env.class);
            // Note the order that I do this... this is because MainApplication may need access to the remoteapp during initialization
            Map<String, Object> properties = getServiceProperties();
            properties = Utility.putAllIfNew(properties, env.getProperties());  // Use the same params as environment
            App app = env.getMessageApplication(true, properties);
//            app.setProperty(DBParams.JMSSERVER, DBConstants.TRUE);
//            app.getMessageManager(true);
            return new RemoteSessionServer(app, null, properties);	// Doesn't create environment
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    	return null;
    }
71421
@Override
    protected BaseContext createContext() {
        AppContextImpl context = getAppContext();
        RoomContextImpl answer = new RoomContextImpl();
        answer.init(context, getClass());
        return answer;
    }
1307953
private WebApplicationContext prepareRootApplicationContext() throws IOException {

        if (logger.isInfoEnabled()) {
            logger.info("[init/rootContext] starting ...");
        }

        ApplicationContext oldRootContext = (ApplicationContext) getServletContext().getAttribute(
                ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);

        // 如果web.xml配置使用了spring装载root应用context ...... 不可以
        // roseFilter可能因为启动失败，在请求的时候容器还会尝试重新启动，此时rootContext可能已经存在，不要简单地抛出异常
        // 同时这样留出了使用Listener作为init rose context的扩展机会
        if (oldRootContext != null) {
            if (oldRootContext.getClass() != RoseWebAppContext.class) {
                throw new IllegalStateException(
                        "Cannot initialize context because there is already a root application context present - "
                                + "check whether you have multiple ContextLoader* definitions in your web.xml!");
            }
            if (logger.isInfoEnabled()) {
                logger.info("[init/rootContext] the root context exists:" + oldRootContext);
            }
            return (RoseWebAppContext) oldRootContext;
        }

        RoseWebAppContext rootContext = new RoseWebAppContext(getServletContext(), load, false);

        String contextConfigLocation = this.contextConfigLocation;
        // 确认所使用的applicationContext配置
        if (StringUtils.isBlank(contextConfigLocation)) {
            String webxmlContextConfigLocation = getServletContext().getInitParameter(
                    "contextConfigLocation");
            if (StringUtils.isBlank(webxmlContextConfigLocation)) {
                contextConfigLocation = RoseWebAppContext.DEFAULT_CONFIG_LOCATION;
            } else {
                contextConfigLocation = webxmlContextConfigLocation;
            }
        }
        rootContext.setConfigLocation(contextConfigLocation);
        rootContext.setId("rose.root");
        
        rootContext.refresh();

        if (logger.isInfoEnabled()) {
            logger.info("[init/rootContext] exits");
        }

        /* enable: WebApplicationContextUtils.getWebApplicationContext() */
        getServletContext().setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);

        if (logger.isInfoEnabled()) {
            logger.info("[init/rootContext] Published rose.root WebApplicationContext ["
                    + rootContext + "] as ServletContext attribute with name ["
                    + ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]");
        }

        return rootContext;
    }
210427
@Override
    public void start(StartContext context) throws StartException {
        Set<KeytabService> services = keytabServices.getValue();

        hostServiceMap = new HashMap<String, KeytabService>(services.size()); // Assume at least one per service.
        /*
         * Iterate the services and find the first one to offer default resolution, also create a hostname to KeytabService map
         * for the first one that claims each host.
         */
        for (KeytabService current : services) {
            for (String currentHost : current.getForHosts()) {
                if ("*".equals(currentHost)) {
                    if (defaultService == null) {
                        defaultService = current;
                    }
                } else if (currentHost != null) {
                    int idx = currentHost.indexOf("/");
                    String hostKey = idx > -1 ? currentHost.substring(0, idx) + "/" + currentHost.substring(idx + 1).toLowerCase(Locale.ENGLISH) :
                        currentHost.toLowerCase(Locale.ENGLISH);
                    if (hostServiceMap.containsKey(hostKey) == false) {
                        hostServiceMap.put(hostKey, current);
                    }
                }
            }
        }

        /*
         * Iterate the services again and attempt to identify host names from the principal name and add to the map if there is
         * not already a mapping for that host name.
         */
        for (KeytabService current : services) {
            String principal = current.getPrincipal();
            int start = principal.indexOf('/');
            int end = principal.indexOf('@');

            String currentHost = principal.substring(start > -1 ? start + 1 : 0, end > -1 ? end : principal.length() - 1);
            if (hostServiceMap.containsKey(currentHost.toLowerCase(Locale.ENGLISH)) == false) {
                hostServiceMap.put(currentHost.toLowerCase(Locale.ENGLISH), current);
            }
            principal = principal.substring(0, end > -1 ? end : principal.length() - 1);
            if (principal.equals(currentHost) == false) {
                String principalKey = principal.substring(0, start) + "/" + currentHost.toLowerCase(Locale.ENGLISH);
                if (hostServiceMap.containsKey(principalKey) == false) {
                    hostServiceMap.put(principalKey, current);
                }
            }
        }
    }
140697
protected static void init(ServletContext context) {
		TimeInterval interval = new TimeInterval();
		
		servletContext = context;
		contextPath = context.getContextPath();
		handler = new ActionHandler(HuluSetting.actionPackages);
		
		String startMsg = null;
		try {
			startMsg = FileUtil.readUtf8String("startup.txt");
		} catch (IORuntimeException e) {
			Throwable cause = e.getCause();
			if(null != cause){
				if(cause instanceof FileNotFoundException){
					log.debug("No file [startup.txt] in classpath, use default start messsage.");
				}else{
					log.warn("Read [startup.txt] error, cause by: {}", cause.getMessage());
				}
			}else{
				log.warn("Read [startup.txt] error, cause by: {}", e.getMessage());
			}
		}
		
		if(StrUtil.isNotBlank(startMsg)){
			Dict param = Dict.create().set("spend", interval.intervalMs()).set("contextPath", contextPath);
			log.info(StrUtil.format("\n" + startMsg, param));
		}else{
			log.info("\n***** Hulu framwork init finished, context path: [{}], spend {}ms *****", contextPath, interval.intervalMs());
		}
	}
839618
protected Context createContext() throws NamingException
   {
      Properties properties = new Properties();
      properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
      properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      properties.setProperty(Context.PROVIDER_URL, jndiProtocol + "://" + jndiHost + ":" + jndiPort);
      return new InitialContext(properties);
   }
1283190
public static Context getOrCreate(NetworkParameters params) {
        Context context;
        try {
            context = get();
        } catch (IllegalStateException e) {
            log.warn("Implicitly creating context. This is a migration step and this message will eventually go away.");
            context = new Context(params);
            return context;
        }
        if (context.getParams() != params)
            throw new IllegalStateException("Context does not match implicit network params: " + context.getParams() + " vs " + params);
        return context;
    }
543593
public static RpcInternalContext getContext() {
        RpcInternalContext context = LOCAL.get();
        if (context == null) {
            context = new RpcInternalContext();
            LOCAL.set(context);
        }
        return context;
    }
785951
public static SenBotContext getSenBotContext() {
        if (senBotContextSingleton == null) {
            //synchronize instantiation
            synchronized (SenBotContext.class) {
                //another null check as two threads might have passed the first null check, wait in line on the 
                //synchronized block and both instantiate the singleton.
                if (senBotContextSingleton == null) {
                	String springConfigLocation = System.getProperty(SPRING_CONFIG_LOCATION);
                	if(springConfigLocation == null) {
                		springConfigLocation = "classpath*:cucumber.xml";
                	}
                	
                    context = new ClassPathXmlApplicationContext(new String[]{springConfigLocation});
                    senBotContextSingleton = context.getBean(SenBotContext.class);
                }
            }
        }
        return senBotContextSingleton;
    }
718587
protected void initialiseApplicationContext() {
        if (context != null) {
            return;
        }

        context = createApplicationContext(parent);

        if (parent != null && classLoader == null) {
            trySettingClassLoaderOnContextIfFoundInParent(parent);
        }
        else if (classLoader != null) {
            setClassLoaderOnContext(classLoader);
        }

        Assert.notNull(context, "ApplicationContext cannot be null");
    }
26233
@Override
  public List<ConfigIssue> init(Service.Context context) {
    this.context = context;
    return init();
  }
354519
@NonNull public Context getContext() {
        if (searchView != null) {
            return searchView.getContext();
        } else if (supportView != null) {
            return supportView.getContext();
        }
        throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
    }
1023738
public void start() throws ContextClientCodeException {
    synchronized (this.contextStack) {
      LOG.log(Level.FINEST, "Instantiating root context.");
      this.contextStack.push(this.launchContext.get().getRootContext());

      if (this.launchContext.get().getInitialTaskConfiguration().isPresent()) {
        LOG.log(Level.FINEST, "Launching the initial Task");
        try {
          this.contextStack.peek().startTask(this.launchContext.get().getInitialTaskConfiguration().get());
        } catch (final TaskClientCodeException e) {
          this.handleTaskException(e);
        }
      }
    }
  }
1157884
public Context getContext() {
		if (context == null) {
			context = Model.getSingleton().getSession().getContext(this.contextId);
		}
		return context;
	}
764733
Object getServletContextForCurrentClassLoader() {
        Object result;
        FactoryManagerCacheKey key = new FactoryManagerCacheKey(null, getClassLoader(), applicationMap);
        result = key.getContext();
        
        return result;
    }
927975
public Context getSelectedContext() {
		SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
		if (node == null || node.isRoot()) {
			return null;
		}
		Target target = (Target) node.getUserObject();
		if (target != null) {
			return target.getContext();
		}
		return null;
	}