public enum ClientTransactionPolicy extends Enum<ClientTransactionPolicy>
Enum Constant and Description |
---|
MANDATORY
Fail with exception when there is no client-side transaction context; propagate the client-side transaction context
when it is present.
|
NEVER
Invoke without propagating any transaction context; if a client-side transaction context is present, an exception
is thrown.
|
NOT_SUPPORTED
Invoke without propagating any transaction context whether or not a client-side transaction context is present.
|
SUPPORTS
Invoke without a transaction if there is no client-side transaction context; propagate the client-side transaction context if it is present.
|
Modifier and Type | Method and Description |
---|---|
boolean |
failIfTransactionAbsent()
Determine whether this transaction policy causes a failure when a client-side transaction context is absent.
|
boolean |
failIfTransactionPresent()
Determine whether this transaction policy causes a failure when a client-side transaction context is present.
|
boolean |
in(ClientTransactionPolicy... values)
Determine whether this instance is equal to one of the given instances.
|
boolean |
in(ClientTransactionPolicy v1)
Determine whether this instance is equal to one of the given instances.
|
boolean |
in(ClientTransactionPolicy v1,
ClientTransactionPolicy v2)
Determine whether this instance is equal to one of the given instances.
|
boolean |
in(ClientTransactionPolicy v1,
ClientTransactionPolicy v2,
ClientTransactionPolicy v3)
Determine whether this instance is equal to one of the given instances.
|
static boolean |
isFull(EnumSet<ClientTransactionPolicy> set)
Determine whether the given set is fully populated (or "full"), meaning it contains all possible values.
|
boolean |
propagate()
Determine whether this transaction policy causes the client-side transaction context (if any) to be propagated
to invocations.
|
static ClientTransactionPolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ClientTransactionPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ClientTransactionPolicy MANDATORY
This mode is compatible with the following server-side transaction attribute types:
TransactionAttributeType.MANDATORY
TransactionAttributeType.REQUIRED
TransactionAttributeType.SUPPORTS
TransactionAttributeType.MANDATORY
.
This mode may be used with TransactionAttributeType.REQUIRES_NEW
and TransactionAttributeType.NOT_SUPPORTED
,
but such usage may not make sense in most situations because the transaction that is required to be propagated by
the client will always be suspended on the server; in this case, a client-side policy of TransactionAttributeType.NOT_SUPPORTED
is recommended to avoid the useless propagation of the client-side transaction context.
Usage of this mode with the following server-side transaction attribute types will always result in an exception, and is therefore not recommended:
public static final ClientTransactionPolicy SUPPORTS
This is the overall default policy.
This mode is compatible with the following server-side transaction attribute types:
TransactionAttributeType.REQUIRED
TransactionAttributeType.SUPPORTS
TransactionAttributeType.NOT_SUPPORTED
TransactionAttributeType.NEVER
and TransactionAttributeType.MANDATORY
,
however the success of the invocation of such methods will depend on the local transaction state.
Unlike TransactionAttributeType.SUPPORTS
, this client-side transaction policy is generally safe to use in
all cases, as it still allows the server to decide to create a new transaction according to local policy.
This mode may be used with TransactionAttributeType.REQUIRES_NEW
, but such usage may not make sense in
most situations because the transaction that is propagated by the client (if any) will always be suspended on the
server; in this case, a client-side policy of NOT_SUPPORTED
is recommended to avoid the useless propagation of
the client-side transaction context.
public static final ClientTransactionPolicy NOT_SUPPORTED
This mode is compatible with the following server-side transaction attribute types:
TransactionAttributeType.REQUIRED
TransactionAttributeType.REQUIRES_NEW
TransactionAttributeType.SUPPORTS
TransactionAttributeType.NOT_SUPPORTED
TransactionAttributeType.NEVER
, however, in this case the server will
never see the client-side transaction, causing the invocation to effectively use the server-side mode
TransactionAttributeType.NOT_SUPPORTED
in this case, which might result in unexpected behavior.
Usage of this mode with the following server-side transaction attribute types will always result in an exception, and is therefore not recommended:
public static final ClientTransactionPolicy NEVER
This mode is compatible with the following server-side transaction attribute types:
TransactionAttributeType.REQUIRED
TransactionAttributeType.REQUIRES_NEW
TransactionAttributeType.SUPPORTS
TransactionAttributeType.NOT_SUPPORTED
TransactionAttributeType.NEVER
, however, in this case the server will
never see the client-side transaction, causing the invocation to effectively use the server-side mode
TransactionAttributeType.NOT_SUPPORTED
in this case, which might result in unexpected behavior.
Usage of this mode with the following server-side transaction attribute types will always result in an exception, and is therefore not recommended:
public static ClientTransactionPolicy[] values()
for (ClientTransactionPolicy c : ClientTransactionPolicy.values()) System.out.println(c);
public static ClientTransactionPolicy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic boolean failIfTransactionPresent()
true
if the policy would fail when a transaction is present, false
otherwisepublic boolean failIfTransactionAbsent()
true
if the policy would fail when a transaction is absent, false
otherwisepublic boolean propagate()
true
if the transaction is propagated by this policy, false
otherwisepublic static boolean isFull(EnumSet<ClientTransactionPolicy> set)
set
- the settrue
if the set is full, false
otherwisepublic boolean in(ClientTransactionPolicy v1)
v1
- the first instancetrue
if one of the instances matches this one, false
otherwisepublic boolean in(ClientTransactionPolicy v1, ClientTransactionPolicy v2)
v1
- the first instancev2
- the second instancetrue
if one of the instances matches this one, false
otherwisepublic boolean in(ClientTransactionPolicy v1, ClientTransactionPolicy v2, ClientTransactionPolicy v3)
v1
- the first instancev2
- the second instancev3
- the third instancetrue
if one of the instances matches this one, false
otherwisepublic boolean in(ClientTransactionPolicy... values)
values
- the possible valuestrue
if one of the instances matches this one, false
otherwiseCopyright © 2017 JBoss by Red Hat. All rights reserved.