All pastes #386685 Raw Edit

Stuff

public text v1 · immutable
·published 2007-03-08 20:45 UTC
rendered paste body
// EDS CORBA 2.6 Xuepeng Deng 28/02/07

// JDK1.4.2 with JacORB 2.2

// bank\ManagerImpl.java

// servant implementation

package bank;

import java.io.*;
import org.omg.CORBA.ORB;
import java.lang.Math;
import javax.naming.*;
import java.rmi.*;
import java.util.Hashtable;

import org.omg.PortableServer.*;
import org.omg.CosNaming.*;


public class ManagerImpl extends ManagerPOA

{
	//This is from the variable mapping from bank.idl(typedef sequence <string> AccountList;);

        //MANAGER NEEDS A HASH TABLE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	private HashTable accountList;
	private Account bankAccount;
	private ORB orb;
	
	//Need this for createing interface: Account;
	public ManagerImpl(ORB orb)
	{
		this.orb = orb;
	};
	
	//This is the method to return a array of all accounts.
	public String[] findAllAccounts() {
		
                //YOU NEED TO CONVERT THE HASHTABLE TO A STRING ARRAY!!!!!!!!!!!

               //JUST CREATING AN ARRAY WITH SOME VALUES!!!!!!!1111
               String[] a = new String[2];
                a[0] = "String 1";
                a[1] = "String 2";


                 //CALLING THE SIZE METHOD OF YOUR HASHTABLE NUMBER WILL GET BIGGER THE MORE ACCOUNTS THAT ARE ADDED
                   System.out.println("Size" + accountList.size());
		return a;
	}
	
	
	//This is the method to create a new account.
	public Account createAccount(String name, int balance)	{
		AccountImpl newAccount = new AccountImpl(name,balance);
		Account obj = newAccount._this(orb);
		// Creat a hashtable to store the info, also in BankClient.java to look up in the context for the table and the name
		try {
                        //ADD TO HASHTABLE   
			accountsList.put(name,newAccount);
	
		}     
		catch (Exception e) {
	      	System.out.println("Error while looking up account:");
	      	//e.printStackTrace();
	    }

		//obj.setAccountName(name);
		//obj.setBalance(balance);
		return obj;
	}
	
	//Retrun a specific account object;
	public Account findAccount(String name){
		
             Account a = new Account()
		return a;
	}

}