我有一个扩展 Swing JFrame 的类。为了让此类接收回调并调用此类中的方法,该类应扩展 POA 类。我不知道该怎么做。多重继承呢?我应该创建另一个扩展 POA 类的类吗?
代码
public final class JFSECorbaClient extends javax.swing.JFrame {
//
// init and other method
//
public static void main(final String args[]) throws ClassNotFoundException, IllegalAccessException, InstantiationException{
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
frame = new JFSECorbaClient().setVisible(true);
try {
//initialize orb
Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBInitialPort", "1050");
props.put("org.omg.CORBA.ORBInitialHost", "localhost");
ORB orb = ORB.init(args, props);
System.out.println("Initialized ORB");
//Instantiate Servant and create reference
POA rootPOA = POAHelper.narrow(
orb.resolve_initial_references("RootPOA"));
rootPOA.activate_object(this.frame); //this.frame should extends jfseCallbackPOA
ref = jfseCallbackHelper.narrow(
rootPOA.servant_to_reference(callbackListener));
//Resolve MessageServer
jfseServer = jfseORBHelper.narrow(
orb.string_to_object("corbaname:iiop:1.2@localhost:1050#MessageServer"));
//Activate rootpoa
rootPOA.the_POAManager().activate();
//thread for receive callback in other class thread
JFSECorrbaListener th = new JFSECorrbaListener();
th.setOrb(orb);
th.start();
} catch (Exception e) {
System.out.println(e);
}
}
});
}