2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.yang.config.clustering_it_provider;
12 import org.opendaylight.controller.clustering.it.listener.PeopleCarListener;
13 import org.opendaylight.controller.clustering.it.provider.PeopleProvider;
14 import org.opendaylight.controller.clustering.it.provider.PurchaseCarProvider;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
17 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PeopleService;
20 import org.opendaylight.yangtools.concepts.ListenerRegistration;
21 import org.opendaylight.yangtools.yang.binding.NotificationListener;
23 public class ClusteringItProviderModule extends org.opendaylight.controller.config.yang.config.clustering_it_provider.AbstractClusteringItProviderModule {
24 public ClusteringItProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
25 super(identifier, dependencyResolver);
28 public ClusteringItProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.clustering_it_provider.ClusteringItProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
29 super(identifier, dependencyResolver, oldModule, oldInstance);
33 public void customValidation() {
34 // add custom validation form module attributes here.
38 public java.lang.AutoCloseable createInstance() {
39 DataBroker dataBrokerService = getDataBrokerDependency();
40 NotificationProviderService notificationProvider = getNotificationServiceDependency();
42 // Add routed RPC registration for car purchase
43 final PurchaseCarProvider purchaseCar = new PurchaseCarProvider();
44 purchaseCar.setNotificationProvider(notificationProvider);
46 final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> purchaseCarRpc = getRpcRegistryDependency()
47 .addRoutedRpcImplementation(CarPurchaseService.class, purchaseCar);
49 // Add people provider registration
50 final PeopleProvider people = new PeopleProvider();
51 people.setDataProvider(dataBrokerService);
53 people.setRpcRegistration(purchaseCarRpc);
55 final BindingAwareBroker.RpcRegistration<PeopleService> peopleRpcReg = getRpcRegistryDependency()
56 .addRpcImplementation(PeopleService.class, people);
60 final PeopleCarListener peopleCarListener = new PeopleCarListener();
61 peopleCarListener.setDataProvider(dataBrokerService);
63 final ListenerRegistration<NotificationListener> listenerReg =
64 getNotificationServiceDependency().registerNotificationListener( peopleCarListener );
66 // Wrap toaster as AutoCloseable and close registrations to md-sal at
68 final class AutoCloseableToaster implements AutoCloseable {
71 public void close() throws Exception {
73 purchaseCarRpc.close();
80 AutoCloseable ret = new AutoCloseableToaster();