001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2018 microBean.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
014 * implied.  See the License for the specific language governing
015 * permissions and limitations under the License.
016 */
017package org.microbean.jpa.org.hibernate.engine.transaction.jta.platform;
018
019import java.util.Objects;
020
021import javax.enterprise.context.ApplicationScoped;
022
023import javax.enterprise.inject.spi.CDI;
024
025import javax.inject.Inject;
026
027import javax.transaction.TransactionManager;
028import javax.transaction.UserTransaction;
029
030import org.hibernate.engine.jndi.spi.JndiService;
031
032import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
033
034import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
035import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformProvider;
036
037@ApplicationScoped
038public class CDISEJtaPlatform extends AbstractJtaPlatform {
039
040  private final TransactionManager transactionManager;
041
042  private final UserTransaction userTransaction;
043  
044  private static final long serialVersionUID = 1L;
045  
046  @Inject
047  public CDISEJtaPlatform(final TransactionManager transactionManager,
048                          final UserTransaction userTransaction) {
049    super();
050    this.transactionManager = Objects.requireNonNull(transactionManager);
051    this.userTransaction = Objects.requireNonNull(userTransaction);
052  }
053
054  @Override
055  protected JndiService jndiService() {
056    throw new UnsupportedOperationException();
057  }
058  
059  @Override
060  protected UserTransaction locateUserTransaction() {
061    return this.userTransaction;
062  }
063
064  @Override
065  protected TransactionManager locateTransactionManager() {
066    return this.transactionManager;
067  }
068  
069}