Throw initialization events.

@param MachineInterface $machine        Machine
@param mixed            $object         Object
@param StateLineStack   $stateLineStack StateLine Stack

@return $this Self object
327435
public function dispatchInitializationEvents(
        MachineInterface $machine,
        $object,
        StateLineStack $stateLineStack
    ) {
        $this
            ->eventDispatcher
            ->dispatch(
                str_replace(
                    '{machine_id}',
                    $machine->getId(),
                    ElcodiStateTransitionMachineEvents::INITIALIZATION
                ),
                InitializationEvent::create(
                    $object,
                    $stateLineStack
                )
            );
    }
872073
function Machine(initialState, transitions, stateActions) {
    Pusher.EventsDispatcher.call(this);

    this.state = undefined;
    this.errors = [];

    // functions for each state
    this.stateActions = stateActions;

    // set up the transitions
    this.transitions = transitions;

    this.transition(initialState);
  }
738758
protected function createLoggerContext(StatemachineInterface $stateMachine)
    {
        $context = array();
        $context[self::CONTEXT_SUBJECT] = $stateMachine->getSubject();
        $context[self::CONTEXT_CURRENT_STATE] = $stateMachine->getCurrentState();
        if ($stateMachine instanceof Statemachine) {
            $context[self::CONTEXT_LAST_STATE] = $stateMachine->getLastState();
            $context[self::CONTEXT_TRANSITION] = $stateMachine->getSelectedTransition();
        }

        return $context;
    }
322647
public void init(BaseSession parentSessionObject, Record record, Map<String, Object> objectID)
    {
        m_topScreen = null;
        super.init(parentSessionObject, record, objectID);
    }
1145948
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
	{
        if ($instance instanceof CurrencyListAwareInterface) {
            if ($serviceLocator instanceof AbstractPluginManager) {
            	$serviceLocator = $serviceLocator->getServiceLocator();
            }

            $exchanger = $serviceLocator->get(CurrencyListInterface::class);
            $instance->setCurrencyList($exchanger);
        }
	}
1183164
public function addStateLine(StateLineInterface $stateLine)
    {
        $this
            ->stateLines
            ->add($stateLine);

        $this->lastStateLine = $stateLine;

        return $this;
    }
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");
    }
698257
public static function reset($object)
	{
		if (!($object instanceof MethodDescriptorProto)) {
			throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodDescriptorProto.');
		}
		$object->name = NULL;
		$object->inputType = NULL;
		$object->outputType = NULL;
		$object->options = NULL;
		$object->clientStreaming = NULL;
		$object->serverStreaming = NULL;
	}
1224035
public function setInitialState()
    {
        foreach ($this->states as $status) {
            if ($status->getType() == StatusInterface::TYPE_INITIAL) {
                $this->currentStatus = $status;

                return;
            }
        }
        throw new WorkflowException('No initial state found for the workflow', 90, NULL);
    }
210634
private function initMethod(object $object, string $method, bool $expected): void
    {
        if (!$this->mustBeInitialized($object, $method)) {
            return;
        }

        $this->object = $object;
        $this->method = $method;
        $this->expected = $expected;
    }
1349885
protected function _throw($object)
    {
        $error = $object->errorInfo();
        throw new \RuntimeException(
            sprintf(
                'PDO operation returned SQLSTATE %s: Error %s (%s)',
                $error[0],
                $error[1],
                $error[2]
            )
        );
    }
689841
protected function initializeStates()
    {
        if (!array_key_exists('states', $this->vars)) {
            throw new WorkflowException("You must define some states:\n", 99, NULL);
        }

        //check if all the methods for each status is callable
        $methods_not_implemented = '';
        try {
            foreach ($this->vars['states'] as $status) {
                array_push($this->states, new Status($status));

                /*
                 * The initial state will never be executed but only the transitions, therefore it will be excluded
                 * from the list of methods which must be implemented
                 */
                if (!method_exists($this, $status['name'])
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL
                    && $status['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
                    $methods_not_implemented .= $status['name'] . "\n";
                }
            }
        } catch (StatusException $ex) {
            throw new WorkflowException("Error in one state of the workflow:\n" . $ex->getMessage(), 79);
        }

        if (strlen($methods_not_implemented) > 0) {
            throw new WorkflowException(
                "This methods are not implemented in the workflow:\n" .
                $methods_not_implemented, 79, NULL
            );
        }
    }
1342331
protected void initializeStateMachine() {

        stateMachine = new StateMachine<ReplicationState, ReplicationTrigger>(ReplicationState.INITIAL);

        // hierarchy
        stateMachine.configure(ReplicationState.IDLE).substateOf(ReplicationState.RUNNING);
        stateMachine.configure(ReplicationState.OFFLINE).substateOf(ReplicationState.RUNNING);

        // permitted transitions
        stateMachine.configure(ReplicationState.INITIAL).permit(
                ReplicationTrigger.START,
                ReplicationState.RUNNING
        );
        stateMachine.configure(ReplicationState.IDLE).permit(
                ReplicationTrigger.RESUME,
                ReplicationState.RUNNING
        );
        stateMachine.configure(ReplicationState.RUNNING).permit(
                ReplicationTrigger.WAITING_FOR_CHANGES,
                ReplicationState.IDLE
        );
        stateMachine.configure(ReplicationState.RUNNING).permit(
                ReplicationTrigger.STOP_IMMEDIATE,
                ReplicationState.STOPPED
        );
        stateMachine.configure(ReplicationState.RUNNING).permit(
                ReplicationTrigger.STOP_GRACEFUL,
                ReplicationState.STOPPING
        );
        stateMachine.configure(ReplicationState.RUNNING).permit(
                ReplicationTrigger.GO_OFFLINE,
                ReplicationState.OFFLINE
        );
        stateMachine.configure(ReplicationState.OFFLINE).permit(
                ReplicationTrigger.GO_ONLINE,
                ReplicationState.RUNNING
        );
        stateMachine.configure(ReplicationState.STOPPING).permit(
                ReplicationTrigger.STOP_IMMEDIATE,
                ReplicationState.STOPPED
        );

        // ignored transitions
        stateMachine.configure(ReplicationState.INITIAL).ignore(ReplicationTrigger.RESUME);
        stateMachine.configure(ReplicationState.INITIAL).ignore(ReplicationTrigger.GO_ONLINE);
        stateMachine.configure(ReplicationState.INITIAL).ignore(ReplicationTrigger.GO_OFFLINE);
        stateMachine.configure(ReplicationState.RUNNING).ignore(ReplicationTrigger.START);
        stateMachine.configure(ReplicationState.RUNNING).ignore(ReplicationTrigger.RESUME);
        stateMachine.configure(ReplicationState.RUNNING).ignore(ReplicationTrigger.GO_ONLINE);
        stateMachine.configure(ReplicationState.IDLE).ignore(ReplicationTrigger.START);
        stateMachine.configure(ReplicationState.IDLE).ignore(ReplicationTrigger.GO_ONLINE);
        stateMachine.configure(ReplicationState.OFFLINE).ignore(ReplicationTrigger.START);
        stateMachine.configure(ReplicationState.OFFLINE).ignore(ReplicationTrigger.RESUME);
        stateMachine.configure(ReplicationState.OFFLINE).ignore(ReplicationTrigger.WAITING_FOR_CHANGES);
        stateMachine.configure(ReplicationState.OFFLINE).ignore(ReplicationTrigger.GO_OFFLINE);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.START);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.RESUME);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.WAITING_FOR_CHANGES);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.GO_ONLINE);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.GO_OFFLINE);
        stateMachine.configure(ReplicationState.STOPPING).ignore(ReplicationTrigger.STOP_GRACEFUL);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.START);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.RESUME);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.WAITING_FOR_CHANGES);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.GO_ONLINE);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.GO_OFFLINE);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.STOP_GRACEFUL);
        stateMachine.configure(ReplicationState.STOPPED).ignore(ReplicationTrigger.STOP_IMMEDIATE);

        // actions
        stateMachine.configure(ReplicationState.RUNNING).onEntry(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onEntry()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                start();
                notifyChangeListenersStateTransition(transition);
            }
        });

        stateMachine.configure(ReplicationState.RUNNING).onExit(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onExit()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
            }
        });

        stateMachine.configure(ReplicationState.IDLE).onEntry(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onEntry()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                retryReplicationIfError();
                if (transition.getSource() == transition.getDestination()) {
                    // ignore IDLE to IDLE
                    return;
                }
                notifyChangeListenersStateTransition(transition);

                // #352
                // iOS version: stop replicator immediately when call setError() with permanent error.
                // But, for Core Java, some of codes wait IDLE state. So this is reason to wait till
                // state becomes IDLE.
                if (Utils.isPermanentError(ReplicationInternal.this.error) && isContinuous()) {
                    Log.d(Log.TAG_SYNC, "IDLE: triggerStopGraceful() " + ReplicationInternal.this.error.toString());
                    triggerStopGraceful();
                }
            }
        });

        stateMachine.configure(ReplicationState.IDLE).onExit(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onExit()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                if (transition.getSource() == transition.getDestination()) {
                    // ignore IDLE to IDLE
                    return;
                }
                notifyChangeListenersStateTransition(transition);
            }
        });

        stateMachine.configure(ReplicationState.OFFLINE).onEntry(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onEntry()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                goOffline();
                notifyChangeListenersStateTransition(transition);
            }
        });

        stateMachine.configure(ReplicationState.OFFLINE).onExit(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onExit()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                goOnline();
                notifyChangeListenersStateTransition(transition);
            }
        });

        stateMachine.configure(ReplicationState.STOPPING).onEntry(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onEntry()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());
                // NOTE: Based on StateMachine configuration, this should not happen.
                //       However, from Unit Test result, this could be happen.
                //       We should revisit StateMachine configuration and also its Thread-safe-ability
                if (transition.getSource() == transition.getDestination()) {
                    // ignore STOPPING to STOPPING
                    return;
                }
                stop();
                notifyChangeListenersStateTransition(transition);
            }
        });

        stateMachine.configure(ReplicationState.STOPPED).onEntry(new Action1<Transition<ReplicationState, ReplicationTrigger>>() {
            @Override
            public void doIt(Transition<ReplicationState, ReplicationTrigger> transition) {
                Log.v(Log.TAG_SYNC,
                        "%s [onEntry()] " + transition.getSource() + " => " + transition.getDestination(),
                        ReplicationInternal.this.toString());

                // NOTE: Based on StateMachine configuration, this should not happen.
                //       However, from Unit Test result, this could be happen.
                //       We should revisit StateMachine configuration and also its Thread-safe-ability
                if (transition.getSource() == transition.getDestination()) {
                    // ignore STOPPED to STOPPED
                    return;
                }

                saveLastSequence(); // move from databaseClosing() method as databaseClosing() is not called

                // stop network reachablity check
                stopNetworkReachabilityManager();

                // close any active resources associated with this replicator
                close();

                clearDbRef();

                notifyChangeListenersStateTransition(transition);

                // ask executor to shutdown. this does not force to shutdown.
                // https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html#shutdown()
                synchronized (executor) {
                    if (!executor.isShutdown()) {
                        executor.shutdown();
                    }
                }
            }
        });
    }
563569
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        parent::initialize($input, $output);

        Context::get('information-collector')->handleCommandInput($input);

        $this->getOutput()->writeBigTitle('Welcome to Release Management Tool');

        $this->executeActionListIfExist('prerequisites');
    }
998662
private function pushCallerStatedClassName(StateInterface $state): ProxyInterface
    {
        $stateClass = \get_class($state);

        if (!isset($this->classesByStates[$stateClass])) {
            throw new \RuntimeException("Error, no original class name defined for $stateClass");
        }

        $this->callerStatedClassesStack->push($this->classesByStates[$stateClass]);

        return $this;
    }
66640
protected function initWorkflow()
    {
        $className = $this->workflowConfiguration['class']['name'];

        if (!class_exists($className, true)) {
            throw new StateMachineException('The class ' . $className . ' does not exist!', 100);
        }

        try {
            $this->workflow = new $className($this->workflowConfiguration);
        } catch (WorkflowException $ex) {
            throw new StateMachineException('Workflow with some problems', 90, $ex);
        }
    }
164090
private function callInitMethod($instance)
    {
        $args = [];
        foreach ($this->init_method_args as $arg) {
            if (is_string($arg) && preg_match('/^\$([\w_]+)$/', $arg, $matches)) {
                $arg = $this->container->get($matches[1]);
            }
            $args[] = $arg;
        }
        call_user_func_array(array($instance, $this->init_method_name), $args);
    }