Call this method once all handlers are fully initialized, to register the chorus remoting JMX bean
and make all chorus handlers accessible remotely
190531
public ChorusHandlerJmxExporter export() {
        if (Boolean.getBoolean(JMX_EXPORTER_ENABLED_PROPERTY)) {
            //export this object as an MBean
            if (exported.getAndSet(true) == false) {
                try {
                    log.info(String.format("Exporting ChorusHandlerJmxExporter with jmx name (%s)", JMX_EXPORTER_NAME));
                    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
                    mbs.registerMBean(this, new ObjectName(JMX_EXPORTER_NAME));
                } catch (Exception e) {
                    throw new ChorusException(String.format("Failed to export ChorusHandlerJmxExporter with jmx name (%s)", JMX_EXPORTER_NAME), e);
                }
            }
        } else {
            log.info(String.format("Will not export ChorusHandlerJmxExporter : '%s' system property must be set to true.",
                JMX_EXPORTER_ENABLED_PROPERTY)
            );
        }
        return this;
    }
708927
synchronized void reconnectServerProcess(final ManagedServerBootCmdFactory factory) {
        if(this.requiredState != InternalState.SERVER_STARTED) {
            this.bootConfiguration = factory;
            this.requiredState = InternalState.SERVER_STARTED;
            ROOT_LOGGER.reconnectingServer(serverName);
            internalSetState(new ReconnectTask(), InternalState.STOPPED, InternalState.SEND_STDIN);
        }
    }
313031
@Override
    public void initialize() throws XMPPException {
        LOGGER.fine("Initialized");
        if (!isResolving() && !isResolved()) {
            // Get the best STUN server available
            if (currentServer.isNull()) {
                loadSTUNServers();
            }
            // We should have a valid STUN server by now...
            if (!currentServer.isNull()) {

                clearCandidates();

                resolverThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        // Iterate through the list of interfaces, and ask
                        // to the STUN server for our address.
                        try {
                            Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
                            String candAddress;
                            int candPort;

                            while (ifaces.hasMoreElements()) {

                                NetworkInterface iface =  ifaces.nextElement();
                                Enumeration<InetAddress> iaddresses = iface.getInetAddresses();

                                while (iaddresses.hasMoreElements()) {
                                    InetAddress iaddress = iaddresses.nextElement();
                                    if (!iaddress.isLoopbackAddress()
                                            && !iaddress.isLinkLocalAddress()) {

                                        // Reset the candidate
                                        candAddress = null;
                                        candPort = -1;

                                        DiscoveryTest test = new DiscoveryTest(iaddress,
                                                currentServer.getHostname(),
                                                currentServer.getPort());
                                        try {
                                            // Run the tests and get the
                                            // discovery
                                            // information, where all the
                                            // info is stored...
                                            DiscoveryInfo di = test.test();

                                            candAddress = di.getPublicIP() != null ?
                                                    di.getPublicIP().getHostAddress() : null;

                                            // Get a valid port
                                            if (defaultPort == 0) {
                                                candPort = getFreePort();
                                            } else {
                                                candPort = defaultPort;
                                            }

                                            // If we have a valid candidate,
                                            // add it to the list.
                                            if (candAddress != null && candPort >= 0) {
                                                TransportCandidate candidate = new TransportCandidate.Fixed(
                                                        candAddress, candPort);
                                                candidate.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName());
                                                addCandidate(candidate);

                                                resolvedPublicIP = candidate.getIp();
                                                resolvedLocalIP = candidate.getLocalIp();
                                                return;
                                            }
                                        }
                                        catch (Exception e) {
                                            LOGGER.log(Level.SEVERE, "Exception", e);
                                        }
                                    }
                                }
                            }
                        }
                        catch (SocketException e) {
                            LOGGER.log(Level.SEVERE, "Exception", e);
                        }
                        finally {
                            setInitialized();
                        }
                    }
                }, "Waiting for all the transport candidates checks...");

                resolverThread.setName("STUN resolver");
                resolverThread.start();
            } else {
                throw new IllegalStateException("No valid STUN server found.");
            }
        }
    }
815084
protected void initialize() {
        eventManager.subscribe(Constants.REFRESH_EVENT, refreshListener);
        appFramework.registerObject(FrameworkController.this);
        comp.addEventListener("destroy", (event) -> {
            cleanup();
        }
871037
protected void init (ManagedRoot root, MediaTimer timer)
    {
        _window = root.getWindow();
        _root = root;
        _root.init(this);
        _timer = timer;

        // set up our custom repaint manager
        _repainter = new ActiveRepaintManager(
            (_root instanceof Component) ? (Component)_root : _window);
        RepaintManager.setCurrentManager(_repainter);

        // turn off double buffering for the whole business because we handle repaints
        _repainter.setDoubleBufferingEnabled(false);
    }
809053
public void init (PlaceManager plmgr, RootDObjectManager omgr, InvocationManager invmgr)
    {
        _plmgr = plmgr;
        _omgr = omgr;
        _invmgr = invmgr;
    }
51390
@Override
    protected void initialize(boolean reactivate) throws RemoteException, InvocationTargetException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.entry(tc, "initialize");
        }

        BeanMetaData bmd = home.beanMetaData;
        ivCallbackKind = bmd.ivCallbackKind;

        state = PRE_CREATE; // d159152

        CallbackContextHelper contextHelper = new CallbackContextHelper(this); // d630940
        try {
            // Disallow setRollbackOnly until create is done.
            allowRollbackOnly = false;

            // Set the BeanId for this MDB. Just like we do for SLSB,
            // we use the BeanId for the home bean so that the same ID
            // is used for all MDB instances. Note the ivStatelessId is
            // for the home bean, which is implemented as a SLSB.
            if (home != null) {
                setId(home.ivStatelessId); // d140003.12
            }

            // Note that the local transaction surrounds injection methods and
            // PostConstruct lifecycle callbacks.
            contextHelper.begin(CallbackContextHelper.Tx.CompatLTC,
                                CallbackContextHelper.Contexts.CallbackBean); // d630940

            InterceptorMetaData imd = bmd.ivInterceptorMetaData;
            createInterceptorsAndInstance(contextHelper);

            // Now set the MessageDrivenContext and/or do the dependency injection.
            // Note that dependency injection must occur while in PRE_CREATE state.
            injectInstance(ivManagedObject, ivEjbInstance, this);

            //---------------------------------------------------------
            // Now that the MessageDrivenContext is set and/or dependencies
            // injection has occured, change state to CREATING state to allow
            // additional methods to be called by the ejbCreate or
            // PostConstruct interceptor methods (e.g. getEJBObject).
            //---------------------------------------------------------
            setState(CREATING); //d399469.2

            // Determine of life cycle callback to make if any.
            if (ivCallbackKind == CallbackKind.MessageDrivenBean) {
                Method m = bmd.ivEjbCreateMethod; //d453778
                if (m != null) //d453778
                {
                    // This is a 2.x MDB that has a ejbCreate method in it.
                    try {
                        if (isTraceOn && // d527372
                            TEBeanLifeCycleInfo.isTraceEnabled()) {
                            TEBeanLifeCycleInfo.traceEJBCallEntry("ejbCreate");
                        }
                        m.invoke(ivEjbInstance, new Object[] {});
                    } catch (InvocationTargetException itex) {
                        //FFDCFilter.processException(itex, CLASS_NAME + ".MessageDrivenBeanO", "96", this);

                        // All exceptions returned through a reflect method call
                        // are wrapped... making it difficult to debug a problem
                        // since InovcationTargetException does not print the root
                        // exception. Unwrap the 'target' exception so that the
                        // client will see it as the cause of the
                        // CreateFailureException.                        d534353.1
                        Throwable targetEx = itex.getCause();
                        if (targetEx == null)
                            targetEx = itex;

                        // MDB 2.x is allowed to throw application exceptions as well as
                        // javax.ejb.CreateException. Continue to wrap with a CreateFailureException
                        // to ensure no behavior change with prior releases.
                        if (isTraceOn && tc.isDebugEnabled()) {
                            Tr.debug(tc, "MDB ejbCreate failure", targetEx);
                        }
                        throw new CreateFailureException(targetEx);
                    } catch (Throwable ex) {
                        //FFDCFilter.processException(ex, CLASS_NAME + ".MessageDrivenBeanO", "96", this);

                        // MDB 2.x is allowed to throw application exceptions as well as
                        // javax.ejb.CreateException. Continue to wrap with a CreateFailureException
                        // to ensure no behavior change with prior releases.
                        if (isTraceOn && tc.isDebugEnabled()) {
                            Tr.debug(tc, "MDB ejbCreate failure", ex);
                        }
                        throw new CreateFailureException(ex);
                    } finally {
                        if (isTraceOn && // d527372
                            TEBeanLifeCycleInfo.isTraceEnabled()) {
                            TEBeanLifeCycleInfo.traceEJBCallExit("ejbCreate");
                        }
                    }
                }
            } else if (ivCallbackKind == CallbackKind.InvocationContext) {
                // This is a MDB 3 that may have one or more PostConstruct interceptors
                // methods. Invoke PostContruct interceptors if there is atleast 1
                // PostConstruct interceptor.
                try {
                    if (imd != null) // d402681
                    {
                        InterceptorProxy[] proxies = imd.ivPostConstructInterceptors;
                        if (proxies != null) {
                            if (isTraceOn && // d527372
                                TEBeanLifeCycleInfo.isTraceEnabled()) {
                                TEBeanLifeCycleInfo.traceEJBCallEntry("PostConstruct");
                            }
                            InvocationContextImpl<?> inv = getInvocationContext();
                            inv.doLifeCycle(proxies, bmd._moduleMetaData); //d450431, F743-14982
                        }
                    }
                } catch (Throwable t) {
                    //FFDCFilter.processException(t, CLASS_NAME + ".MessageDrivenBeanO", "281", this);

                    // PostConstruct interceptors are allowed to throw system runtime exceptions,
                    // but NOT application exceptions. Therefore, wrap the caught Throwable
                    // in a javax.ejb.EJBException so that it gets handled as an unchecked
                    // exception.
                    if (isTraceOn && tc.isDebugEnabled()) {
                        Tr.debug(tc, "MDB PostConstruct failure", t);
                    }
                    throw ExceptionUtil.EJBException("MDB PostConstruct failure", t);
                } finally {
                    if (isTraceOn && // d527372
                        TEBeanLifeCycleInfo.isTraceEnabled() &&
                        imd != null &&
                        imd.ivPostConstructInterceptors != null) {
                        TEBeanLifeCycleInfo.traceEJBCallExit("PostConstruct");
                    }
                }
            } // d367572.1 end

            //---------------------------------------------------------
            // Now that create has completed, allow setRollbackOnly to
            // be called on the SessionContext and change state to the
            // POOLED state to indicate the MDB is in the method-ready
            // pool state and message listener methods are now allowed to be
            // invoked on this MDB.
            //---------------------------------------------------------
            allowRollbackOnly = true;
            setState(POOLED);
        } finally // d399469
        {
            contextHelper.complete(true);
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "initialize");
        }
    }
1300733
private void initRemoteCommands()
   {
      if (rpcService != null)
      {
         // register commands
         suspend = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-suspend-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               suspendLocally();
               return null;
            }
         });

         resume = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-resume-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               resumeLocally();
               return null;
            }
         });

         requestForResponsibleForResuming = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager"
                  + "-requestForResponsibilityForResuming-" + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               return isResponsibleForResuming.get();
            }
         });
      }
   }
19372
private void registerServant(BusinessRemoteWrapper wrapper, int i)
    {
        // synchronized on the remote Wrapper to set the isRemoteRegistered flag
        synchronized (wrapper)
        {
            if (!ivBusinessRemoteRegistered[i])
            {
                try
                {
                    if (!isZOS)
                    {
                        // Since there may be multiple remote interfaces per bean
                        // type, a unique WrapperId must be formed by combining the
                        // BeanId with specific remote interface information. d419704
                        WrapperId wrapperId = new WrapperId
                                        (wrapper.beanId.getByteArrayBytes(),
                                                        wrapper.bmd.ivBusinessRemoteInterfaceClasses[i].getName(),
                                                        i);

                        // Servant registration must be performed with the application classloader
                        // in force.  This is especially needed for JITDeploy since
                        // the JIT pluggin will be on the application classloader.
                        // Without the JIT pluggin the classloader will not trigger
                        // JITDeploy to create the stub.  //d521388
                        Object originalLoader = ThreadContextAccessor.UNCHANGED;
                        try
                        {
                            if (ivBMD != null) // EJBFactories have no BMD.   d529446
                            {
                                originalLoader = EJBThreadData.svThreadContextAccessor.pushContextClassLoaderForUnprivileged(ivBMD.classLoader); //PK83186

                                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                                {
                                    if (originalLoader != ThreadContextAccessor.UNCHANGED)
                                    {
                                        Tr.debug(tc, "registerServant : old ClassLoader = " + originalLoader);
                                        Tr.debug(tc, "registerServant : new ClassLoader = " + ivBMD.classLoader);
                                    }
                                    else
                                    {
                                        Tr.debug(tc, "registerServant : current ClassLoader = " + ivBMD.classLoader);
                                    }
                                }
                            }
                            wrapper.container.getEJBRuntime().registerServant(wrapperId, wrapper);
                        } finally
                        {
                            EJBThreadData.svThreadContextAccessor.popContextClassLoaderForUnprivileged(originalLoader);
                        } // finally

                    } // if( !isZOS )

                    ivBusinessRemoteRegistered[i] = true;
                } catch (Throwable ex)
                {
                    FFDCFilter.processException(ex, CLASS_NAME + ".registerServant", "439", this);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    {
                        Tr.event(tc, "Failed to register wrapper instance", new Object[] { wrapper, ex });
                    }
                }

            } // if ( ! ivBusinessRemoteRegistered[i] )

        } //synchronized( wrapper )

    }
515331
public static void initialise(AcceptListenerFactory _acceptListenerFactory) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "initalise");

        acceptListenerFactory = _acceptListenerFactory;

        // Create the maintainer of the configuration.
        Framework framework = Framework.getInstance();
        if (framework == null) {
            state = State.INITIALISATION_FAILED;
        } else {
            state = State.INITIALISED;

            // Extract the chain reference.
            connectionTracker = new OutboundConnectionTracker(framework);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "initalise");
    }
829531
public void initialize()
    {
        //
        // Register the ControlBeanContext provider on all new context instances.
        //
        addService(org.apache.beehive.controls.api.context.ControlBeanContext.class, CONTROL_BEAN_CONTEXT_PROVIDER);
    }
1139689
@Override
    public void completeInitialization()
                    throws RemoteException
    {
        enterpriseBeanClass = beanMetaData.enterpriseBeanClass;
        localEJBObjectClass = beanMetaData.localImplClass;

        // If a PreDestroy callback exists, then a weak reference cache is used
        // to keep track of instances, so PreDestroy may be called when all
        // references are dropped, or the application is uninstalled. F743-34301.1
        if (beanMetaData.ivInterceptorMetaData != null &&
            beanMetaData.ivInterceptorMetaData.ivPreDestroyInterceptors != null)
        {
            ivWeakCache = WeakManagedBeanCache.instance();
        }
    }
1142930
@Override
	public void prepare(Map stormConf, TopologyContext context,
			OutputCollector collector) {
		if(this.jmsProvider == null || this.producer == null){
			throw new IllegalStateException("JMS Provider and MessageProducer not set.");
		}
		this.collector = collector;
		LOG.debug("Connecting JMS..");
		try {
			ConnectionFactory cf = this.jmsProvider.connectionFactory();
			Destination dest = this.jmsProvider.destination();
			this.connection = cf.createConnection();
			this.session = connection.createSession(this.jmsTransactional,
					this.jmsAcknowledgeMode);
			this.messageProducer = session.createProducer(dest);
			
			connection.start();
		} catch (Exception e) {
			LOG.warn("Error creating JMS connection.", e);
		}	
	}
322387
public void init(CommsErrorListener CEL,
                   RoutingManager RM)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "init", new Object[] { CEL, RM});

    // Lock exclusively for start operations
    mpioLockManager.lockExclusive();
    _commsErrorListener = CEL;
    _routingManager = RM;
    
    synchronized(_mpConnectionsByMEConnection)
    {
      _mpConnectionsByMEUuid.clear();
      _mpConnectionsByMEConnection.clear();
    }
    
    // Create a new RemoteMessageReceiver if we don't already have one
    // or re-initialise the existing one to refresh any cached data
    // (used when an ME is re-started without the Server being re-started) 
    if(_remoteMessageReciever == null)
      _remoteMessageReciever = new RemoteMessageReceiver(_messageProcessor, this);
    else
      _remoteMessageReciever.init();
    
    started = true;    
    mpioLockManager.unlockExclusive();
          
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "init");
  }
726059
private void initRemoteCommands()
   {
      // register commands
      suspend = rpcService.registerCommand(new RemoteCommand()
      {

         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.query.SearchManager-suspend-" + wsId + "-"
               + (parentSearchManager == null);
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            suspendLocally();
            return null;
         }
      });

      resume = rpcService.registerCommand(new RemoteCommand()
      {

         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.query.SearchManager-resume-" + wsId + "-"
               + (parentSearchManager == null);
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            resumeLocally();
            return null;
         }
      });

      requestForResponsibleForResuming = rpcService.registerCommand(new RemoteCommand()
      {

         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.query.SearchManager-requestForResponsibilityForResuming-"
               + wsId + "-" + (parentSearchManager == null);
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            return isResponsibleForResuming.get();
         }
      });

      changeIndexState = rpcService.registerCommand(new RemoteCommand()
      {
         public String getId()
         {
            return "org.exoplatform.services.jcr.impl.core.query.SearchManager-changeIndexerState-" + wsId + "-"
               + (parentSearchManager == null);
         }

         public Serializable execute(Serializable[] args) throws Throwable
         {
            boolean isOnline = (Boolean)args[0];
            boolean allowQuery = (args.length == 2) ? (Boolean)args[1] : false;
            SearchManager.this.setOnline(isOnline, allowQuery, true);
            return null;
         }
      });

   }
875039
public void initalised() throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "initalised");
    
    try
    {    
      _lockManager.lockExclusive();

      // Flag that we are in a started state. 
      _started = true;
      
      // If the Neighbour Listener hasn't been created, create it
      if (_proxyListener == null)
        createProxyListener();
     
      // Indicate that reconciling is complete
      _reconciling = false;
      
      _neighbours.resetBusSubscriptionList();
    }      
    finally
    {
      _lockManager.unlockExclusive();
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "initalised"); 
  }
286005
protected function registerManagerStopCallback()
    {
        $this->swooleServer->on('ManagerStop', function () {
            $this->events->dispatch(new Events\ManagerStopped($this));

            $this->dispatchEvent('ManagerStop', $this);
        });
    }