use of org.jboss.ejb.protocol.remote.RemoteEJBService 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);
}
}
Aggregations