X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-restconf-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fbroker%2FSalRemoteServiceBroker.java;h=74b23201e74bd645e132843664b8897bc6943d6c;hp=988bfd8ca51da148d0979b9eb06941368ba2ace3;hb=082d7ba433b85d5810c50f624d2691088336e66a;hpb=ed237395f6e2e4834f20c982ab1a4a1a7260b18a diff --git a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/SalRemoteServiceBroker.java b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/SalRemoteServiceBroker.java index 988bfd8ca5..74b23201e7 100644 --- a/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/SalRemoteServiceBroker.java +++ b/opendaylight/md-sal/sal-restconf-broker/src/main/java/org/opendaylight/controller/sal/restconf/broker/SalRemoteServiceBroker.java @@ -8,25 +8,60 @@ package org.opendaylight.controller.sal.restconf.broker; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.controller.sal.core.api.Provider; +import com.google.common.collect.ImmutableClassToInstanceMap; +import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.BindingAwareService; +import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; +import org.opendaylight.controller.sal.restconf.broker.impl.RemoteServicesFactory; +import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext; import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import static com.google.common.base.Preconditions.checkState; -public class SalRemoteServiceBroker implements Broker,AutoCloseable { +public class SalRemoteServiceBroker implements BindingAwareBroker,AutoCloseable { - @Override - public void close() throws Exception { + private static final Logger logger = LoggerFactory.getLogger(SalRemoteServiceBroker.class.toString()); + private ImmutableClassToInstanceMap supportedConsumerServices; + + private final String identifier; + + private RpcConsumerRegistry rpcBroker; + private NotificationService notificationBroker; + private DataBrokerService dataBroker; + private final RemoteServicesFactory servicesFactory; + + public SalRemoteServiceBroker(String instanceName,RestconfClientContext clientContext){ + this.identifier = instanceName; + this.servicesFactory = new RemoteServicesFactory(clientContext); } - @Override - public ConsumerSession registerConsumer(Consumer cons, BundleContext context) { - return null; + public void start() { + logger.info("Starting Binding Aware Broker: {}", identifier); + + supportedConsumerServices = ImmutableClassToInstanceMap. builder() + .put(NotificationService.class, servicesFactory.getNotificationService()) // + .put(DataBrokerService.class,servicesFactory.getDataBrokerService() ) // + .put(RpcConsumerRegistry.class,servicesFactory.getRpcConsumerRegistry() ).build(); } + public ProviderContext registerProvider(BindingAwareProvider provider, BundleContext ctx) { + throw new UnsupportedOperationException(); + } + @Override + public void close() throws Exception { + //TODO decide if serviceFactory should close clientContext or it has to be closed by consumer + } @Override - public ProviderSession registerProvider(Provider prov, BundleContext context) { - return null; + public ConsumerContext registerConsumer(BindingAwareConsumer consumer, BundleContext ctx) { + checkState(supportedConsumerServices != null, "Broker is not initialized."); + return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices); } + }