use of org.wildfly.discovery.ServiceRegistration in project wildfly by wildfly.
the class AssociationService method start.
public void start(final StartContext context) throws StartException {
// todo suspendController
value = new AssociationImpl(deploymentRepositoryInjector.getValue(), registryCollectorInjector.getValue());
// register the fact that the local receiver can handle invocations targeted at its node name
final ServiceURL.Builder builder = new ServiceURL.Builder();
builder.setAbstractType("ejb").setAbstractTypeAuthority("jboss");
builder.setUri(Affinity.LOCAL.getUri());
builder.addAttribute(EJBClientContext.FILTER_ATTR_NODE, AttributeValue.fromString(serverEnvironmentServiceInjector.getValue().getNodeName()));
serviceRegistration = getLocalRegistryProvider().registerService(builder.create());
// track deployments at an association level for local dispatchers to utilize
handle = value.registerModuleAvailabilityListener(new ModuleAvailabilityListener() {
private final ConcurrentHashMap<ModuleIdentifier, ServiceRegistration> map = new ConcurrentHashMap<ModuleIdentifier, ServiceRegistration>();
public void moduleAvailable(final List<ModuleIdentifier> modules) {
for (ModuleIdentifier module : modules) {
final String appName = module.getAppName();
final String moduleName = module.getModuleName();
final String distinctName = module.getDistinctName();
final ServiceURL.Builder builder = new ServiceURL.Builder();
builder.setUri(Affinity.LOCAL.getUri());
builder.setAbstractType("ejb");
builder.setAbstractTypeAuthority("jboss");
if (distinctName.isEmpty()) {
if (appName.isEmpty()) {
builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(moduleName));
} else {
builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(appName + "/" + moduleName));
}
} else {
if (appName.isEmpty()) {
builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(moduleName + "/" + distinctName));
} else {
builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(appName + "/" + moduleName + "/" + distinctName));
}
}
final ServiceRegistration serviceRegistration = localRegistry.registerService(builder.create());
// should never conflict normally!
map.putIfAbsent(module, serviceRegistration);
}
}
public void moduleUnavailable(final List<ModuleIdentifier> modules) {
for (ModuleIdentifier module : modules) {
map.computeIfPresent(module, (i, old) -> {
old.close();
return null;
});
}
}
});
}
Aggregations