| D:\DEV\PROJECTS\Harbor_ATM_DEMO_SHIP\src\harbor_atm_demo\CD_UNIT.java |
package harbor_atm_demo;
import kewlstuff.atm.demo.interfaces.*;
import kewlstuff.harbor.client.Vessel;
import javax.swing.JOptionPane;
public class CD_UNIT implements I_CD_Unit{
I_BankInstructionProcessor i_BankInstructionProcessor = null;
private Vessel vessel = null;
public CD_UNIT() {
String harborUrl = "http://localhost:8080/harbor/service";
Vessel.loadUserConfig();
String harborTestUrl = Vessel.getUserProperty("HARBOR_SITE_URL");
if(harborTestUrl != null){
Vessel.setLocalAdminLogMessage("URL environment variable set to " + harborTestUrl);
harborUrl = harborTestUrl;
JOptionPane.showMessageDialog(null,harborUrl, "URL Setting in config file", JOptionPane.INFORMATION_MESSAGE);
}
vessel = new Vessel(harborUrl);
vessel.enableProgressDisplay(true);
boolean fSuccess = vessel.certifiedSecurity("Company B");
}
public void startATM(){
if(!vessel.isCommsSecure()){
JOptionPane.showMessageDialog(null, "A secure line could not be established", "Cannot Continue", JOptionPane.WARNING_MESSAGE);
return;
}
i_BankInstructionProcessor = (I_BankInstructionProcessor)vessel.loadRemoteClassInst(I_BankInstructionProcessor.class,"kewlstuff.atm.demo.server.BankInstructionProcessor");
Class uiApp = vessel.getRemoteClass("kewlstuff.atm.demo.UI.ATM_Terminal");
if(uiApp != null){
I_UI atmTerminal = (I_UI)vessel.newInst(uiApp);
atmTerminal.start(this);
}
}
public void closeDownServer(){
if(i_BankInstructionProcessor != null) vessel.releaseRemoteClassInst(i_BankInstructionProcessor);
}
public byte[] processRemoteInstruction(byte[] bInstruction, byte[] userCertificate, byte[] auxData){
if(i_BankInstructionProcessor == null) return null;
try {
return i_BankInstructionProcessor.processRemoteInstruction(bInstruction,userCertificate,auxData);
} catch(Exception e){
JOptionPane.showMessageDialog(null, "Please check the internet connection and retry", "Communications Failed", JOptionPane.WARNING_MESSAGE);
}
return null;
}
public static void main(String[] args) {
new CD_UNIT().startATM();
}
}