blob: 3a27122b79d2fc1adedc2ee2acf113d11679336a [file] [log] [blame]
Madan Jampani7e55c662016-02-15 21:13:53 -08001/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.store.primitives.impl;
17
18import org.onosproject.store.primitives.DistributedPrimitiveCreator;
19import org.onosproject.store.primitives.TransactionId;
20import org.onosproject.store.service.TransactionContext;
21import org.onosproject.store.service.TransactionContextBuilder;
22/**
23 * Default Transaction Context Builder.
24 */
25public class NewDefaultTransactionContextBuilder extends TransactionContextBuilder {
26
27 private final TransactionId transactionId;
28 private final DistributedPrimitiveCreator base;
29 private final DistributedPrimitiveCreator federated;
30 private final TransactionCoordinator transactionCoordinator;
31
32 public NewDefaultTransactionContextBuilder(TransactionId transactionId,
33 DistributedPrimitiveCreator base,
34 DistributedPrimitiveCreator federated,
35 TransactionCoordinator transactionCoordinator) {
36 this.transactionId = transactionId;
37 this.base = base;
38 this.federated = federated;
39 this.transactionCoordinator = transactionCoordinator;
40 }
41
42 @Override
43 public TransactionContext build() {
44 return new NewDefaultTransactionContext(transactionId,
45 this.partitionsDisabled() ? base : federated,
46 transactionCoordinator);
47 }
48}