Java Reference
In-Depth Information
Table 4-5. Attributes Used with tx:attributes
Attribute
Required
Default
Description
name
Yes
n/a
The name of the methods against which the advice
will be applied. You can use wildcards ( * ).
propagation
No
REQUIRED
The propagation specification for the transaction.
isolation
No
DEFAULT
The isolation level specification for the transaction.
timeout
No
-1
How long the transaction will try to commit before it
times out.
Continued
read-only
No
False
Tells the container whether the transaction is read-
only or not. This is a Spring-specific setting. If you're
used to standard Java EE transaction configuration,
you won't have seen this setting before. Its meaning
is different for different resources (e.g., databases
have a different notion of " read-only " than a JMS
queue does).
rollback-for
Comma-delimited list of fully qualified Exception
t ypes that, when thrown from the method, the
transaction should rollback for.
No
N/A
no-rollback-for
A comma-delimited list of Exception types that,
when thrown from the method, the transaction
should ignore and not roll back for.
No
N/A
Now you can retrieve the bookShop bean from the Spring IoC container to use. Because this bean's
methods are matched by the pointcut, Spring will return a proxy that has transaction management
enabled for this bean.
package com.apress.springenterpriserecipes.bookshop.aspectj;
...
public class Main {
public static void main(String[] args) {
...
BookShop bookShop = (BookShop) context.getBean( " bookShop " );
bookShop.purchase( " 0001 " , " user1 " );
}
}
Search WWH ::




Custom Search