/** * 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.openflowplugin.test; import com.google.common.util.concurrent.ListenableFuture; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OpenflowpluginTableFeaturesTestServiceProvider implements AutoCloseable, SalTableService { private static final Logger LOG = LoggerFactory .getLogger(OpenflowpluginTableFeaturesTestServiceProvider.class); private RoutedRpcRegistration tableRegistration; private NotificationProviderService notificationService; /** * Get table registration. * * @return {@link #tableRegistration} */ public RoutedRpcRegistration getTableRegistration() { return this.tableRegistration; } /** * Set {@link #tableRegistration}. */ public void setTableRegistration( final RoutedRpcRegistration tableRegistration) { this.tableRegistration = tableRegistration; } /** * Get notification service. * * @return {@link #notificationService} */ public NotificationProviderService getNotificationService() { return this.notificationService; } /** * Set {@link #notificationService}. */ public void setNotificationService( final NotificationProviderService notificationService) { this.notificationService = notificationService; } public void start() { OpenflowpluginTableFeaturesTestServiceProvider.LOG .info("SalTableServiceProvider Started."); } /* * (non-Javadoc) * * @see java.lang.AutoCloseable#close() */ @Override public void close() throws Exception { OpenflowpluginTableFeaturesTestServiceProvider.LOG .info("SalTableServiceProvider stopped."); tableRegistration.close(); } /* * (non-Javadoc) * * @see * org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026 * .SalTableService * #updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight * .table.service.rev131026.UpdateTableInput) */ @Override public ListenableFuture> updateTable( UpdateTableInput input) { String plus = "updateTable - " + input; OpenflowpluginTableFeaturesTestServiceProvider.LOG.info(plus); return null; } public ObjectRegistration register( final RpcProviderRegistry rpcRegistry) { RoutedRpcRegistration addRoutedRpcImplementation = rpcRegistry.addRoutedRpcImplementation( SalTableService.class, this); setTableRegistration(addRoutedRpcImplementation); InstanceIdentifierBuilder builder1 = InstanceIdentifier .builder(Nodes.class); NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID); NodeKey nodeKey = new NodeKey(nodeId); InstanceIdentifierBuilder nodeIndentifier = builder1 .child(Node.class, nodeKey); InstanceIdentifier instance = nodeIndentifier.build(); tableRegistration.registerPath(NodeContext.class, instance); RoutedRpcRegistration tableRegistration1 = this .getTableRegistration(); return new AbstractObjectRegistration(this) { @Override protected void removeRegistration() { tableRegistration1.close(); } }; } }