24308b664df759dcff96b3f5f7c8d074b3c599cd
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / BindingDOMAdapterLoader.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.binding.impl;
9
10 import com.google.common.base.Preconditions;
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13 import org.opendaylight.controller.md.sal.binding.api.ActionProviderService;
14 import org.opendaylight.controller.md.sal.binding.api.ActionService;
15 import org.opendaylight.controller.md.sal.binding.api.BindingService;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
18 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
19 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
20 import org.opendaylight.controller.md.sal.binding.spi.AdapterBuilder;
21 import org.opendaylight.controller.md.sal.binding.spi.AdapterLoader;
22 import org.opendaylight.controller.md.sal.dom.api.DOMService;
23 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
24
25 @Deprecated
26 public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingService, DOMService> {
27     private static final Map<Class<?>, BindingDOMAdapterBuilder.Factory<?>> FACTORIES =
28         ImmutableMap.<Class<?>, BindingDOMAdapterBuilder.Factory<?>>builder()
29             .put(NotificationService.class, BindingDOMNotificationServiceAdapter.BUILDER_FACTORY)
30             .put(NotificationPublishService.class, BindingDOMNotificationPublishServiceAdapter.BUILDER_FACTORY)
31             .put(DataBroker.class, BindingDOMDataBrokerAdapter.BUILDER_FACTORY)
32             .put(RpcConsumerRegistry.class, BindingDOMRpcServiceAdapter.BUILDER_FACTORY)
33             .put(ActionProviderService.class, ControllerActionProviderServiceAdapter.BUILDER_FACTORY)
34             .put(ActionService.class,  ControllerActionServiceAdapter.BUILDER_FACTORY)
35             .build();
36
37     private final BindingToNormalizedNodeCodec codec;
38
39     public BindingDOMAdapterLoader(final BindingToNormalizedNodeCodec codec) {
40         this.codec = codec;
41     }
42
43     @Override
44     protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(
45             final Class<? extends BindingService> key) {
46         final Factory<?> factory = FACTORIES.get(key);
47         Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
48         final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
49         builder.setCodec(codec);
50         return builder;
51     }
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.