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.CarProvider;
14 import org.opendaylight.controller.clustering.it.provider.PeopleProvider;
15 import org.opendaylight.controller.clustering.it.provider.PurchaseCarProvider;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
18 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.purchase.rev140818.CarPurchaseService;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.car.rev140818.CarService;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.sal.clustering.it.people.rev140818.PeopleService;
22 import org.opendaylight.yangtools.concepts.ListenerRegistration;
23 import org.opendaylight.yangtools.yang.binding.NotificationListener;
25 public class ClusteringItProviderModule extends org.opendaylight.controller.config.yang.config.clustering_it_provider.AbstractClusteringItProviderModule {
26 public ClusteringItProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
27 super(identifier, dependencyResolver);
30 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) {
31 super(identifier, dependencyResolver, oldModule, oldInstance);
35 public void customValidation() {
36 // add custom validation form module attributes here.
40 public java.lang.AutoCloseable createInstance() {
41 DataBroker dataBrokerService = getDataBrokerDependency();
42 NotificationProviderService notificationProvider = getNotificationServiceDependency();
44 // Add routed RPC registration for car purchase
45 final PurchaseCarProvider purchaseCar = new PurchaseCarProvider();
46 purchaseCar.setNotificationProvider(notificationProvider);
48 final BindingAwareBroker.RoutedRpcRegistration<CarPurchaseService> purchaseCarRpc = getRpcRegistryDependency()
49 .addRoutedRpcImplementation(CarPurchaseService.class, purchaseCar);
51 // Add people provider registration
52 final PeopleProvider people = new PeopleProvider();
53 people.setDataProvider(dataBrokerService);
55 people.setRpcRegistration(purchaseCarRpc);
57 CarProvider carProvider = new CarProvider(dataBrokerService);
58 getRpcRegistryDependency().addRpcImplementation(CarService.class, carProvider);
60 final BindingAwareBroker.RpcRegistration<PeopleService> peopleRpcReg = getRpcRegistryDependency()
61 .addRpcImplementation(PeopleService.class, people);
65 final PeopleCarListener peopleCarListener = new PeopleCarListener();
66 peopleCarListener.setDataProvider(dataBrokerService);
68 final ListenerRegistration<NotificationListener> listenerReg =
69 getNotificationServiceDependency().registerNotificationListener( peopleCarListener );
71 // Wrap toaster as AutoCloseable and close registrations to md-sal at
73 final class AutoCloseableToaster implements AutoCloseable {
76 public void close() throws Exception {
78 purchaseCarRpc.close();
85 AutoCloseable ret = new AutoCloseableToaster();