Bug 2364: Migrated Binding MD-SAL to not use composites nodes
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / ForwardedBindingDataBroker.java
1 /*
2  * Copyright (c) 2014 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
11 import com.google.common.collect.ClassToInstanceMap;
12 import com.google.common.collect.ImmutableSet;
13 import java.util.Set;
14 import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
15 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
16 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
17 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
18 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
19 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMAdapterBuilder.Factory;
20 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
21 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
22 import org.opendaylight.controller.md.sal.dom.api.DOMService;
23 import org.opendaylight.controller.sal.core.api.model.SchemaService;
24
25 /**
26  * The DataBrokerImpl simply defers to the DOMDataBroker for all its operations.
27  * All transactions and listener registrations are wrapped by the DataBrokerImpl
28  * to allow binding aware components to use the DataBroker transparently.
29  *
30  * Besides this the DataBrokerImpl and it's collaborators also cache data that
31  * is already transformed from the binding independent to binding aware format
32  *
33
34  */
35 public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements DataBroker {
36
37
38     static final Factory<DataBroker> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<DataBroker>() {
39
40         @Override
41         public BindingDOMAdapterBuilder<DataBroker> newBuilder() {
42             return new Builder();
43         }
44
45     };
46
47     public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
48         super(domDataBroker, codec);
49     }
50
51     @Deprecated
52     public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec, final SchemaService schemaService) {
53         super(domDataBroker, codec,schemaService);
54     }
55
56     @Override
57
58     public ReadOnlyTransaction newReadOnlyTransaction() {
59         return new BindingDataReadTransactionImpl(getDelegate().newReadOnlyTransaction(),getCodec());
60     }
61
62     @Override
63     public ReadWriteTransaction newReadWriteTransaction() {
64         return new BindingDataReadWriteTransactionImpl(getDelegate().newReadWriteTransaction(),getCodec());
65     }
66
67     @Override
68     public WriteTransaction newWriteOnlyTransaction() {
69         return new BindingDataWriteTransactionImpl<>(getDelegate().newWriteOnlyTransaction(),getCodec());
70     }
71
72     @Override
73     public BindingTransactionChain createTransactionChain(final TransactionChainListener listener) {
74         return new BindingTranslatedTransactionChain(getDelegate(), getCodec(), listener);
75     }
76
77     private static class Builder extends BindingDOMAdapterBuilder<DataBroker> {
78
79         @Override
80         public Set<? extends Class<? extends DOMService>> getRequiredDelegates() {
81             return ImmutableSet.of(DOMDataBroker.class);
82         }
83
84         @Override
85         protected DataBroker createInstance(BindingToNormalizedNodeCodec codec,
86                 ClassToInstanceMap<DOMService> delegates) {
87             DOMDataBroker domDataBroker = delegates.getInstance(DOMDataBroker.class);
88             return new ForwardedBindingDataBroker(domDataBroker, codec);
89         }
90
91
92
93     }
94 }

©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.