Merge "Fix a few eclipse-reported warnings"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / DataBrokerImpl.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.sal.binding.impl;\r
9 \r
10 import java.util.Set;
11 import java.util.concurrent.Future;
12 import java.util.concurrent.atomic.AtomicLong;
13
14 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
15 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
16 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
17 import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderRouter;
18 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
19 import org.opendaylight.yangtools.yang.binding.DataObject;
20 import org.opendaylight.yangtools.yang.binding.DataRoot;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import org.opendaylight.yangtools.yang.common.RpcResult;
23 \r
24 \r
25 public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //\r
26        implements DataProviderService, AutoCloseable {\r
27 \r
28     private final AtomicLong nextTransaction = new AtomicLong();\r
29     private final AtomicLong createdTransactionsCount = new AtomicLong();\r
30 \r
31     public AtomicLong getCreatedTransactionsCount() {\r
32         return createdTransactionsCount;\r
33     }\r
34 \r
35     public DataBrokerImpl() {\r
36         setDataReadRouter(new BindingAwareDataReaderRouter());\r
37     }\r
38 \r
39     @Override\r
40     public DataTransactionImpl beginTransaction() {\r
41         String transactionId = "BA-" + nextTransaction.getAndIncrement();\r
42         createdTransactionsCount.getAndIncrement();\r
43         return new DataTransactionImpl(transactionId,this);\r
44     }\r
45 \r
46     @Override\r
47     @Deprecated\r
48     public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {\r
49         throw new UnsupportedOperationException("Deprecated");\r
50     }\r
51 \r
52     @Override\r
53     @Deprecated\r
54     public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {\r
55         throw new UnsupportedOperationException("Deprecated");\r
56     }\r
57 \r
58     @Override\r
59     @Deprecated\r
60     public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {\r
61         throw new UnsupportedOperationException("Deprecated");\r
62     }\r
63 \r
64     @Override\r
65     @Deprecated\r
66     public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {\r
67         throw new UnsupportedOperationException("Deprecated");\r
68     }\r
69 \r
70     @Override\r
71     @Deprecated\r
72     public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {\r
73         throw new UnsupportedOperationException("Deprecated");\r
74     }\r
75 \r
76     @Override\r
77     @Deprecated\r
78     public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {\r
79         throw new UnsupportedOperationException("Deprecated");\r
80     }\r
81 \r
82     @Override\r
83     @Deprecated\r
84     public DataObject getData(InstanceIdentifier<? extends DataObject> data) {\r
85         throw new UnsupportedOperationException("Deprecated");\r
86     }\r
87 \r
88     @Override\r
89     @Deprecated\r
90     public DataObject getConfigurationData(InstanceIdentifier<?> data) {\r
91         throw new UnsupportedOperationException("Deprecated");\r
92     }\r
93 \r
94     @Override\r
95     @Deprecated\r
96     public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {\r
97         throw new UnsupportedOperationException("Deprecated");\r
98     }\r
99 \r
100     @Override\r
101     @Deprecated\r
102     public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,\r
103             DataChangeListener changeListener) {\r
104         throw new UnsupportedOperationException("Deprecated");\r
105     }\r
106 \r
107     @Override\r
108     public void close() throws Exception {\r
109 \r
110     }
111
112     @Override
113     protected boolean isAffectedBy(InstanceIdentifier<? extends DataObject> key,
114             Set<InstanceIdentifier<? extends DataObject>> paths) {
115         if (paths.contains(key)) {
116             return true;
117         }
118         for (InstanceIdentifier<?> path : paths) {
119             if (key.containsWildcarded(path)) {
120                 return true;
121             }
122         }
123         return false;
124     }\r
125 }