summaryrefslogtreecommitdiffstats
path: root/infra/impl/src/main/java/io/fd
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-08-16 11:04:00 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-08-19 12:49:56 +0200
commit77fa76b4b15ec6d74920349f9a066ec4597b2585 (patch)
tree1347757ad900f096dbfaee9949a552615d4a04f4 /infra/impl/src/main/java/io/fd
parentdcd507eff53e7c0abd659da416aac91a7d29e3d3 (diff)
HONEYCOMB-22: Remove karaf based distribution and wiring
Change-Id: I48aafb726de53b6ad3fb9b97c202f712dfa4a540 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/impl/src/main/java/io/fd')
-rw-r--r--infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java114
-rw-r--r--infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java44
2 files changed, 158 insertions, 0 deletions
diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java
new file mode 100644
index 000000000..f11848ac7
--- /dev/null
+++ b/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * 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 io.fd.honeycomb.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+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.rpc.RpcContextIdentifier;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Binding aware broker wrapping just a DataBroker
+ */
+public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoCloseable {
+
+ private DataBroker netconfBindingBrokerDependency;
+
+ public FakeBindingAwareBroker(final DataBroker netconfBindingBrokerDependency) {
+
+ this.netconfBindingBrokerDependency = netconfBindingBrokerDependency;
+ }
+
+ @Deprecated
+ @Override
+ public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer,
+ final BundleContext bundleContext) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer) {
+ final ConsumerContext consumerContext = new ConsumerContext() {
+ @Override
+ public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
+ return aClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null;
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> aClass) {
+ return null;
+ }
+ };
+ bindingAwareConsumer.onSessionInitialized(consumerContext);
+ return consumerContext;
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider,
+ final BundleContext bundleContext) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider) {
+ final ProviderContext context = new ProviderContext() {
+ @Override
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+ final L l) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> aClass) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> aClass, final T t)
+ throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(
+ final Class<T> aClass, final T t) throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
+ return aClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null; }
+ };
+ bindingAwareProvider.onSessionInitiated(context);
+ return context;
+ }
+
+ @Override
+ public void close() throws Exception {
+ netconfBindingBrokerDependency = null;
+ }
+}
diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java
new file mode 100644
index 000000000..a299dbe3f
--- /dev/null
+++ b/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * 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 io.fd.honeycomb.impl;
+
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import io.fd.honeycomb.translate.util.read.BindingBrokerReader;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfStateBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * {@link io.fd.honeycomb.translate.read.ReaderFactory} initiating reader into NETCONF's dedicated data store.
+ * Making NETCONF operational data available over NETCONF/RESTCONF
+ */
+public final class NetconfMonitoringReaderFactory implements AutoCloseable, io.fd.honeycomb.translate.read.ReaderFactory {
+
+ private final DataBroker netconfMonitoringBindingBrokerDependency;
+
+ public NetconfMonitoringReaderFactory(final DataBroker netconfMonitoringBindingBrokerDependency) {
+ this.netconfMonitoringBindingBrokerDependency = netconfMonitoringBindingBrokerDependency;
+ }
+
+ @Override
+ public void init(final ModifiableReaderRegistryBuilder registry) {
+ registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(NetconfState.class),
+ netconfMonitoringBindingBrokerDependency,
+ LogicalDatastoreType.OPERATIONAL, NetconfStateBuilder.class));
+ }
+}