blob: ecbb1d2bbde3d0ee2d842e02d34855ada4c21b5a [file] [log] [blame]
Madan Jampani7e55c662016-02-15 21:13:53 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Madan Jampani7e55c662016-02-15 21:13:53 -08003 *
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
Madan Jampani7e55c662016-02-15 21:13:53 -080018import org.onosproject.store.primitives.TransactionId;
19import org.onosproject.store.service.TransactionContext;
20import org.onosproject.store.service.TransactionContextBuilder;
Jordan Halterman948d6592017-04-20 17:18:24 -070021
Madan Jampani7e55c662016-02-15 21:13:53 -080022/**
23 * Default Transaction Context Builder.
24 */
Madan Jampani832686d2016-04-04 21:57:26 -070025public class DefaultTransactionContextBuilder extends TransactionContextBuilder {
Madan Jampani7e55c662016-02-15 21:13:53 -080026
27 private final TransactionId transactionId;
Jordan Halterman948d6592017-04-20 17:18:24 -070028 private final TransactionManager transactionManager;
Madan Jampani7e55c662016-02-15 21:13:53 -080029
Jordan Halterman948d6592017-04-20 17:18:24 -070030 public DefaultTransactionContextBuilder(TransactionId transactionId, TransactionManager transactionManager) {
Madan Jampani7e55c662016-02-15 21:13:53 -080031 this.transactionId = transactionId;
Jordan Halterman948d6592017-04-20 17:18:24 -070032 this.transactionManager = transactionManager;
Madan Jampani7e55c662016-02-15 21:13:53 -080033 }
34
35 @Override
36 public TransactionContext build() {
Madan Jampani832686d2016-04-04 21:57:26 -070037 return new DefaultTransactionContext(transactionId,
Jordan Halterman948d6592017-04-20 17:18:24 -070038 new TransactionCoordinator(transactionId, transactionManager));
Madan Jampani7e55c662016-02-15 21:13:53 -080039 }
40}