From 178d7d60449f221af2615c361bd4fefbe338c613 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 10 Jul 2018 09:36:14 +0200 Subject: [PATCH] Remove deprecated controller.sal.core.api interfaces Broker, Consumer, Provider and related classes have been deprecated for a long time and no longer have any in-tree users. Remove them. Change-Id: I82aab628b7612e636d2c18427e5e71f93c11083f Signed-off-by: Robert Varga --- .../binding/test/util/BindingTestContext.java | 6 - .../sal/core/api/AbstractConsumer.java | 82 -------- .../sal/core/api/AbstractProvider.java | 83 -------- .../controller/sal/core/api/Broker.java | 176 ---------------- .../sal/core/api/BrokerService.java | 21 +- .../controller/sal/core/api/Consumer.java | 64 ------ .../controller/sal/core/api/Provider.java | 65 ------ .../controller/sal/dom/broker/BrokerImpl.java | 198 ------------------ .../sal/dom/broker/ConsumerContextImpl.java | 94 --------- .../sal/dom/broker/ProviderContextImpl.java | 29 --- .../sal/dom/broker/package-info.java | 8 - .../controller/sal/core/spi/BrokerModule.java | 32 --- .../core/spi/ForwardingConsumerSession.java | 38 ---- .../core/spi/ForwardingProviderSession.java | 39 ---- .../controller/sal/core/spi/package-info.java | 8 - 15 files changed, 2 insertions(+), 941 deletions(-) delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java delete mode 100644 opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java delete mode 100644 opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/package-info.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/BrokerModule.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java delete mode 100644 opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/package-info.java diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java index 29f7cd3334..a5d0b261f1 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java @@ -47,7 +47,6 @@ import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker; import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.controller.sal.dom.broker.BrokerImpl; import org.opendaylight.mdsal.binding.dom.codec.gen.impl.DataObjectSerializerGenerator; import org.opendaylight.mdsal.binding.dom.codec.gen.impl.StreamWriterGenerator; import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry; @@ -67,8 +66,6 @@ public class BindingTestContext implements AutoCloseable { private HeliumNotificationProviderServiceAdapter baNotifyImpl; - private BrokerImpl biBrokerImpl; - private final ListeningExecutorService executor; private final ClassPool classPool; @@ -214,9 +211,6 @@ public class BindingTestContext implements AutoCloseable { final ClassToInstanceMap services = MutableClassToInstanceMap.create(); services.put(DOMRpcService.class, this.domRouter); - - this.biBrokerImpl = new BrokerImpl(this.domRouter,services); - } public void startBindingNotificationBroker() { diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java deleted file mode 100644 index 2bd1235292..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.core.api; - -import java.util.Collection; -import java.util.Collections; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; - -/** - * Deprecated. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public abstract class AbstractConsumer implements Consumer, BundleActivator,ServiceTrackerCustomizer { - - private BundleContext context; - private ServiceTracker tracker; - private Broker broker; - - @Override - public final void start(final BundleContext bundleContext) throws Exception { - this.context = bundleContext; - this.startImpl(bundleContext); - tracker = new ServiceTracker<>(bundleContext, Broker.class, this); - tracker.open(); - } - - @Override - public final void stop(final BundleContext bundleContext) throws Exception { - stopImpl(bundleContext); - broker = null; - - if (tracker != null) { - tracker.close(); - } - } - - protected void startImpl(final BundleContext bundleContext) { - // NOOP - } - - protected void stopImpl(final BundleContext bundleContext) { - // NOOP - } - - @Override - public Collection getConsumerFunctionality() { - return Collections.emptySet(); - } - - - @Override - public Broker addingService(final ServiceReference reference) { - if (broker == null && context != null) { - broker = context.getService(reference); - broker.registerConsumer(this, context); - return broker; - } - - return null; - } - - @Override - public void modifiedService(final ServiceReference reference, final Broker service) { - // NOOP - } - - @Override - public void removedService(final ServiceReference reference, final Broker service) { - stopImpl(context); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java deleted file mode 100644 index 5c5abe2f05..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.core.api; - -import java.util.Collection; -import java.util.Collections; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; -import org.osgi.util.tracker.ServiceTrackerCustomizer; - -/** - * Deprecated. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public abstract class AbstractProvider implements BundleActivator, Provider,ServiceTrackerCustomizer { - - private Broker broker; - private BundleContext context; - private ServiceTracker tracker; - - @Override - public Collection getProviderFunctionality() { - return Collections.emptySet(); - } - - @Override - public final void start(final BundleContext bundleContext) throws Exception { - this.context = bundleContext; - this.startImpl(bundleContext); - tracker = new ServiceTracker<>(bundleContext, Broker.class, this); - tracker.open(); - } - - protected void startImpl(final BundleContext bundleContext) { - // NOOP - } - - protected void stopImpl(final BundleContext bundleContext) { - // NOOP - } - - @Override - public final void stop(final BundleContext bundleContext) throws Exception { - broker = null; - - if (tracker != null) { - tracker.close(); - } - - tracker = null; - stopImpl(bundleContext); - } - - @Override - public Broker addingService(final ServiceReference reference) { - if (broker == null && context != null) { - broker = context.getService(reference); - broker.registerProvider(this, context); - return broker; - } - - return null; - } - - @Override - public void modifiedService(final ServiceReference reference, final Broker service) { - // NOOP - } - - @Override - public void removedService(final ServiceReference reference, final Broker service) { - stopImpl(context); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java deleted file mode 100644 index ce64e8e7c0..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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.core.api; - -import org.osgi.framework.BundleContext; - -/** - * Core component of the SAL layer responsible for wiring the SAL consumers. - * - *

- * The responsibility of the broker is to maintain registration of SAL - * functionality {@link Consumer}s and {@link Provider}s, store provider and - * consumer specific context and functionality registration via - * {@link ConsumerSession} and provide access to infrastructure services, which - * removes direct dependencies between providers and consumers. - * - *

- * The services are exposed via session. - * - *

Session-based access

- * - *

- * The providers and consumers needs to register in order to use the - * binding-independent SAL layer and to expose functionality via SAL layer. - * - *

- * For more information about session-based access see {@link ConsumerSession} - * and {@link ProviderSession} - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public interface Broker { - - /** - * Registers the {@link Consumer}, which will use the SAL layer. - * - *

- * During the registration, the broker obtains the initial functionality - * from consumer, using the {@link Consumer#getConsumerFunctionality()}, and - * register that functionality into system and concrete infrastructure - * services. - * - *

- * Note that consumer could register additional functionality at later point - * by using service and functionality specific APIs. - * - *

- * The consumer is required to use returned session for all communication - * with broker or one of the broker services. The session is announced to - * the consumer by invoking - * {@link Consumer#onSessionInitiated(ConsumerSession)}. - * - * @param cons - * Consumer to be registered. - * @return a session specific to consumer registration - * @throws IllegalArgumentException - * If the consumer is null. - * @throws IllegalStateException - * If the consumer is already registered. - */ - ConsumerSession registerConsumer(Consumer cons); - - /* - * @deprecated Use registerConsumer(Consumer cons) instead (BundleContext is no longer used) - */ - @Deprecated - ConsumerSession registerConsumer(Consumer cons, BundleContext context); - - /** - * Registers the {@link Provider}, which will use the SAL layer. - * - *

- * During the registration, the broker obtains the initial functionality - * from consumer, using the {@link Provider#getProviderFunctionality()}, and - * register that functionality into system and concrete infrastructure - * services. - * - *

- * The consumer is required to use returned session for all - * communication with broker or one of the broker services. The session is - * announced to the consumer by invoking - * {@link Provider#onSessionInitiated(ProviderSession)}. - * - * - * @param prov - * Provider to be registered. - * @return a session unique to the provider registration. - * @throws IllegalArgumentException - * If the provider is null. - * @throws IllegalStateException - * If the consumer is already registered. - */ - ProviderSession registerProvider(Provider prov); - - /* - * @deprecated Use registerProvider(Provider cons) instead (BundleContext is no longer used) - */ - @Deprecated - ProviderSession registerProvider(Provider prov, BundleContext context); - - /** - * {@link Consumer} specific access to the SAL functionality. - * - *

- * ConsumerSession is {@link Consumer}-specific access to the SAL - * functionality and infrastructure services. - * - *

- * The session serves to store SAL context (e.g. registration of - * functionality) for the consumer and provides access to the SAL - * infrastructure services and other functionality provided by - * {@link Provider}s. - * - * - * - */ - interface ConsumerSession { - - boolean isClosed(); - - /** - * Returns a session specific instance (implementation) of requested service. - * - * @param service - * Broker service - * @return Session specific implementation of service - */ - T getService(Class service); - - /** - * Closes a session between consumer and broker. - * - *

- * The close operation unregisters a consumer and remove all registered - * functionality of the consumer from the system. - * - */ - void close(); - } - - /** - * {@link Provider} specific access to the SAL functionality. - * - *

- * ProviderSession is {@link Provider}-specific access to the SAL - * functionality and infrastructure services, which also allows for exposing - * the provider's functionality to the other {@link Consumer}s. - * - *

- * The session serves to store SAL context (e.g. registration of - * functionality) for the providers and exposes access to the SAL - * infrastructure services, dynamic functionality registration and any other - * functionality provided by other {@link Provider}s. - * - */ - interface ProviderSession extends ConsumerSession { - /** - * Closes a session between provider and SAL. - * - *

- * The close operation unregisters a provider and remove all registered - * functionality of the provider from the system. - */ - @Override - void close(); - - @Override - boolean isClosed(); - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java index 27bf9c21aa..655d5fb871 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java @@ -8,25 +8,8 @@ package org.opendaylight.controller.sal.core.api; /** - * Session-specific instance of the broker functionality. - * - *

- * BrokerService is marker interface for infrastructure services provided by the - * SAL. These services are session-specific, each {@link Provider} and - * {@link Consumer} usually has own instance of the service with it's own - * context. - * - *

- * The consumer's (or provider's) instance of specific service could be obtained - * by invoking {@link org.opendaylight.controller.sal.core.api.Broker.ConsumerSession#getService(Class)} - * method on session assigned to the consumer. - * - *

- * {@link BrokerService} and {@link Provider} may seem similar, but provider - * provides YANG model-based functionality and {@link BrokerService} exposes the - * necessary supporting functionality to implement specific functionality of - * YANG and to reuse it in the development of {@link Consumer}s and - * {@link Provider}s. + * Session-specific instance of the broker functionality. BrokerService is marker interface for infrastructure services + * provided by the SAL. * * @deprecated Use blueprint instead for code wiring. */ diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java deleted file mode 100644 index 0e398e5578..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Consumer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.core.api; - -import java.util.Collection; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; - -/** - * Defines the component of controller and supplies additional metadata. A - * component of the controller or application supplies a concrete implementation - * of this interface. - * - *

- * A user-implemented component (application) which facilitates the SAL and SAL - * services to access infrastructure services or providers' functionality. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public interface Consumer { - - /** - * Callback signaling initialization of the consumer session to the SAL. - * - *

- * The consumer MUST use the session for all communication with SAL or - * retrieving SAL infrastructure services. - * - *

- * This method is invoked by {@link Broker#registerConsumer(Consumer)} - * - * @param session - * Unique session between consumer and SAL. - */ - void onSessionInitiated(ConsumerSession session); - - /** - * Deprecated. - * - * @deprecated - no longer used or needed. Suggested implementation until removed: - * {@code - * public Collection getConsumerFunctionality() { - * return Collections.emptySet(); - * } - * } - */ - @Deprecated - Collection getConsumerFunctionality(); - - /** - * Deprecated. - * - * @deprecated - no longer used or needed - */ - @Deprecated - interface ConsumerFunctionality { - - } -} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java deleted file mode 100644 index 72968e6163..0000000000 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Provider.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.core.api; - -import java.util.Collection; -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; - -/** - * Defines the component of controller and supplies additional metadata. A - * component of the controller or application supplies a concrete implementation - * of this interface. - * - *

- * A user-implemented component (application) which facilitates the SAL and SAL - * services to access infrastructure services and to provide functionality to - * {@link Consumer}s and other providers. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public interface Provider { - - /** - * Callback signaling initialization of the provider session to the SAL. - * - *

- * The provider MUST use the session for all communication with SAL - * or retrieving SAL infrastructure services. - * - *

- * This method is invoked by {@link Broker#registerConsumer(Consumer)} - * - * @param session - * Unique session between provider and SAL. - */ - void onSessionInitiated(ProviderSession session); - - /** - * Deprecated. - * - * @deprecated - No longer used or needed. Suggested implementation until removed: - * {@code - * public Collection getProviderFunctionality() { - * return Collections.emptySet(); - * } - * } - */ - @Deprecated - Collection getProviderFunctionality(); - - /** - * Deprecated. - * - * @deprecated - no longer used or needed - */ - @Deprecated - interface ProviderFunctionality { - - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java deleted file mode 100644 index dbf08758d6..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.ImmutableClassToInstanceMap; -import com.google.common.util.concurrent.CheckedFuture; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMRpcRouter; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class BrokerImpl implements Broker, DOMRpcProviderService, DOMRpcService, AutoCloseable { - private static final Logger LOG = LoggerFactory.getLogger(BrokerImpl.class); - - // Broker Generic Context - private final Set sessions = Collections - .synchronizedSet(new HashSet()); - private final Set providerSessions = Collections - .synchronizedSet(new HashSet()); - - private AutoCloseable deactivator; - - private final DOMRpcService rpcService; - private final DOMRpcProviderService rpcProvider; - - private final ClassToInstanceMap services; - - public BrokerImpl(final DOMRpcRouter router,final ClassToInstanceMap services) { - this(router, router, services); - } - - public BrokerImpl(final DOMRpcService rpcService, final DOMRpcProviderService rpcProvider, - final ClassToInstanceMap services) { - this.rpcService = Preconditions.checkNotNull(rpcService, "DOMRpcService must not be null"); - this.rpcProvider = Preconditions.checkNotNull(rpcProvider, "DOMRpcProviderService must not be null"); - this.services = ImmutableClassToInstanceMap.copyOf(services); - } - - @Override - public ConsumerSession registerConsumer(final Consumer consumer, - final BundleContext ctx) { - return registerConsumer(consumer); - } - - @Override - public ConsumerSession registerConsumer(final Consumer consumer) { - checkPredicates(consumer); - LOG.trace("Registering consumer {}", consumer); - final ConsumerContextImpl session = newSessionFor(consumer); - consumer.onSessionInitiated(session); - sessions.add(session); - return session; - } - - @Override - public ProviderSession registerProvider(final Provider provider, - final BundleContext ctx) { - return registerProvider(provider); - } - - @Override - public ProviderSession registerProvider(final Provider provider) { - checkPredicates(provider); - final ProviderContextImpl session = newSessionFor(provider); - provider.onSessionInitiated(session); - providerSessions.add(session); - return session; - } - - // Validation - private void checkPredicates(final Provider prov) { - Preconditions.checkNotNull(prov, "Provider should not be null."); - synchronized (providerSessions) { - for (final ProviderContextImpl session : providerSessions) { - if (prov.equals(session.getProvider())) { - throw new IllegalStateException("Provider already registered"); - } - } - } - - } - - private void checkPredicates(final Consumer cons) { - Preconditions.checkNotNull(cons, "Consumer should not be null."); - synchronized (sessions) { - for (final ConsumerContextImpl session : sessions) { - if (cons.equals(session.getConsumer())) { - throw new IllegalStateException("Consumer already registered"); - } - } - } - } - - // Private Factory methods - private ConsumerContextImpl newSessionFor(final Consumer provider) { - final ConsumerContextImpl ret = new ConsumerContextImpl(provider, this); - return ret; - } - - private ProviderContextImpl newSessionFor(final Provider provider) { - final ProviderContextImpl ret = new ProviderContextImpl(provider, this); - return ret; - } - - protected void consumerSessionClosed( - final ConsumerContextImpl consumerContextImpl) { - sessions.remove(consumerContextImpl); - providerSessions.remove(consumerContextImpl); - } - - @Override - public void close() throws Exception { - if (deactivator != null) { - deactivator.close(); - deactivator = null; - } - } - - /** - * Gets deactivator. - * - * @return the deactivator - */ - public AutoCloseable getDeactivator() { - return deactivator; - } - - /** - * Sets deactivator. - * - * @param deactivator - * the deactivator to set - */ - public void setDeactivator(final AutoCloseable deactivator) { - this.deactivator = deactivator; - } - - protected Optional getGlobalService(final Class service) { - return Optional.fromNullable(services.getInstance(service)); - } - - @Nonnull - @Override - public DOMRpcImplementationRegistration registerRpcImplementation( - @Nonnull final T implementation, @Nonnull final DOMRpcIdentifier... rpcs) { - return rpcProvider.registerRpcImplementation(implementation, rpcs); - } - - @Nonnull - @Override - public DOMRpcImplementationRegistration registerRpcImplementation( - @Nonnull final T implementation, @Nonnull final Set rpcs) { - return rpcProvider.registerRpcImplementation(implementation, rpcs); - } - - @Nonnull - @Override - public CheckedFuture invokeRpc(@Nonnull final SchemaPath type, - @Nullable final NormalizedNode input) { - return rpcService.invokeRpc(type, input); - } - - @Nonnull - @Override - public ListenerRegistration registerRpcListener( - @Nonnull final T listener) { - return rpcService.registerRpcListener(listener); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java deleted file mode 100644 index 0e0088f62a..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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 com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.ClassToInstanceMap; -import com.google.common.collect.MutableClassToInstanceMap; -import java.util.Collection; -import java.util.concurrent.atomic.AtomicBoolean; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.controller.sal.dom.broker.osgi.AbstractBrokerServiceProxy; -import org.opendaylight.controller.sal.dom.broker.osgi.ProxyFactory; - -@Deprecated -class ConsumerContextImpl implements ConsumerSession { - - private final ClassToInstanceMap instantiatedServices = MutableClassToInstanceMap.create(); - private final Consumer consumer; - - private final BrokerImpl broker; - private final AtomicBoolean closed = new AtomicBoolean(false); - - ConsumerContextImpl(final Consumer provider, final BrokerImpl brokerImpl) { - broker = brokerImpl; - consumer = provider; - } - - @Override - public T getService(final Class service) { - checkNotClosed(); - final T localProxy = instantiatedServices.getInstance(service); - if (localProxy != null) { - return localProxy; - } - final Optional serviceImpl = broker.getGlobalService(service); - if (serviceImpl.isPresent()) { - final T ret = ProxyFactory.createProxy(null, serviceImpl.get()); - instantiatedServices.putInstance(service, ret); - return ret; - } else { - return null; - } - } - - @Override - public void close() { - if (closed.compareAndSet(false, true)) { - Collection toStop = instantiatedServices.values(); - for (BrokerService brokerService : toStop) { - if (brokerService instanceof AbstractBrokerServiceProxy) { - ((AbstractBrokerServiceProxy) brokerService).close(); - } - } - broker.consumerSessionClosed(this); - } - } - - - @Override - public boolean isClosed() { - return closed.get(); - } - - /** - * Gets broker. - * - * @return the broker - */ - protected final BrokerImpl getBrokerChecked() { - checkNotClosed(); - return broker; - } - - /** - * Gets consumer. - * - * @return the _consumer - */ - public Consumer getConsumer() { - return consumer; - } - - protected final void checkNotClosed() { - Preconditions.checkState(!closed.get(), "Session is closed."); - } -} 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 deleted file mode 100644 index 836e72cba8..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Provider; - -@Deprecated -class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession { - private final Provider provider; - - ProviderContextImpl(final Provider provider, final BrokerImpl broker) { - super(null, broker); - this.provider = provider; - } - - @Override - public void close() { - } - - public Provider getProvider() { - return provider; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/package-info.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/package-info.java deleted file mode 100644 index 97931089cb..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/BrokerModule.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/BrokerModule.java deleted file mode 100644 index d91a136880..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/BrokerModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.core.spi; - -import java.util.Set; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality; -import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality; - -/** - * Deprecated. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public interface BrokerModule { - - Set> getProvidedServices(); - - Set> getSupportedConsumerFunctionality(); - - T getServiceForSession(Class service, - ConsumerSession session); - - Set> getSupportedProviderFunctionality(); -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java deleted file mode 100644 index c76ee64b1f..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingConsumerSession.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2015 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.core.spi; - -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.core.api.BrokerService; - -/** - * Deprecated. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public abstract class ForwardingConsumerSession implements ConsumerSession { - - protected abstract ConsumerSession delegate(); - - @Override - public void close() { - delegate().close(); - } - - @Override - public T getService(Class arg0) { - return delegate().getService(arg0); - } - - @Override - public boolean isClosed() { - return delegate().isClosed(); - } - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java deleted file mode 100644 index ecd6785df7..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/ForwardingProviderSession.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015 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.core.spi; - -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.BrokerService; - -/** - * Deprecated. - * - * @deprecated Use blueprint instead for code wiring. - */ -@Deprecated -public abstract class ForwardingProviderSession implements ProviderSession { - - protected abstract ProviderSession delegate(); - - @Override - public void close() { - delegate().close(); - } - - @Override - public T getService(Class arg0) { - return delegate().getService(arg0); - } - - @Override - public boolean isClosed() { - return delegate().isClosed(); - } - -} diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/package-info.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/package-info.java deleted file mode 100644 index 6cab2a8749..0000000000 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/* - * 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.core.spi; \ No newline at end of file -- 2.36.6