<?xml version="1.0"?>
<!--
  JBoss, Home of Professional Open Source
  Copyright 2006, Red Hat Middleware LLC, and individual contributors
  as indicated by the @author tags.
  See the copyright.txt in the distribution for a full listing
  of individual contributors.
  This copyrighted material is made available to anyone wishing to use,
  modify, copy, or redistribute it subject to the terms and conditions
  of the GNU Lesser General Public License, v. 2.1.
  This program is distributed in the hope that it will be useful, but WITHOUT A
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License,
  v.2.1 along with this distribution; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  MA  02110-1301, USA.


  (C) 2005-2008,
  @author JBoss Inc.
-->
<page title="JBossTS Trail map: Running and Testing Examples" rootpath="../..">
	<header>         Trail map: Running and Testing Examples     </header>
	<content>
		<navigation>
			<links include="includes/www_arjuna_com_navigation.xml"/>
			<links include="includes/trailmap_navigation.xml"/>
			<links title="Navigation">
				<link ref="index.html">Home</link>
				<link ref="part5_testing_jts.html">Previous</link>
			</links>
			<links include="includes/trailmap_additional.xml"/>
		</navigation>
		<area title="Running The Banking application with JTS">
			<html>
				<p>The JTS version of the Banking application means that the Object Request Broker
  will be used. The JBossTS distribution is provided to work with the bundled JacORB version</p>
				<p>
					<strong>Note</strong>: Ensure that the jacorb jar files are added in your CLASSPATH</p>

				<p>To launch the <a class="linkscoloured" href="part5_jts_local.html">JTS version of the Banking application</a>,
  execute the following java program</p>
				<blockquote>
					<pre>java com.arjuna.demo.jts.localbank.BankClient</pre>
				</blockquote>
				<p>Once one of the program given above is launched the following lines are displayed:</p>
				<blockquote>
					<pre>
-------------------------------------------------
   Bank client
-------------------------------------------------
Select an option :
   0. Quit
   1. Create a new account.
   2. Get an account information.
   3. Make a transfer.
   4. Credit an account.
   5. Withdraw from an account

Your choice :
</pre>
				</blockquote>
				<p>After introducing your choice, the appropriate operation is performed by the
  Bank object, to get the requested account, and by the account to execute the
  credit or withdraw or to return the current balance. Let's consider the following
  execution. </p>
				<p>Enter the number 1 as your choice, then give the name &quot;Foo&quot; as the
  account name and &quot;1000&quot; as an initial value of the account to create.
  You should get the following lines:</p>
				<blockquote>
					<pre>
Your choice : 1
- Create a new account -
------------------------
Name : Foo
Initial balance : 1000
Beginning a User transaction to create account
[ Connected to 192.168.0.2:4799 from local port 4924 ]<br/>Attempt to commit the account creation transaction
/[ Resource for Foo : Commit one phase ]
</pre>
				</blockquote>
				<ul>
					<li>Since only one AccountResource then only one CosTransaction.Resource is
    involved in the account creation transaction, the two phases needed to get
    a consensus in the 2PC protocol are not mandatory. The one phase commit optimisation,
    indicated by the &quot;Commit one phase&quot;, is applied. </li>
				</ul>
				<p>In the same way create a second account with the name &quot;Bar&quot; and the
  initial balance set to 500. </p>
				<p>As a choice now, enter &quot;3&quot; to make a transfer (300) from &quot;Foo&quot;
  to &quot;Bar&quot;. </p>
				<blockquote>
					<pre>
Your choice : 3
- Make a transfer -
-------------------

Take money from : Foo
Put money to : Bar
Transfer amount : 300
Beginning a User transaction to Transfer money
[ Resource for Foo : Prepare ]
[ Resource for Bar : Prepare ]
[ Resource for Foo : Commit ]
[ Resource for Bar : Commit ]
</pre>
				</blockquote>
				<ul>
					<li>Now two AccountResource objects, then two CosTransactions.Resource objects
    are enlisted with the transaction. The displayed lines show that the two phases,
    prepare and commit, are applied. </li>
				</ul>
				<p>Any attempt to manipulate an account that it doesn't exist leads to throw the
  NotExistingAccount exception and to rollback the transaction in progress. For
  instance, let's withdraw money from an account FooBar not previously created.</p>
				<blockquote>
					<pre>
Your choice : 5
- Withdraw from an Account -
----------------------------
Give the Account name : FooBar
Amount to withdraw : 200
Beginning a User transaction to withdraw from an account
The requested account does not exist!
ERROR - org.omg.CORBA.TRANSACTION_ROLLEDBACK:
minor code: 50001  completed: No
</pre>
				</blockquote>
				<h4>Using a stand-alone Transaction Server</h4>
				<p>By default JBossTS does not use a separate transaction manager server: transaction
  managers are co-located with each application process to improve performance
  and improve application fault-tolerance. When running applications which require
  a separate transaction manager, you must set the com.arjuna.ats.jts.transactionManager
  property variable, in the "(jbossts_install_dir)/etc/jbossts-properties.xml file, to YES. </p>
				<p>In a separate window, the stand-alone Transaction Server is launched as follow:</p>
				<blockquote>
					<pre>java com.arjuna.ats.jts.TransactionServer [-test]</pre>
				</blockquote>
				<p>The option <font face="Courier New, Courier, mono">-test</font> allows to see the message "Ready" when the Transaction Server is started.</p>
				<p>The Banking application presented above gives the same output.</p>
			</html>
		</area>
	</content>
	<footer/>
</page>
