Java Reference
In-Depth Information
Using your own or another transaction manager
In addition to these transaction manager implementations, the DaoTransaction-
Manager is an interface that you can implement and insert into the DAO configura-
tion by providing the fully qualified name of your implementation in the type
attribute of the transaction manager configuration element. Any properties that
are listed in the body of the transaction manager element are passed to the con-
figure() method of the transaction manager class:
<property name="someProp" value="aValue"/>
<property name="someOtherProp" value="anotherValue"/>
In the previous example, the i BATIS DAO framework would create an instance of
the MyNiftyTransactionManager class, and pass it a Properties object with entries
for someProp and someOtherProp . We will look at the anatomy of an existing
DaoTransactionManager implementation in more detail in chapter 11.
The DAO elements
Once the transaction manager has been chosen and configured, the DAO ele-
ments can be added to the DAO context to define the DAO interfaces and imple-
mentations that your context will make available for your application.
The <dao> element only has two properties: interface and implementation .
Just because the attribute name interface is used to identify the DAO
implementation, you do not actually need to use an interface. In our pre-
vious example, both of the attributes ( interface and implementation )
could have been the fully qualified class name of the implementation.
While this may seem like an easy way to reduce some code, it is strongly
discouraged, because it essentially eliminates the value added by the DAO
layer—that is, the separation of the interface from the implementation.
As for the code savings, nearly all IDE s now provide refactoring tools to
allow you to extract an interface from an implementation, meaning that
you are able to write and test your DAO implementation without creating
the interface and then create the interface with a few mouse clicks.
The interface property is used to identify the DAO in the DAO map, and is gen-
erally used in the following way:
<dao interface="com.mycompany.system.dao.AccountDao"
Search WWH ::

Custom Search