All pastes #386669 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-08 20:28 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.Vector;
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;);
	private String[] accountList;
	private Account bankAccount;
	private ORB orb;
	private int credit;
	//private Dictionary _accountsTable = new Hashtable ();
	
	//Need this for createing interface: Account;
	public ManagerImpl(ORB orb)
	{
		this.orb = orb;
		//When server start, automatic create 3 account for example;
		//createAccount("Mike", 100);
	};
	
	//This is the method to return a array of all accounts.
	public String[] findAllAccounts() {
		
		return accountList;
	}
	
	
	//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 {
			//Vector accountVector = new Vector();
			//accountVector.add(newAccount);
			Hashtable test = new Hashtable();
			//ORB orb = ORB.init();
			//org.omg.CORBA.Object o = orb.resolve_initial_references("NameService");
			//NamingContextExt rootContext = NamingContextExtHelper.narrow( o );
      		// get the root naming context
	      	// bind the Object Reference in Naming
      		
     	 	//NameComponent path[] = rootContext.to_name( name );
      		//rootContext.rebind(path, test);


			
			
			
			
			//rootContext.
			//Context ctx = new InitialContext(test);
			
			// Register our Account with the CORBA naming service
			//ctx.rebind("Mike", 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){
		//Method here		
		//orb.getAccountName();
		return bankAccount;
	}

}