Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
AWare
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h2>Overview</h2> <p>The <strong>UnitOfWorkProtocol</strong> aspect makes the <a class="confluence-link" href="/display/AWARE/Unit+Of+Work" data-linked-resource-id="3415" data-linked-resource-type="page" data-linked-resource-default-alias="Unit Of Work" data-base-url="http://docs.codehaus.org">Unit Of Work</a> management transparent in the user code. </p> <p>It will allow you to write your code like this:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> AddressBook book = new AddressBook(...); book.addContact(contact); </pre></td></tr></table> <p>Instead of like this:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="java" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6amF2YX0&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> UnitOrWork unitOfWork = UnitOfWork.begin(); try { AddressBook book = new AddressBook(...); unitOfWork.registerNew(book); book.addContact(contact); unitOfWork.registerDirty(book); unitOfWork.commit(); } catch(Exception e) { unitOfWork.rollback(); } finally { unitOfWork.dispose(); } </pre></td></tr></table> <p>and still all the transaction and persistence management will take place.</p> <h2>Definition</h2> <p>The <strong>UnitOfWorkProtocol</strong> aspect has abstract pointcuts that you have to define in your aop.xml file (a "transactional object" is an object that is set to participate in the Unit Of Work transaction, meaning that the Unit Of Work will keep track of its state):</p> <ul> <li><code>txRequires</code> - picks out all points in the code where you want a <em>TX REQUIRES</em> transaction to <em>begin</em>, <em>commit</em> and <em>rollback</em></li> <li><code>txRequiresNew</code> - picks out all points in the code where you want a <em>TX REQUIRES_NEW</em> transaction to <em>begin</em>, <em>commit</em> and <em>rollback</em></li> <li><code>txSupports</code> - picks out all points in the code where you want a <em>TX SUPPORTS</em> transaction to <em>begin</em>, <em>commit</em> and <em>rollback</em></li> <li><code>txMandatory</code> - picks out all points in the code where you want a <em>TX MANDATORY</em> transaction to <em>begin</em>, <em>commit</em> and <em>rollback</em></li> <li><code>txNever</code> - picks out all points in the code where you want a <em>TX NEVER</em> transaction to <em>begin</em>, <em>commit</em> and <em>rollback</em></li> <li><code>transactionalObjects</code> - picks out all transactional object, this pointcut is used by the <a class="confluence-link" href="/display/AWARE/Transactional+Mixin" data-linked-resource-id="3595" data-linked-resource-type="page" data-linked-resource-default-alias="Transactional Mixin" data-base-url="http://docs.codehaus.org">Transactional Mixin</a></li> <li><code>transactionalObjectCreationPoints</code> - picks out all points in the code where a transactional object is created</li> <li><code>transactionalObjectModificationPoints</code> - picks out all points in the code where a transactional object is being modified (best done with a <code>set(...)</code> pointcut)</li> </ul> <p>Here is an example on how to define this in XML:</p> <table class="wysiwyg-macro" data-macro-name="code" data-macro-default-parameter="xml" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGU6eG1sfQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <aspect class="org.codehaus.aware.unitofwork.UnitOfWorkProtocol"> <pointcut name="txSupports" expression="execution(* org.codehaus.aware.app.service.*.*(..))"/> <pointcut name="txRequires" expression="execution(* org.codehaus.aware.app.domain.*.*(..))"/> <pointcut name="transactionalObjects" expression="within(org.codehaus.aware.app.domain.*)"/> <pointcut name="transactionalObjectCreationPoints" expression="call(org.codehaus.aware.app.domain.*.new(..))"/> <pointcut name="transactionalObjectModificationPoints" expression="set(* org.codehaus.aware.app.domain.*.*)"/> </aspect> </pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced