IDL抽象方法错误

时间:2016-03-10 15:35:16

标签: java server client corba idl

我目前正在创建一个程序来接受用户注册并允许他们通过Corba“购买”电子书。 我得到的主要错误是:

BookServant is not abstract and does not override abstract method storeUserDetails(UserDetails) in distBkOperations

ebook.idl目前如下所示:

module BookAny {

struct UserDetails {
    string name;
    string password;
};

struct BookDetails {
    string bookID;
    string title;
    string price;
};


interface distBk {
void storeUserDetails(in UserDetails myUserDetails);
any getUserDetails(in string name, out any myUserDetails);

void storeBookDetails(in BookDetails myBookDetails);
any getBookDetails(in string title, out any myBookDetails);
}; };

BookServant.java如下所示:

    import java.io.*;
import java.util.*;
import BookAny.*;
import org.omg.CORBA.*;

public class BookServant implements distBkOperations{
    public static Hashtable hashtable;
    public static ORB orb;

public BookServant (org.omg.CORBA.ORB orb){
        hashtable = new Hashtable();
        this.orb=orb;
}

public void storeUserDetails (BookAny.UserDetails myUserDetails, AnyHolder password){

    Any pass = orb.create_any();

    myUserDetails.password="safepasswordlol";

    pass.insert_string(myUserDetails.password);

    password.value = pass;


    hashtable.put(myUserDetails.name, myUserDetails);
    System.out.println(myUserDetails.name + " You have registered and your password is  " +myUserDetails.password+myUserDetails.name);

}

public Any getUserDetails (String name, AnyHolder myUserDetails){

Any anyAB = orb.create_any();
try {
    UserDetails tempAddrBook = (UserDetails)hashtable.get(name);

    UserDetailsHelper.insert(anyAB, tempAddrBook);
    myUserDetails.value = anyAB;
}catch (Exception e) {
    System.err.println("Error E: "+e);
    e.printStackTrace(System.out);
    }
}


/*  public void getUserDetails (String name, org.omg.CORBA.AnyHolder myUserDetails){

Any anyAB = orb.create_any();
try {
    UserDetails tempAddrBook = (UserDetails)hashtable.get(name);

    UserDetailsHelper.insert(anyAB, tempAddrBook);
    myUserDetails.value = anyAB;
}catch (Exception e) {
    System.err.println("Error E: "+e);
    e.printStackTrace(System.out);
    }
}*/
}

我可以正确地从IDL生成文件,但在实际尝试编译BookServant或BookServer.java时,我得到了上述错误。我已经尝试将idl接口从void更改为any,但仍然没有。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

如错误所示,您的IDL文件在任何mock_some_external_thing.return_value = "there be dragons"操作中只有一个参数,即删除Java代码中的第二个参数

storeUserDetails