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);
}
Aggregations