final Optional<Class<? extends RpcService>> rpcInterface = mappingService.getRpcServiceClassFor(
name.getNamespace().toString(), name.getFormattedRevision());
if (rpcInterface.isPresent()) {
- getRpcForwarder(rpcInterface.get(), null).registerToBidningBroker();
+ getRpcForwarder(rpcInterface.get(), null).registerToBindingBroker();
}
}
private final WeakHashMap<Method, RpcInvocationStrategy> strategiesByMethod = new WeakHashMap<>();
private final RpcService proxy;
private ObjectRegistration<?> forwarderRegistration;
+ private boolean registrationInProgress = false;
public DomToBindingRpcForwarder(final Class<? extends RpcService> service) {
this.rpcServiceType = new WeakReference<Class<? extends RpcService>>(service);
*
*/
public void registerToDOMBroker() {
- if(forwarderRegistration == null) {
+ if(!registrationInProgress && forwarderRegistration == null) {
+ registrationInProgress = true;
CompositeObjectRegistrationBuilder<DomToBindingRpcForwarder> builder = CompositeObjectRegistration.builderFor(this);
try {
for (QName rpc : supportedRpcs) {
LOG.error("Could not forward Rpcs of type {}", rpcServiceType.get(), e);
}
this.forwarderRegistration = builder.toInstance();
+ registrationInProgress = false;
}
}
* creating forwarding loop.
*
*/
- public void registerToBidningBroker() {
- if(forwarderRegistration == null) {
+ public void registerToBindingBroker() {
+ if(!registrationInProgress && forwarderRegistration == null) {
try {
+ registrationInProgress = true;
this.forwarderRegistration = baRpcRegistry.addRpcImplementation((Class)rpcServiceType.get(), proxy);
} catch (Exception e) {
LOG.error("Unable to forward RPCs for {}",rpcServiceType.get(),e);
+ } finally {
+ registrationInProgress = false;
}
}
}