1 package org.apache.onami.persist; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import com.google.inject.Key; 23 import com.google.inject.TypeLiteral; 24 25 import javax.inject.Provider; 26 import javax.transaction.UserTransaction; 27 28 /** 29 * 3rd step of the persistence unit builder process. 30 * Define the transaction type. 31 */ 32 public interface AnnotatedPersistenceUnitBuilder 33 extends UnconfiguredPersistenceUnitBuilder 34 { 35 36 /** 37 * Mark the persistence unit to use resource local transactions. 38 * 39 * @return the next builder step. 40 */ 41 UnconfiguredPersistenceUnitBuilder useLocalTransaction(); 42 43 /** 44 * Mark the persistence unit to use JTA transactions. 45 * 46 * @param userTransaction the instance of the UserTransaction object to use. 47 * @return the next builder step. 48 */ 49 UnconfiguredPersistenceUnitBuilder useGlobalTransaction( UserTransaction userTransaction ); 50 51 /** 52 * Mark the persistence unit to use JTA transactions. 53 * 54 * @param utJndiName the JNDI name to use for looking up the user transaction instance. 55 * @return the next builder step. 56 */ 57 UnconfiguredPersistenceUnitBuilder useGlobalTransactionWithJndiName( String utJndiName ); 58 59 /** 60 * Mark the persistence unit to use JTA transactions. 61 * 62 * @param utProvider a provider to retrieve the user transaction instance. 63 * @return the next builder step. 64 */ 65 UnconfiguredPersistenceUnitBuilder useGlobalTransactionProvidedBy( Provider<UserTransaction> utProvider ); 66 67 /** 68 * Mark the persistence unit to use JTA transactions. 69 * 70 * @param utProviderClass a provider to retrieve the user transaction instance. 71 * @return the next builder step. 72 */ 73 UnconfiguredPersistenceUnitBuilder useGlobalTransactionProvidedBy( 74 Class<? extends Provider<UserTransaction>> utProviderClass ); 75 76 /** 77 * Mark the persistence unit to use JTA transactions. 78 * 79 * @param utProviderType a provider to retrieve the user transaction instance. 80 * @return the next builder step. 81 */ 82 UnconfiguredPersistenceUnitBuilder useGlobalTransactionProvidedBy( 83 TypeLiteral<? extends Provider<UserTransaction>> utProviderType ); 84 85 /** 86 * Mark the persistence unit to use JTA transactions. 87 * 88 * @param utProviderKey a provider to retrieve the user transaction instance. 89 * @return the next builder step. 90 */ 91 UnconfiguredPersistenceUnitBuilder useGlobalTransactionProvidedBy( 92 Key<? extends Provider<UserTransaction>> utProviderKey ); 93 94 }