Search in sources :

Example 1 with DeploymentRepositoryListener

use of org.jboss.as.ejb3.deployment.DeploymentRepositoryListener in project wildfly by wildfly.

the class AssociationImpl method registerModuleAvailabilityListener.

@Override
public ListenerHandle registerModuleAvailabilityListener(@NotNull final ModuleAvailabilityListener moduleAvailabilityListener) {
    final DeploymentRepositoryListener listener = new DeploymentRepositoryListener() {

        @Override
        public void listenerAdded(final DeploymentRepository repository) {
            List<EJBModuleIdentifier> list = new ArrayList<>();
            if (!repositoryIsSuspended()) {
                // only send out the initial list if the deployment repository (i.e. the server + clean transaction state) is not in a suspended state
                for (DeploymentModuleIdentifier deploymentModuleIdentifier : repository.getModules().keySet()) {
                    EJBModuleIdentifier ejbModuleIdentifier = toModuleIdentifier(deploymentModuleIdentifier);
                    list.add(ejbModuleIdentifier);
                }
                EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Sending initial module availability to connecting client: server is not suspended");
            } else {
                // send out empty list if the deploymentRepository is suspended
                EjbLogger.EJB3_INVOCATION_LOGGER.debugf("Sending empty initial module availability to connecting client: server is suspended");
            }
            moduleAvailabilityListener.moduleAvailable(list);
        }

        @Override
        public void deploymentAvailable(final DeploymentModuleIdentifier deployment, final ModuleDeployment moduleDeployment) {
        }

        @Override
        public void deploymentStarted(final DeploymentModuleIdentifier deployment, final ModuleDeployment moduleDeployment) {
            // only send out moduleAvailability until module has started (WFLY-13009)
            moduleAvailabilityListener.moduleAvailable(Collections.singletonList(toModuleIdentifier(deployment)));
        }

        @Override
        public void deploymentRemoved(final DeploymentModuleIdentifier deployment) {
            moduleAvailabilityListener.moduleUnavailable(Collections.singletonList(toModuleIdentifier(deployment)));
        }

        @Override
        public void deploymentSuspended(DeploymentModuleIdentifier deployment) {
            moduleAvailabilityListener.moduleUnavailable(Collections.singletonList(toModuleIdentifier(deployment)));
        }

        @Override
        public void deploymentResumed(DeploymentModuleIdentifier deployment) {
            moduleAvailabilityListener.moduleAvailable(Collections.singletonList(toModuleIdentifier(deployment)));
        }

        private boolean repositoryIsSuspended() {
            return deploymentRepository.isSuspended();
        }
    };
    deploymentRepository.addListener(listener);
    return () -> deploymentRepository.removeListener(listener);
}
Also used : ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) EJBModuleIdentifier(org.jboss.ejb.client.EJBModuleIdentifier) DeploymentRepositoryListener(org.jboss.as.ejb3.deployment.DeploymentRepositoryListener) ArrayList(java.util.ArrayList) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository)

Aggregations

ArrayList (java.util.ArrayList)1 DeploymentModuleIdentifier (org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier)1 DeploymentRepository (org.jboss.as.ejb3.deployment.DeploymentRepository)1 DeploymentRepositoryListener (org.jboss.as.ejb3.deployment.DeploymentRepositoryListener)1 ModuleDeployment (org.jboss.as.ejb3.deployment.ModuleDeployment)1 EJBModuleIdentifier (org.jboss.ejb.client.EJBModuleIdentifier)1