Provider, //
AutoCloseable {
+
+
private final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class);
@SuppressWarnings( "deprecation")
}
} catch (Exception e) {
- LOG.error("Could not forward Rpcs of type {}", service.getName());
+ LOG.error("Could not forward Rpcs of type {}", service.getName(),e);
}
registrations = ImmutableSet.of();
}
} else {
strategy = new NoInputNoOutputInvocationStrategy(rpc,targetMethod);
}
+ } else if(inputClass.isPresent()){
+ strategy = new NoOutputInvocationStrategy(rpc,targetMethod, inputClass.get());
} else {
- strategy = null;
+ strategy = new NoInputNoOutputInvocationStrategy(rpc,targetMethod);
}
return strategy;
}
return Futures.immediateFuture(null);
}
}
+
+ private class NoOutputInvocationStrategy extends RpcInvocationStrategy {
+
+
+ @SuppressWarnings("rawtypes")
+ private WeakReference<Class> inputClass;
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public NoOutputInvocationStrategy(QName rpc, Method targetMethod,
+ Class<? extends DataContainer> inputClass) {
+ super(rpc,targetMethod);
+ this.inputClass = new WeakReference(inputClass);
+ }
+
+
+ @Override
+ public RpcResult<CompositeNode> uncheckedInvoke(RpcService rpcService, CompositeNode domInput) throws Exception {
+ DataContainer bindingInput = mappingService.dataObjectFromDataDom(inputClass.get(), domInput);
+ Future<RpcResult<?>> result = (Future<RpcResult<?>>) targetMethod.invoke(rpcService, bindingInput);
+ if (result == null) {
+ return Rpcs.getRpcResult(false);
+ }
+ RpcResult<?> bindingResult = result.get();
+ return Rpcs.getRpcResult(true);
+ }
+
+ @Override
+ public Future<RpcResult<?>> forwardToDomBroker(DataObject input) {
+ if(biRouter != null) {
+ CompositeNode xml = mappingService.toDataDom(input);
+ CompositeNode wrappedXml = ImmutableCompositeNode.create(rpc,ImmutableList.<Node<?>>of(xml));
+ RpcResult<CompositeNode> result = biRouter.invokeRpc(rpc, wrappedXml);
+ Object baResultValue = null;
+ RpcResult<?> baResult = Rpcs.<Void>getRpcResult(result.isSuccessful(), null, result.getErrors());
+ return Futures.<RpcResult<?>>immediateFuture(baResult);
+ }
+ return Futures.<RpcResult<?>>immediateFuture(Rpcs.getRpcResult(false));
+ }
+
+ }
public boolean isRpcForwarding() {
return rpcForwarding;
}
public boolean isNotificationForwarding() {
- // TODO Auto-generated method stub
return notificationForwarding;
}
import org.osgi.framework.BundleContext
import org.osgi.framework.ServiceRegistration
import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
class BrokerConfigActivator implements AutoCloseable {
@Property
private var DataBrokerImpl dataService;
- private var ServiceRegistration<SchemaService> schemaReg;
private var ServiceRegistration<DataBrokerService> dataReg;
private var ServiceRegistration<DataProviderService> dataProviderReg;
private var ServiceRegistration<MountService> mountReg;
private var ServiceRegistration<MountProvisionService> mountProviderReg;
private var SchemaService schemaService;
+ private var ServiceRegistration<RpcProvisionRegistry> rpcProvisionRegistryReg;
private var MountPointManagerImpl mountService;
SchemaAwareDataStoreAdapter wrappedStore
val serviceRef = context.getServiceReference(SchemaService);
schemaService = context.getService(serviceRef);
- schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
broker.setRouter(new SchemaAwareRpcBroker("/", SchemaContextProviders.fromSchemaService(schemaService)));
mountReg = context.registerService(MountService, mountService, emptyProperties);
mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
+
+ rpcProvisionRegistryReg = context.registerService(RpcProvisionRegistry, broker.getRouter(), emptyProperties);
}
override def close() {
- schemaReg?.unregister();
dataReg?.unregister();
dataProviderReg?.unregister();
mountReg?.unregister();
mountProviderReg?.unregister();
+ rpcProvisionRegistryReg?.unregister();
}
}
RpcDefinition definition = findRpcDefinition(rpcType);
checkArgument(!isRoutedRpc(definition), "RPC Type must not be routed.");
GlobalRpcRegistration reg = new GlobalRpcRegistration(rpcType, implementation, this);
+ implementations.putIfAbsent(rpcType, implementation);
return reg;
}
import org.opendaylight.controller.sal.core.api.notify.NotificationService
import org.opendaylight.controller.sal.core.api.model.SchemaService
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry
class ProxyFactory {
new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
}
+ private static def dispatch createProxyImpl(ServiceReference<?> ref, RpcProvisionRegistry service) {
+ new RpcProvisionRegistryProxy(ref as ServiceReference<RpcProvisionRegistry>, service);
+ }
+
private static def dispatch createProxyImpl(ServiceReference<?> reference, BrokerService service) {
throw new IllegalArgumentException("Not supported class");
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.sal.dom.broker.osgi;
+
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.core.api.Broker;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
+import org.opendaylight.controller.sal.core.api.RpcRoutingContext;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.osgi.framework.ServiceReference;
+
+public class RpcProvisionRegistryProxy extends AbstractBrokerServiceProxy<RpcProvisionRegistry>
+ implements RpcProvisionRegistry {
+
+ public RpcProvisionRegistryProxy(ServiceReference<RpcProvisionRegistry> ref, RpcProvisionRegistry delegate) {
+ super(ref, delegate);
+ }
+
+ @Override
+ public Broker.RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException {
+ return getDelegate().addRpcImplementation(rpcType, implementation);
+ }
+
+ @Override
+ public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener) {
+ return getDelegate().addRpcRegistrationListener(listener);
+ }
+
+ @Override
+ public Broker.RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
+ return getDelegate().addRoutedRpcImplementation(rpcType, implementation);
+ }
+
+ @Override
+ public <L extends RouteChangeListener<RpcRoutingContext, InstanceIdentifier>> ListenerRegistration<L> registerRouteChangeListener(L listener) {
+ return getDelegate().registerRouteChangeListener(listener);
+ }
+}