从处理程序类中获取值

时间:2014-06-01 20:47:35

标签: java corba

我写了一个基于CORBA的程序。我使用此代码调用两个函数:

AMI_StockQuotesServerHandler cbHandler = new AMICallbackHandler()._this(orb);
  ((_StockQuotesServerStub)server).sendc_getQuoteByName(cbHandler, "GOOGLE");
 ((_StockQuotesServerStub)server).sendc_getQuoteByISIN(cbHandler, "GOL");
try
            {
                Thread.currentThread().sleep ( 100 );
            }
            catch (InterruptedException ex) {}
// How to get the received value here ? 

我在班级AMICallbackHandler收到了结果:

public class AMICallbackHandler extends AMI_StockQuotesServerHandlerPOA
{
    @Override
    public void getQuoteByName(stock_quote ami_return_val) {
        System.out.println(ami_return_val.name + ": " + ami_return_val.price);
    }

    @Override
    public void getQuoteByName_excep(ExceptionHolder excep_holder) {
        System.out.println("Not found ");

    }

    @Override
    public void getQuoteByISIN(stock_quote ami_return_val) {
        System.out.println(ami_return_val.isin + ": " + ami_return_val.price);
    }

    @Override
    public void getQuoteByISIN_excep(ExceptionHolder excep_holder) {
        System.out.println("Not found ");

我尝试添加类似的内容,但我收到了消息

  

方法没有覆盖超类的方法

private static int priceByName;
private static int priceByIsin;
....
....
priceByName=ami_return_val.price;
...
...
priceByIsin=ami_return_val.price;
...

@Override
public int checkPrice(){
    if(priceByIsin==priceByName)
        return priceByIsin;
    return 0;
}

1 个答案:

答案 0 :(得分:0)

您很可能会看到此错误消息,因为checkPrice()方法所在的一个类继承的类没有checkPrice()方法。为了解决此问题,您可能应该删除@Overrides注释。