<?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-2006,
  @author JBoss Inc.
-->
<page title="JBossTS Trail map: Running and Testing Examples" rootpath="../..">
	<header>         Implementing the Account interface  </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="part6_txoj_banking_develop.html">Previous</link>
			</links>
			<links include="includes/trailmap_additional.xml"/>
		</navigation>
		<area title="Implementing the BankServer">
			<html>
<p>The role of the BankServer class is mainly to initialise the ORB and the Object
  Adapter and to create the default Bank object responsible to create banking
  accounts. </p>
<p>Globally the BankServer has the following structure.</p>
<ul>
  <li>Initialise the ORB
    <p>This done using the ORB Portability API</p>
  </li>
  <blockquote>
    <pre>...
myORB = ORB.getInstance(&quot;ServerSide&quot;);
myOA = OA.getRootOA(myORB);
myORB.initORB(args, null);
myOA.initOA();
...
</pre>
  </blockquote>
  <li>Create the BankImpl object, an instance that implements the Bank interface.
    Two ways are provided to build such Bank object according to the fact it's
    the first time we create such object or not. This depends on the existence
    or not of the file named &quot;<ul>
      &quot; that should contain
    the Uid of the BankImpl object.
    <li>
    </li>
    </ul>
    <blockquote>
      <pre>...
java.io.FileInputStream file = new java.io.FileInputStream(&quot;UidBankFile&quot;);
java.io.InputStreamReader input = new java.io.InputStreamReader(file);
java.io.BufferedReader reader = new java.io.BufferedReader(input);
String stringUid = reader.readLine();
file.close();
_bank = new BankImpl(new Uid(stringUid), myOA);
boolean result =_bank.activate();
...
</pre>
    </blockquote>
    <ul>
      <li>If the file does not exist, a new BankImpl object is created, then the
        Uid of the created object is stored in the file named &quot;UidBankFile&quot;</li>
    </ul>
    <blockquote>
      <pre>...
_bank = new BankImpl(myOA);
java.io.FileOutputStream file = new java.io.FileOutputStream(&quot;UidBankFile&quot;);
java.io.PrintStream pfile=new java.io.PrintStream(file);
pfile.println(_bank.get_uid().toString());
file.close();
...</pre>
    </blockquote>
  </li>
  <li>Store the CORBA object reference of the BankImpl object in a file in such
    way the client can retrieve it from that file.</li>
</ul>
<h5>Sample Application Source Code</h5>
<p>Full source code for the <a class="linkscoloured" href="../src/com/arjuna/demo/jts/txojbank/BankServer.java">BankServer</a>
  class is included to provide you with a starting point for experimentation.</p>
			</html>
		</area>
	</content>
	<footer/>
</page>
