Search in sources :

Example 1 with ControlledProcessStateService

use of org.jboss.as.controller.ControlledProcessStateService in project wildfly by wildfly.

the class Host method start.

@Override
public void start(StartContext context) throws StartException {
    ControlledProcessStateService controlledProcessStateService = controlledProcessStateServiceInjectedValue.getValue();
    //may be null for tests
    if (controlledProcessStateService != null && controlledProcessStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
        gateHandlerWrapper = new GateHandlerWrapper();
        controlledProcessStateService.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                controlledProcessStateService.removePropertyChangeListener(this);
                if (gateHandlerWrapper != null) {
                    gateHandlerWrapper.open();
                    gateHandlerWrapper = null;
                }
                rootHandler = null;
            }
        });
    }
    server.getValue().registerHost(this);
    UndertowLogger.ROOT_LOGGER.hostStarting(name);
}
Also used : ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) GateHandlerWrapper(org.wildfly.extension.undertow.deployment.GateHandlerWrapper) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 2 with ControlledProcessStateService

use of org.jboss.as.controller.ControlledProcessStateService in project wildfly by wildfly.

the class EJBRemoteConnectorService method start.

@Override
public void start(StartContext context) throws StartException {
    final AssociationService associationService = associationServiceInjectedValue.getValue();
    final Endpoint endpoint = endpointValue.getValue();
    Executor executor = executorService.getOptionalValue();
    if (executor != null) {
        associationService.setExecutor(executor);
    }
    RemoteEJBService remoteEJBService = RemoteEJBService.create(associationService.getAssociation(), remotingTransactionServiceInjectedValue.getValue());
    final ControlledProcessStateService processStateService = controlledProcessStateServiceInjectedValue.getValue();
    if (processStateService.getCurrentState() == ControlledProcessState.State.STARTING) {
        final PropertyChangeListener listener = new PropertyChangeListener() {

            public void propertyChange(final PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("currentState") && evt.getOldValue() == ControlledProcessState.State.STARTING) {
                    remoteEJBService.serverUp();
                    // can't use a lambda because of this line...
                    processStateService.removePropertyChangeListener(this);
                }
            }
        };
        processStateService.addPropertyChangeListener(listener);
        // this is actually racy, so we have to double-check the state afterwards just to be sure it didn't transition before we got here.
        if (processStateService.getCurrentState() != ControlledProcessState.State.STARTING) {
            // this method is idempotent so it's OK if the listener got fired
            remoteEJBService.serverUp();
            // this one too
            processStateService.removePropertyChangeListener(listener);
        }
    } else {
        remoteEJBService.serverUp();
    }
    // Register an EJB channel open listener
    OpenListener channelOpenListener = remoteEJBService.getOpenListener();
    try {
        registration = endpoint.registerService(EJB_CHANNEL_NAME, channelOpenListener, this.channelCreationOptions);
    } catch (ServiceRegistrationException e) {
        throw new StartException(e);
    }
}
Also used : RemoteEJBService(org.jboss.ejb.protocol.remote.RemoteEJBService) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) PropertyChangeEvent(java.beans.PropertyChangeEvent) Executor(java.util.concurrent.Executor) Endpoint(org.jboss.remoting3.Endpoint) PropertyChangeListener(java.beans.PropertyChangeListener) OpenListener(org.jboss.remoting3.OpenListener) ServiceRegistrationException(org.jboss.remoting3.ServiceRegistrationException) StartException(org.jboss.msc.service.StartException)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 ControlledProcessStateService (org.jboss.as.controller.ControlledProcessStateService)2 Executor (java.util.concurrent.Executor)1 RemoteEJBService (org.jboss.ejb.protocol.remote.RemoteEJBService)1 StartException (org.jboss.msc.service.StartException)1 Endpoint (org.jboss.remoting3.Endpoint)1 OpenListener (org.jboss.remoting3.OpenListener)1 ServiceRegistrationException (org.jboss.remoting3.ServiceRegistrationException)1 GateHandlerWrapper (org.wildfly.extension.undertow.deployment.GateHandlerWrapper)1