X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2FProviderContextImpl.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2FProviderContextImpl.java;h=5e8c0e82538b4d2beacddd3366571ac2a734f7c5;hb=0cb415cf4cb61d85d545a1940bdde33734fa23a3;hp=0000000000000000000000000000000000000000;hpb=26da3c2a206a753356b507b018052cbb9cccca7d;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java new file mode 100644 index 0000000000..5e8c0e8253 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014 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; + +import java.util.HashSet; +import java.util.Set; + +import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; +import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration; +import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration; +import org.opendaylight.controller.sal.core.api.Provider; +import org.opendaylight.controller.sal.core.api.RpcImplementation; +import org.opendaylight.controller.sal.core.api.RpcRegistrationListener; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.QName; +import org.osgi.framework.BundleContext; + +class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession { + private final Set registrations = new HashSet<>(); + private final Provider provider; + + public ProviderContextImpl(final Provider provider, final BundleContext ctx) { + super(null, ctx); + this.provider = provider; + } + + @Override + public RpcRegistrationWrapper addRpcImplementation(final QName rpcType, + final RpcImplementation implementation) throws IllegalArgumentException { + final RpcRegistration origReg = getBroker().getRouter() + .addRpcImplementation(rpcType, implementation); + final RpcRegistrationWrapper newReg = new RpcRegistrationWrapper( + origReg); + registrations.add(newReg); + return newReg; + } + + protected boolean removeRpcImplementation(final RpcRegistrationWrapper implToRemove) { + return registrations.remove(implToRemove); + } + + @Override + public void close() { + for (final RpcRegistrationWrapper reg : registrations) { + reg.close(); + } + } + + @Override + public RoutedRpcRegistration addMountedRpcImplementation( + final QName rpcType, final RpcImplementation implementation) { + throw new UnsupportedOperationException( + "TODO: auto-generated method stub"); + } + + @Override + public RoutedRpcRegistration addRoutedRpcImplementation( + final QName rpcType, final RpcImplementation implementation) { + throw new UnsupportedOperationException( + "TODO: auto-generated method stub"); + } + + @Override + public Set getSupportedRpcs() { + return getBroker().getRouter().getSupportedRpcs(); + } + + @Override + public ListenerRegistration addRpcRegistrationListener( + final RpcRegistrationListener listener) { + return getBroker().getRouter().addRpcRegistrationListener(listener); + } + + /** + * @return the provider + */ + public Provider getProvider() { + return provider; + } + + /** + * @param provider + * the provider to set + */ +}