summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/provider')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java66
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProvider.java39
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderRegistry.java111
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderService.java61
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/Provider.java30
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderId.java135
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderRegistry.java57
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderService.java33
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/package-info.java20
9 files changed, 0 insertions, 552 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java
deleted file mode 100644
index ff67c6da..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractListenerProviderRegistry.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onosproject.event.Event;
-import org.onosproject.event.EventDeliveryService;
-import org.onosproject.event.EventListener;
-import org.onosproject.event.ListenerRegistry;
-import org.onosproject.event.ListenerService;
-
-/**
- * Basis for components which need to export listener mechanism.
- */
-@Component(componentAbstract = true)
-public abstract class AbstractListenerProviderRegistry<E extends Event, L extends EventListener<E>,
- P extends Provider, S extends ProviderService<P>>
- extends AbstractProviderRegistry<P, S> implements ListenerService<E, L> {
-
- // If only Java supported mixins...
-
- protected final ListenerRegistry<E, L> listenerRegistry = new ListenerRegistry<>();
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected EventDeliveryService eventDispatcher;
-
- @Override
- public void addListener(L listener) {
- listenerRegistry.addListener(listener);
- }
-
- @Override
- public void removeListener(L listener) {
- listenerRegistry.removeListener(listener);
- }
-
-
- /**
- * Safely posts the specified event to the local event dispatcher.
- * If there is no event dispatcher or if the event is null, this method
- * is a noop.
- *
- * @param event event to be posted; may be null
- */
- protected void post(E event) {
- if (event != null && eventDispatcher != null) {
- eventDispatcher.post(event);
- }
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProvider.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProvider.java
deleted file mode 100644
index a4926dd3..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-/**
- * Base provider implementation.
- */
-public abstract class AbstractProvider implements Provider {
-
- private final ProviderId providerId;
-
- /**
- * Creates a provider with the supplier identifier.
- *
- * @param id provider id
- */
- protected AbstractProvider(ProviderId id) {
- this.providerId = id;
- }
-
- @Override
- public ProviderId id() {
- return providerId;
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderRegistry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderRegistry.java
deleted file mode 100644
index bcf5fae0..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderRegistry.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.net.DeviceId;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * Base implementation of provider registry.
- *
- * @param <P> type of the information provider
- * @param <S> type of the provider service
- */
-public abstract class AbstractProviderRegistry<P extends Provider, S extends ProviderService<P>>
- implements ProviderRegistry<P, S> {
-
- private final Map<ProviderId, P> providers = new HashMap<>();
- private final Map<ProviderId, S> services = new HashMap<>();
- private final Map<String, P> providersByScheme = new HashMap<>();
-
- /**
- * Creates a new provider service bound to the specified provider.
- *
- * @param provider provider
- * @return provider service
- */
- protected abstract S createProviderService(P provider);
-
- @Override
- public synchronized S register(P provider) {
- checkNotNull(provider, "Provider cannot be null");
- checkState(!services.containsKey(provider.id()), "Provider %s already registered", provider.id());
-
- // If the provider is a primary one, check for a conflict.
- ProviderId pid = provider.id();
- checkState(pid.isAncillary() || !providersByScheme.containsKey(pid.scheme()),
- "A primary provider with id %s is already registered",
- providersByScheme.get(pid.scheme()));
-
- S service = createProviderService(provider);
- services.put(provider.id(), service);
- providers.put(provider.id(), provider);
-
- // Register the provider by URI scheme only if it is not ancillary.
- if (!pid.isAncillary()) {
- providersByScheme.put(pid.scheme(), provider);
- }
-
- return service;
- }
-
- @Override
- public synchronized void unregister(P provider) {
- checkNotNull(provider, "Provider cannot be null");
- S service = services.get(provider.id());
- if (service != null && service instanceof AbstractProviderService) {
- ((AbstractProviderService) service).invalidate();
- services.remove(provider.id());
- providers.remove(provider.id());
- if (!provider.id().isAncillary()) {
- providersByScheme.remove(provider.id().scheme());
- }
- }
- }
-
- @Override
- public synchronized Set<ProviderId> getProviders() {
- return ImmutableSet.copyOf(services.keySet());
- }
-
- /**
- * Returns the provider registered with the specified provider ID.
- *
- * @param providerId provider identifier
- * @return provider
- */
- protected synchronized P getProvider(ProviderId providerId) {
- return providers.get(providerId);
- }
-
- /**
- * Returns the provider for the specified device ID based on URI scheme.
- *
- * @param deviceId device identifier
- * @return provider bound to the URI scheme
- */
- protected synchronized P getProvider(DeviceId deviceId) {
- return providersByScheme.get(deviceId.uri().getScheme());
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderService.java
deleted file mode 100644
index 6c926d88..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/AbstractProviderService.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * Base implementation of a provider service, which tracks the provider to
- * which it is issued and can be invalidated.
- *
- * @param <P> type of the information provider
- */
-public abstract class AbstractProviderService<P extends Provider> implements ProviderService<P> {
-
- private boolean isValid = true;
- private final P provider;
-
- /**
- * Creates a provider service on behalf of the specified provider.
- *
- * @param provider provider to which this service is being issued
- */
- protected AbstractProviderService(P provider) {
- this.provider = provider;
- }
-
- /**
- * Invalidates this provider service.
- */
- public void invalidate() {
- isValid = false;
- }
-
- /**
- * Checks the validity of this provider service.
- *
- * @throws java.lang.IllegalStateException if the service is no longer valid
- */
- public void checkValidity() {
- checkState(isValid, "Provider service is no longer valid");
- }
-
- @Override
- public P provider() {
- return provider;
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/Provider.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/Provider.java
deleted file mode 100644
index 84465ab7..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/Provider.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-/**
- * Abstraction of a provider of information about network environment.
- */
-public interface Provider {
-
- /**
- * Returns the provider identifier.
- *
- * @return provider identification
- */
- ProviderId id();
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderId.java
deleted file mode 100644
index 2c959afd..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderId.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * External identity of a {@link org.onosproject.net.provider.Provider} family.
- * It also carriers two designations of external characteristics, the URI
- * scheme and primary/ancillary indicator.
- * <p>
- * The device URI scheme is used to determine applicability of a provider to
- * operations on a specific device. The ancillary indicator serves to designate
- * a provider as a primary or ancillary.
- * </p>
- * <p>
- * A {@link org.onosproject.net.provider.ProviderRegistry} uses this designation
- * to permit only one primary provider per device URI scheme. Multiple
- * ancillary providers can register with the same device URI scheme however.
- * </p>
- */
-public class ProviderId {
-
- /**
- * Represents no provider ID.
- */
- public static final ProviderId NONE = new ProviderId("none", "none");
-
- private final String scheme;
- private final String id;
- private final boolean ancillary;
-
- // For serialization
- private ProviderId() {
- scheme = null;
- id = null;
- ancillary = false;
- }
-
- /**
- * Creates a new primary provider identifier from the specified string.
- * The providers are expected to follow the reverse DNS convention, e.g.
- * {@code org.onosproject.provider.of.device}
- *
- * @param scheme device URI scheme to which this provider is bound, e.g. "of", "snmp"
- * @param id string identifier
- */
- public ProviderId(String scheme, String id) {
- this(scheme, id, false);
- }
-
- /**
- * Creates a new provider identifier from the specified string.
- * The providers are expected to follow the reverse DNS convention, e.g.
- * {@code org.onosproject.provider.of.device}
- *
- * @param scheme device URI scheme to which this provider is bound, e.g. "of", "snmp"
- * @param id string identifier
- * @param ancillary ancillary provider indicator
- */
- public ProviderId(String scheme, String id, boolean ancillary) {
- this.scheme = checkNotNull(scheme, "Scheme cannot be null");
- this.id = checkNotNull(id, "ID cannot be null");
- this.ancillary = ancillary;
- }
-
- /**
- * Returns the device URI scheme to which this provider is bound.
- *
- * @return device URI scheme
- */
- public String scheme() {
- return scheme;
- }
-
- /**
- * Returns the device URI scheme specific id portion.
- *
- * @return id
- */
- public String id() {
- return id;
- }
-
- /**
- * Indicates whether this identifier designates an ancillary providers.
- *
- * @return true if the provider is ancillary; false if primary
- */
- public boolean isAncillary() {
- return ancillary;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(scheme, id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof ProviderId) {
- final ProviderId other = (ProviderId) obj;
- return Objects.equals(this.scheme, other.scheme) &&
- Objects.equals(this.id, other.id) &&
- this.ancillary == other.ancillary;
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("scheme", scheme).add("id", id)
- .add("ancillary", ancillary).toString();
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderRegistry.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderRegistry.java
deleted file mode 100644
index 3c2009ad..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderRegistry.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-import java.util.Set;
-
-/**
- * Registry for tracking information providers with the core.
- *
- * @param <P> type of the information provider
- * @param <S> type of the provider service
- */
-public interface ProviderRegistry<P extends Provider, S extends ProviderService<P>> {
-
- /**
- * Registers the supplied provider with the core.
- *
- * @param provider provider to be registered
- * @return provider service for injecting information into core
- * @throws java.lang.IllegalArgumentException if the provider is registered already
- */
- S register(P provider);
-
- /**
- * Unregisters the supplied provider. As a result the previously issued
- * provider service will be invalidated and any subsequent invocations
- * of its methods may throw {@link java.lang.IllegalStateException}.
- * <p>
- * Unregistering a provider that has not been previously registered results
- * in a no-op.
- * </p>
- *
- * @param provider provider to be unregistered
- */
- void unregister(P provider);
-
- /**
- * Returns a set of currently registered provider identities.
- *
- * @return set of provider identifiers
- */
- Set<ProviderId> getProviders();
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderService.java
deleted file mode 100644
index 5c469276..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/ProviderService.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.provider;
-
-/**
- * Abstraction of a service through which providers can inject information
- * about the network environment into the core.
- *
- * @param <P> type of the information provider
- */
-public interface ProviderService<P extends Provider> {
-
- /**
- * Returns the provider to which this service has been issued.
- *
- * @return provider to which this service has been assigned
- */
- P provider();
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/package-info.java
deleted file mode 100644
index d279f56a..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/provider/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Base abstractions related to network entity providers and their brokers.
- */
-package org.onosproject.net.provider;