All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jakarta.transaction.TransactionScoped Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0, which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the
 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
 * version 2 with the GNU Classpath Exception, which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 */

package jakarta.transaction;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import jakarta.enterprise.context.NormalScope;

/**
 * 

The jakarta.transaction.TransactionScoped annotation provides the ability to * specify a standard CDI scope to define bean instances whose lifecycle is * scoped to the currently active Jakarta Transactions transaction. This annotation has no effect * on classes which have non-contextual references such those defined as managed * beans by the Jakarta EE specification.

* The transaction scope is active when the return from a call to * UserTransaction.getStatus or * TransactionManager.getStatus * is one of the following states: *
    *
  • Status.STATUS_ACTIVE *
  • Status.STATUS_MARKED_ROLLBACK *
  • Status.STATUS_PREPARED *
  • Status.STATUS_UNKNOWN *
  • Status.STATUS_PREPARING *
  • Status.STATUS_COMMITTING *
  • Status.STATUS_ROLLING_BACK *
*

It is not intended that the term "active" as defined here in relation to the * TransactionScoped annotation should also apply to its use in relation to * transaction context, lifecycle, etc. mentioned elsewhere in this * specification. The object with this annotation will be associated with the * current active Jakarta Transactions transaction when the object is used. This association must * be retained through any transaction suspend or resume calls as well as any * Synchronization.beforeCompletion callbacks. Any * Synchronization.afterCompletion methods will be invoked in an undefined * context. The way in which the Jakarta Transactions transaction is begun and completed * (for example via UserTransaction, Transactional interceptor, etc.) is of no consequence. * The contextual references used across different Jakarta Transactions transactions are distinct. * Refer to the CDI specification for more details on contextual references. * A jakarta.enterprise.context.ContextNotActiveException * will be thrown if an object with this annotation is used when the * transaction context is not active.

* * @version Jakarta Transactions 2.0 * @since JTA 1.2 */ @Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD}) @NormalScope(passivating=true) public @interface TransactionScoped { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy