請幫我創建此代理設計模式的主類?代理設計模式中主類的代碼是什麼?
//Filename:Payment.java
import java.math.*; import java.rmi.*;
public interface Payment extends Remote{
public void purchase(PaymentVO payInfo, BigDecimal price)
throws PaymentException, RemoteException; }
//文件名:PaymentException.java
`public class PaymentException extends Exception{
public PaymentException(String m){
super(m);
}
public PaymentException(String m, Throwable c){
super(m, c);
}
}`
//Filename:PaymentImpl.java
`import java.math.*;
import java.net.*;
import java.rmi.*;
import java.rmi.server.*;
public class PaymentImpl implements Payment{
private static final String PAYMENT_SERVICE_NAME = "paymentService";
public PaymentImpl() throws RemoteException, MalformedURLException{
UnicastRemoteObject.exportObject(this);
Naming.rebind(PAYMENT_SERVICE_NAME, this);
}
public void purchase(PaymentVO payInfo, BigDecimal price)
throws PaymentException{
}
}`
//文件名:Paym entService.java
import java.math.*;
public interface PaymentService{
public void purchase(PaymentVO payInfo, BigDecimal price)
throws PaymentException, ServiceUnavailableException;
}
//文件名:PaymentVO.java
public class PaymentVO{
}
//文件名:ServiceUnavailableException.java
public class ServiceUnavailableException extends Exception{
public ServiceUnavailableException(String m){
super(m);
}
public ServiceUnavailableException(String m, Throwable c){
super(m, c);
}
}
你似乎在這裏失去了幾節課。你可以檢查一下嗎? – maheeka 2014-12-05 05:46:58