This is used to initialize the application.
 It runs in a thread because startup depends on EventMachine running
961645
def boot
      Thread.new do
        sleep 1 until EM.reactor_running?

        begin
          log.info "Loading application..."
          app_init
          load_settings
          Fastr::Plugin.load(self)
          load_app_classes
          setup_router
          setup_watcher

          log.info "Application loaded successfully."

          @booting = false

          plugin_after_boot
        rescue Exception => e
          log.error "#{e}"
          puts e.backtrace
          log.fatal "Exiting due to previous errors..."
          exit(1)
        end
      end
    end
470616
@Override
	public synchronized void start() {
		super.start();
		this.running = true;
		if (this.hasFrame) this.frame.setVisible(true);
		this.thread.start();
	}
840490
@Override
    public void initialize(JsMessagingEngine engine) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "initialize", engine);

        // Get the admin factory class
        try {
            jsaf = JsAdminFactory.getInstance();
        } catch (Exception e) {
            // No FFDC code needed
        }

        // Synchronize on stateChangeLock to manage the startup of the engine with
        // potential addition of new engine components via dynamic config.
//        processor = _mainImpl.mpService.getService().getInstance();
        ListIterator<ComponentList> li = null;
        boolean initializationFailed = false;

        synchronized (stateChangeLock) {

            setState(STATE_INITIALIZING);
            for (int i = 0; i < NUM_STOP_PHASES; i++)
            {
                stopSequence[i] = new Vector<ComponentList>();
            }
            try
            {
                _messageStore = JsMainAdminComponentImpl.messageStoreRef.getService();

            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            _messageProcessor = loadClass(JsConstants.SIB_CLASS_MP, STOP_PHASE_1, true);

            // Initialize any engine components
            initializationFailed = false;

        } // synchronized(stateChangeLock)
        try {
            //Initialize the message store 
            _messageStore.initialize(this);
            //Initialize the message processor 
            _messageProcessor.initialize(this);
            setState(STATE_INITIALIZED);
        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, CLASS_NAME + ".<init>", "625", this);
            SibTr.error(tc, "ME_CANNOT_BE_INITIALIZED_SIAS0033", new Object[] { _name, "MessageProcessor.java", "initialize()" });
            SibTr.exception(tc, e);
            initializationFailed = true;

        }
        if (initializationFailed) {
            destroy();
            // Cleanup finished...
            // Change state to UNINITIALIZED
            setState(STATE_UNINITIALIZED);
        } else {
            setState(STATE_INITIALIZED);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "initialize");
    }
424453
public void onInit() {

        String authToken = m_params.getAuthToken();
        if (authToken != null) {
            m_ui.showForgotPasswordView(authToken);
        } else if (m_params.isReset()) {
            m_ui.showPasswordResetDialog();
        } else {
            boolean loggedIn = !A_CmsUI.getCmsObject().getRequestContext().getCurrentUser().isGuestUser();
            m_ui.setSelectableOrgUnits(CmsLoginHelper.getOrgUnitsForLoginDialog(A_CmsUI.getCmsObject(), null));
            if (loggedIn) {
                if (m_params.isLogout()) {
                    logout();
                } else {
                    m_ui.showAlreadyLoggedIn();
                }
            } else {
                m_ui.showLoginView(m_params.getOufqn());
            }
        }

    }
452317
@Override
    public void launch(@NonNull ThreadingModel threading) {
        this.threadingModel = threading;

        switch (threading) {
            case SINGLE_THREAD: {

                log.warn("SINGLE_THREAD model is used, performance will be significantly reduced");

                // single thread for all queues. shouldn't be used in real world
                threadA = new Thread(() -> {
                    while (runner.get()) {
                        if (subscriptionForShards != null)
                            subscriptionForShards.poll(messageHandlerForShards, 512);

                        idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    }
                });

                threadA.setDaemon(true);
                threadA.start();
                }
                break;
            case DEDICATED_THREADS: {
                // we start separate thread for each handler

                /**
                 * We definitely might use less conditional code here, BUT i'll keep it as is,
                 * only because we want code to be obvious for people
                 */
                final AtomicBoolean localRunner = new AtomicBoolean(false);
                if (nodeRole == NodeRole.NONE) {
                    throw new ND4JIllegalStateException("No role is set for current node!");
                } else if (nodeRole == NodeRole.SHARD || nodeRole == NodeRole.BACKUP || nodeRole == NodeRole.MASTER) {
                    // // Shard or Backup uses two subscriptions

                    // setting up thread for shard->client communication listener
                    if (messageHandlerForShards != null) {
                        threadB = new Thread(() -> {
                            while (runner.get())
                                idler.idle(subscriptionForShards.poll(messageHandlerForShards, 512));

                        });
                        threadB.setDaemon(true);
                        threadB.setName("VoidParamServer subscription threadB [" + nodeRole + "]");
                    }

                    // setting up thread for inter-shard communication listener
                    threadA = new Thread(() -> {
                        localRunner.set(true);
                        while (runner.get())
                            idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    });

                    if (threadB != null) {
                        Nd4j.getAffinityManager().attachThreadToDevice(threadB,
                                        Nd4j.getAffinityManager().getDeviceForCurrentThread());
                        threadB.setDaemon(true);
                        threadB.setName("VoidParamServer subscription threadB [" + nodeRole + "]");
                        threadB.start();
                    }
                } else {
                    // setting up thread for shard->client communication listener
                    threadA = new Thread(() -> {
                        localRunner.set(true);
                        while (runner.get())
                            idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    });
                }

                // all roles have threadA anyway
                Nd4j.getAffinityManager().attachThreadToDevice(threadA,
                                Nd4j.getAffinityManager().getDeviceForCurrentThread());
                threadA.setDaemon(true);
                threadA.setName("VoidParamServer subscription threadA [" + nodeRole + "]");
                threadA.start();

                while (!localRunner.get())
                    try {
                        Thread.sleep(50);
                    } catch (Exception e) {
                    }
            }
                break;
            case SAME_THREAD: {
                // no additional threads at all, we do poll within takeMessage loop
                log.warn("SAME_THREAD model is used, performance will be dramatically reduced");
            }
                break;
            default:
                throw new IllegalStateException("Unknown thread model: [" + threading.toString() + "]");
        }
    }
794843
public static void init(Application application) {
        if (!hasInit) {
            logger = _ARouter.logger;
            _ARouter.logger.info(Consts.TAG, "ARouter init start.");
            hasInit = _ARouter.init(application);

            if (hasInit) {
                _ARouter.afterInit();
            }

            _ARouter.logger.info(Consts.TAG, "ARouter init over.");
        }
    }
1010250
@Override
    protected void onInit() {
        logger.info("DoTaskApp onInit");
        // ConsoleReporters prints S4 metrics
        // MetricsRegistry mr = new MetricsRegistry();
        //
        // CsvReporter.enable(new File(System.getProperty("user.home")
        // + "/monitor/"), 10, TimeUnit.SECONDS);
        // ConsoleReporter.enable(10, TimeUnit.SECONDS);
        try {
            System.err.println();
            System.err.println(Globals.getWorkbenchInfoString());
            System.err.println();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        S4ComponentFactory factory = new S4ComponentFactory();
        factory.setApp(this);

        // logger.debug("LC {}", lc);

        // task = TaskProvider.getTask(evalTask);

        // EXAMPLE OPTIONS
        // -l Clustream -g Clustream -i 100000 -s (RandomRBFGeneratorEvents -K
        // 5 -N 0.0)
        // String[] args = new String[] {evalTask,"-l", "Clustream","-g",
        // "Clustream", "-i", "100000", "-s", "(RamdomRBFGeneratorsEvents",
        // "-K", "5", "-N", "0.0)"};
        // String[] args = new String[] { evalTask, "-l", "clustream.Clustream",
        // "-g", "clustream.Clustream", "-i", "100000", "-s",
        // "(RandomRBFGeneratorEvents", "-K", "5", "-N", "0.0)" };
        logger.debug("PARAMETERS {}", evalTask);
        // params = params.replace(":", " ");
        List<String> parameters = new ArrayList<String>();
        // parameters.add(evalTask);
        try {
            parameters.addAll(Arrays.asList(URLDecoder.decode(evalTask, "UTF-8").split(" ")));
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        String[] args = parameters.toArray(new String[0]);
        Option[] extraOptions = new Option[] {};
        // build a single string by concatenating cli options
        StringBuilder cliString = new StringBuilder();
        for (int i = 0; i < args.length; i++) {
            cliString.append(" ").append(args[i]);
        }

        // parse options
        try {
            task = (Task) ClassOption.cliStringToObject(cliString.toString(), Task.class, extraOptions);
            task.setFactory(factory);
            task.init();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
1105669
public synchronized void init() {
        channelFactory = new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(),
                Executors.newCachedThreadPool());

        datagramChannelFactory = new NioDatagramChannelFactory(
                Executors.newCachedThreadPool());

        timer = new HashedWheelTimer();
    }
42943
@Override
    protected void onStart() {
        logger.info("Starting DoTaskApp... App Partition [{}]", this.getPartitionId());
        // <<<<<<< HEAD Task doesn't have start in latest storm-impl
        // TODO change the way the app starts
        // if (this.getPartitionId() == 0)
        S4Topology s4topology = (S4Topology) getTask().getTopology();
        S4EntranceProcessingItem epi = (S4EntranceProcessingItem) s4topology.getEntranceProcessingItem();
        while (epi.injectNextEvent())
            // inject events from the EntrancePI
            ;
    }
132543
@Override
    public void run()
    {
        if (!running.compareAndSet(false, true))
        {
            throw new IllegalStateException("Thread is already running");
        }
        sequenceBarrier.clearAlert();

        notifyStart();

        boolean processedSequence = true;
        long cachedAvailableSequence = Long.MIN_VALUE;
        long nextSequence = sequence.get();
        T event = null;
        while (true)
        {
            try
            {
                // if previous sequence was processed - fetch the next sequence and set
                // that we have successfully processed the previous sequence
                // typically, this will be true
                // this prevents the sequence getting too far forward if an exception
                // is thrown from the WorkHandler
                if (processedSequence)
                {
                    processedSequence = false;
                    do
                    {
                        nextSequence = workSequence.get() + 1L;
                        sequence.set(nextSequence - 1L);
                    }
                    while (!workSequence.compareAndSet(nextSequence - 1L, nextSequence));
                }

                if (cachedAvailableSequence >= nextSequence)
                {
                    event = ringBuffer.get(nextSequence);
                    workHandler.onEvent(event);
                    processedSequence = true;
                }
                else
                {
                    cachedAvailableSequence = sequenceBarrier.waitFor(nextSequence);
                }
            }
            catch (final TimeoutException e)
            {
                notifyTimeout(sequence.get());
            }
            catch (final AlertException ex)
            {
                if (!running.get())
                {
                    break;
                }
            }
            catch (final Throwable ex)
            {
                // handle, mark as processed, unless the exception handler threw an exception
                exceptionHandler.handleEventException(ex, nextSequence, event);
                processedSequence = true;
            }
        }

        notifyShutdown();

        running.set(false);
    }
744073
private void init() {
        assertUnlocked();
        
        lock.lock();
        try {
            httpSender.init(cfg);

            LOG.info(
                "Starting with "
                    + DEFAULT_REQ_PROC_COUNT + " request processors");

            procThreads = new RequestProcessor[DEFAULT_REQ_PROC_COUNT];

            for (int i = 0; i < procThreads.length; i++) {
                procThreads[i] = new RequestProcessor(i);
                procThreads[i].start();
            }

        } finally {
            lock.unlock();
        }
    }
735099
@PostConstruct
    public final void init() {
        this.cleanUpTimer = Executors.newScheduledThreadPool(1, timerTask -> {
            final Thread thread = new Thread(timerTask, "Clean up old job records");
            thread.setDaemon(true);
            return thread;
        });
        this.cleanUpTimer.scheduleAtFixedRate(this::cleanup, this.cleanupInterval, this.cleanupInterval,
                                              TimeUnit.SECONDS);
    }
1176963
@PostConstruct
    public void onInit() {
    	isExecutorAvailable = isExecutorOnClasspath();
		if (identityProvider.isUnsatisfied()) {
			setIdentityProvider(new EJBContextIdentityProvider(context));
		} else {
			setIdentityProvider(identityProvider.get());
		}
		setManagerFactory(new RuntimeManagerFactoryImpl());
		super.onInit();
	}
118933
@Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
        String activeProfile = System.getProperty("spring.profiles.active");
        if (SpringProfiles.OSGI.equalsIgnoreCase(activeProfile)) {
            LOGGER.info("Running in OSGI environment");
        } else if (SpringProfiles.NON_OSGI.equalsIgnoreCase(activeProfile)) {
            LOGGER.info("Running in a non OSGI environment");
        } else {
            applicationContext.getEnvironment().setActiveProfiles(SpringProfiles.NON_OSGI);
            applicationContext.refresh();
            LOGGER.info("Switched to a non OSGI environment");
        }
    }
800620
public void initialize() {

        OpenCms.getExecutor().scheduleWithFixedDelay(new Runnable() {

            public void run() {

                checkForUpdates();
            }
        }, DELAY_MILLIS, DELAY_MILLIS, TimeUnit.MILLISECONDS);
        reload();
    }
759177
public void initialise(String name, int minSize, int maxSize)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "initialise",
                                           new Object[]{name, minSize, maxSize});

      wasThreadPool = new com.ibm.ws.util.ThreadPool(name, minSize, maxSize);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "initialise");
   }
1169838
private void initializeInstance() {
		this.processHelper = Programs.as(this.jobInstance);

		if (this.launchId == null) {
			this.launchId = UUID.randomUUID();
		}
		this.launchResult = new LaunchResult();
	}