/*
(non-Javadoc)

@see
com.ibm.wsspi.webcontainer.servlet.IServletContext#startEnvSetup(boolean)
760961
public void startEnvSetup(boolean transactional) throws Exception {
        // set classloader
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME, "startEnvSetup", "enter");
        }
        ClassLoader origCl = ThreadContextHelper.getContextClassLoader();
        final ClassLoader warClassLoader = getClassLoaderInternal();
        if (warClassLoader != origCl) {
            ThreadContextHelper.setClassLoader(warClassLoader);
        } else {
            origCl = null;
        }
        // createCollaboratorHelper();
        webAppNameSpaceCollab.preInvoke(getModuleMetaData().getCollaboratorComponentMetaData());

        // transaction preinvoke
        Object tx = null;
        if (transactional) {
            tx = txCollab.preInvoke(null, this.isServlet23);
        }
        UnsynchronizedStack envObjectStack = (UnsynchronizedStack) envObject.get();
        if (envObjectStack == null) {
            envObjectStack = new UnsynchronizedStack();
            envObject.set(envObjectStack);
        }
        envObjectStack.push(new EnvObject(origCl, tx));
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME, "startEnvSetup", "exit");
        }
    }
883554
public void start(String[] args)
    {
        ArrayList al=new ArrayList();
        for(int i=0;i<args.length;i++)
        {
            if(args[i]==null)
                continue;
            if(args[i].startsWith("-"))
            {
                System.err.println("Usage: java [-DDEBUG] [-DSTART=start.config] [-Dmain.class=org.MyMain] -jar start.jar [--help] [config ...]");
                System.exit(1);
            }
            else
                al.add(args[i]);
        }
        args=(String[])al.toArray(new String[al.size()]);
        // set up classpath:
        InputStream cpcfg = null;
        try
        {
            Monitor.monitor();
            
            cpcfg=getClass().getClassLoader().getResourceAsStream(_config);
            if(_debug)
                System.err.println("config="+_config);
            if(cpcfg==null)
                cpcfg=new FileInputStream(_config);
            configure(cpcfg,args.length);
            File file=new File(System.getProperty("jetty.home"));
            String canonical=file.getCanonicalPath();
            System.setProperty("jetty.home",canonical);
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.exit(1);
        }
        finally
        {
            try{cpcfg.close();}
	    catch(Exception e){e.printStackTrace();}
        }
        // okay, classpath complete.
        System.setProperty("java.class.path",_classpath.toString());
        ClassLoader cl=_classpath.getClassLoader();
        if(_debug)
        {
            System.err.println("java.class.path="+System.getProperty("java.class.path"));
            System.err.println("jetty.home="+System.getProperty("jetty.home"));
            System.err.println("java.io.tmpdir="+System.getProperty("java.io.tmpdir"));
            System.err.println("java.class.path="+_classpath);
            System.err.println("classloader="+cl);
            System.err.println("classloader.parent="+cl.getParent());
        }
        // Invoke main(args) using new classloader.
        Thread.currentThread().setContextClassLoader(cl);
        // re-eval the policy now that env is set
        try
        {
            Policy policy=Policy.getPolicy();
            if(policy!=null)
                policy.refresh();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        try
        {
            for(int i=0;i<args.length;i++)
            {
                if(args[i]==null)
                    continue;
                _xml.add(args[i]);
            }
            args=(String[])_xml.toArray(args);

            if(_debug)
                System.err.println("main.class="+_classname);
            invokeMain(cl,_classname,args);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
1040271
@Override
    protected void doStart() throws Exception
    {
        log.info("starting...");
        super.doStart();
        _client = newClient(_serverString);
        if (_client == null)
        {
            throw new IllegalStateException("newClient(" + _serverString + ") returns null.");
        }
        log.info("use " + _client.getClass().getSimpleName() + " as client factory.");
        _client.establish();
        log.info("started.");
    }
75597
@Override
  public final void init (@Nonnull final ServletConfig aSC) throws ServletException
  {
    super.init (aSC);
    m_aStatusMgr.onServletInit (getClass ());
    try
    {
      // Build init parameter map
      final ICommonsMap <String, String> aInitParams = new CommonsHashMap <> ();
      final Enumeration <String> aEnum = aSC.getInitParameterNames ();
      while (aEnum.hasMoreElements ())
      {
        final String sName = aEnum.nextElement ();
        aInitParams.put (sName, aSC.getInitParameter (sName));
      }
      // Invoke each handler for potential initialization
      m_aHandlerRegistry.forEachHandlerThrowing (x -> x.onServletInit (aInitParams));
    }
    catch (final ServletException ex)
    {
      m_aStatusMgr.onServletInitFailed (ex, getClass ());
      throw ex;
    }
  }
460102
public void init(String webAppRfsPath, String servletMapping, String defaultWebApplication) {

        try {
            // explicit set to null to overwrite exiting values from session
            m_availableModules = null;
            m_fullDatabaseKey = null;
            m_databaseKey = null;
            m_databaseKeys = null;
            m_databaseProperties = null;
            m_configuration = null;
            m_installModules = null;
            m_moduleDependencies = null;
            m_sortedDatabaseKeys = null;
            m_moduleFilenames = null;

            if (servletMapping == null) {
                servletMapping = "/opencms/*";
            }
            if (defaultWebApplication == null) {
                defaultWebApplication = "ROOT";
            }
            m_servletMapping = servletMapping;
            m_defaultWebApplication = defaultWebApplication;

            setWebAppRfsPath(webAppRfsPath);
            m_errors = new ArrayList<String>();

            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(webAppRfsPath)) {
                m_configuration = new CmsParameterConfiguration(m_configRfsPath + CmsSystemInfo.FILE_PROPERTIES);
                readDatabaseConfig();
            }

            if (m_workplaceImportThread != null) {
                if (m_workplaceImportThread.isAlive()) {
                    m_workplaceImportThread.kill();
                }
                m_workplaceImportThread = null;
                m_newLoggingOffset = 0;
                m_oldLoggingOffset = 0;
            }
        } catch (Exception e) {
            e.printStackTrace();
            m_errors.add(e.toString());
        }
    }
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());
		}
	}
443773
public void startup(boolean forceStartup) throws GreenPepperServerException {
        log.info("Starting Plugin");
        if (!isPluginEnabled)
            return;

        final GreenPepperServerConfiguration configuration = getConfiguration();

        if ((configuration.isSetupComplete() && !isServerStarted) || forceStartup) {
            isServerStarted = false;

            try {
                closeSession();

                Properties properties = configuration.getProperties();

                injectAdditionalProperties(properties);

                HibernateSessionService sessionService = new HibernateSessionService(properties);

                log.info("Boostrapping datas");
                new BootstrapData(sessionService, properties).execute();
                new GreenPepperUserGroup().createIfNeeded();

                Authorizer authorizer = new OpenSourceAuthorizer(sessionService, properties);
                authorizer.initialize(GreenPepperServer.versionDate());

                ProjectDao projectDao = new HibernateProjectDao(sessionService);
                RepositoryDao repositoryDao = new HibernateRepositoryDao(sessionService);
                SystemUnderTestDao sutDao = new HibernateSystemUnderTestDao(sessionService);
                DocumentDao documentDao = new HibernateDocumentDao(sessionService);

                Object object = ContainerManager.getComponent("greenPepperServerService");
                GreenPepperServerServiceImpl service = (GreenPepperServerServiceImpl) object;

                service.setAuthorizer(authorizer);
                service.setDocumentDao(documentDao);
                service.setProjectDao(projectDao);
                service.setRepositoryDao(repositoryDao);
                service.setSessionService(sessionService);
                service.setSutDao(sutDao);

                object = ContainerManager.getComponent("greenPepperXmlRpcServerService");
                GreenPepperXmlRpcServer xmlRpcServer = (GreenPepperXmlRpcServer) object;
                xmlRpcServer.setService(service);

                hibernateSessionService = sessionService;

                configuration.setSetupComplete(true);
                storeConfiguration(configuration);

                isServerStarted = true;
            } catch (Exception ex) {
                log.error("Starting up GreenPepper plugin", ex);
                throw new GreenPepperServerException(GreenPepperServerErrorKey.GENERAL_ERROR, ex);
            }
        }
    }
1147772
public final void contextInitialized(final ServletContextEvent sce) {
		try {
			// Get the configuration
			final ParalleljConfiguration configuration = (ParalleljConfiguration) ConfigurationService
					.getConfigurationService().getConfigurationManager()
					.get(ParalleljConfigurationManager.class).getConfiguration();

			// Initialize the launcher
			Launcher.getLauncher();

			// Initialize a TcpIpServer
			if (configuration.getServers() != null
					&& configuration.getServers().getTelnet() != null) {
				this.tcpIpServer = new TcpIpServer(configuration.getServers()
						.getTelnet().getHost(), configuration.getServers()
						.getTelnet().getPort(), new TcpIpHandlerAdapter());
				// Try to start the TciIpServer
				if (this.tcpIpServer != null) {
					try {
						this.tcpIpServer.start();
					} catch (IOException e) {
						LaunchingMessageKind.ETCPIP0001.format(e);
					}
				}
			}

			// Initialize a JmxServer
			// and register all defined Program as MBeans
			if (configuration.getServers() != null
					&& configuration.getServers().getJmx() != null) {
				this.jmxServer = new JmxServer(configuration.getServers()
						.getJmx().getHost(), configuration.getServers()
						.getJmx().getPort());
				// Try to start the JmxServer
				if (this.jmxServer != null) {
					try {
						this.jmxServer.start();
					} catch (IOException e) {
						LaunchingMessageKind.EJMX0001.format(e);
					}
				}
			}

			// Initialize a SshServer
			if (configuration.getServers() != null
					&& configuration.getServers().getSsh() != null) {

				this.sshServer = new SshServer(configuration.getServers()
						.getSsh().getPort());

				// Try to start SshServer
				if (this.sshServer != null) {
					try {
						sshServer.start();
					} catch (IOException e) {
						LaunchingMessageKind.ESSH0001.format(e);
					}
				}
			}
			
		} catch (LaunchException e) {
			LaunchingMessageKind.EWLAUNCH0001.format(e);
		}
	}
1340790
private void doStart() throws LifecycleException {
        tomcat.getServer().addLifecycleListener(new TomcatLifecycleListener());
        logger.info("Deploying application to [" + getConfig().getDeployUrl() + "]");
        tomcat.start();

        // Let's set the port that was used to actually start the application if necessary
        if (getConfig().getPort() == EmbedVaadinConfig.DEFAULT_PORT) {
            getConfig().setPort(getTomcat().getConnector().getLocalPort());
        }

        logger.info("Application has been deployed to [" + getConfig().getDeployUrl() + "]");
        if (config.shouldOpenBrowser()) {
            BrowserUtils.openBrowser(getConfig().getOpenBrowserUrl());
        }
        if (isWaiting()) {
            tomcat.getServer().await();
        }
    }
920338
public synchronized void setUp()
	{	
			if(initialized)
				return;

			String className = null;
			
			//Load
			Map<Object,Object> properties = settings.getProperties();
			
			String key = null;
			
			Object serviceObject = null;
			
			for(Map.Entry<Object,Object> entry : properties.entrySet())
			{
				key = String.valueOf(entry.getKey());
				
				if(key.startsWith(PROP_PREFIX))
				{
					try
					{
						className = (String)entry.getValue();
						serviceObject = ClassPath.newInstance(className);
						
						factoryMap.put(key, serviceObject);
					}
					catch (Throwable e)
					{
						throw new SetupException("CLASS:"+className+" ERROR:"+e.getMessage(),e);
					}
				}
			}
			
			initialized = true;
		}
844330
@Override
    public void start() {
        String res = launchPing();
        if (res != null && res.length() > 0) {
            res = res.toLowerCase();
            if (res.contains(Cmd.PING_UNREACHABLE) && !res.contains(Cmd.PING_EXCEED)) {
                // Failed
                mLossRate = 1f;
                mError = Cmd.HOST_UNREACHABLE_ERROR;
            } else {
                // Succeed
                mLossRate = parseLoss(res);
                mDelay = parseDelay(res);
                if (isAnalysisIp)
                    mIp = parseIp(res);
            }
        } else {
            mError = Cmd.DROP_DATA_ERROR;
        }
    }
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;
    }
267305
public void start() {
      initMBeanServer(globalConfig);

      if (mBeanServer != null) {
         Collection<ComponentRef<?>> components = basicComponentRegistry.getRegisteredComponents();
         resourceDMBeans = Collections.synchronizedCollection(getResourceDMBeansFromComponents(components));

         registrar.registerMBeans(resourceDMBeans);
         needToUnregister = true;
      }
      stopped = false;
   }
565549
public void startSetup(@NotNull final OnIabSetupFinishedListener listener) {
        if (options != null) {
            Logger.d("startSetup() options = ", options);
        }
        //noinspection ConstantConditions
        if (listener == null) {
            throw new IllegalArgumentException("Setup listener must be not null!");
        }
        if (setupState != SETUP_RESULT_NOT_STARTED && setupState != SETUP_RESULT_FAILED) {
            throw new IllegalStateException("Couldn't be set up. Current state: " + setupStateToString(setupState));
        }
        setupState = SETUP_IN_PROGRESS;
        setupExecutorService = Executors.newSingleThreadExecutor();

        // Compose full list of available stores to check billing for
        availableAppstores.clear();
        // Add all manually supplied Appstores
        availableAppstores.addAll(options.getAvailableStores());
        final List<String> storeNames = new ArrayList<String>(options.getAvailableStoreNames());
        // Remove already added stores
        for (final Appstore appstore : availableAppstores) {
            storeNames.remove(appstore.getAppstoreName());
        }
        // Instantiate and add all known wrappers
        final List<Appstore> instantiatedAppstores = new ArrayList<Appstore>();
        for (final String storeName : options.getAvailableStoreNames()) {
            if (appStoreFactoryMap.containsKey(storeName)) {
                final Appstore appstore = appStoreFactoryMap.get(storeName).get();
                instantiatedAppstores.add(appstore);
                availableAppstores.add(appstore);
                storeNames.remove(storeName);
            }
        }
        // Look among open stores for specified store names
        if (!storeNames.isEmpty()) {
            discoverOpenStores(new OpenStoresDiscoveredListener() {
                @Override
                public void openStoresDiscovered(@NotNull final List<Appstore> appStores) {
                    // Add all specified open stores
                    for (final Appstore appstore : appStores) {
                        final String name = appstore.getAppstoreName();
                        if (storeNames.contains(name)) {
                            availableAppstores.add(appstore);
                        } else {
                            final AppstoreInAppBillingService billingService;
                            if ((billingService = appstore.getInAppBillingService()) != null) {
                                billingService.dispose();
                                Logger.d("startSetup() billing service disposed for ", appstore.getAppstoreName());
                            }
                        }
                    }
                    final Runnable cleanup = new Runnable() {
                        @Override
                        public void run() {
                            for (final Appstore appstore : instantiatedAppstores) {
                                final AppstoreInAppBillingService billingService;
                                if ((billingService = appstore.getInAppBillingService()) != null) {
                                    billingService.dispose();
                                    Logger.d("startSetup() billing service disposed for ", appstore.getAppstoreName());
                                }
                            }
                        }
                    };
                    if (setupState != SETUP_IN_PROGRESS) {
                        cleanup.run();
                        return;
                    }
                    setupWithStrategy(new OnIabSetupFinishedListener() {
                        @Override
                        public void onIabSetupFinished(final IabResult result) {
                            listener.onIabSetupFinished(result);
                            instantiatedAppstores.remove(OpenIabHelper.this.appstore);
                            cleanup.run();
                        }
                    });
                }
            });
        } else {
            setupWithStrategy(listener);
        }
    }
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);
                }
            }
        }
    }
134961
@Override
    public void internalInitialize(BeanDeployerEnvironment environment) {
        super.internalInitialize(environment);
        checkEJBTypeAllowed();
        checkConflictingRoles();
        checkObserverMethods();
        checkScopeAllowed();
    }
322991
@Override
    public void init(ServletConfig config) throws ServletException {
        LOGGER.info("Initializing filesystem resource servlet");
        super.init(config);

        final String directory = config.getInitParameter("directory");
        if (StringUtils.isNotBlank(directory)) {
            this.directory = directory;
        }

        final String absolute = config.getInitParameter("absolute");
        if (StringUtils.isNotBlank(absolute)) {
            this.absolute = BooleanUtil.valueOf(absolute);
        }
    }