use of org.wildfly.discovery.impl.StaticDiscoveryProvider in project wildfly by wildfly.
the class DiscoveryRegistrationProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
// we only process top level deployment units
if (deploymentUnit.getParent() != null) {
return;
}
final ServiceName profileServiceName = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME);
final DiscoveryService discoveryService = new DiscoveryService();
final ServiceName discoveryServiceName = DiscoveryService.BASE_NAME.append(deploymentUnit.getName());
final ServiceBuilder<Discovery> builder = phaseContext.getServiceTarget().addService(discoveryServiceName, discoveryService);
Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();
new RemoteEJBDiscoveryConfigurator().configure(providerInjector::inject, registryProvider -> {
});
if (profileServiceName != null)
builder.addDependency(profileServiceName, RemotingProfileService.class, new Injector<RemotingProfileService>() {
Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();
public void inject(final RemotingProfileService value) throws InjectionException {
providerInjector.inject(new StaticDiscoveryProvider(value.getServiceUrls()));
}
public void uninject() {
providerInjector.uninject();
}
});
providerInjector = discoveryService.getDiscoveryProviderInjector();
new HttpDiscoveryConfigurator().configure(providerInjector::inject, registryProvider -> {
});
// only add association service dependency if the context is configured to use the local EJB receiver & we are not app client
final EJBClientDescriptorMetaData ejbClientDescriptorMetaData = deploymentUnit.getAttachment(Attachments.EJB_CLIENT_METADATA);
final boolean useLocalReceiver = ejbClientDescriptorMetaData == null || ejbClientDescriptorMetaData.isLocalReceiverExcluded() != Boolean.TRUE;
if (useLocalReceiver && !appClient) {
builder.addDependency(AssociationService.SERVICE_NAME, AssociationService.class, new Injector<AssociationService>() {
Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();
public void inject(final AssociationService value) throws InjectionException {
providerInjector.inject(value.getLocalDiscoveryProvider());
}
public void uninject() {
providerInjector.uninject();
}
});
}
builder.install();
}
Aggregations