2012-04-29 5 views
0

Swing JFrame을 확장하는 클래스가 있습니다. 이 클래스가 콜백을 수신하여이 클래스의 메소드를 호출하려면 클래스가 POA 클래스를 확장해야합니다. 어떻게해야할지 모르겠다. 다중 상속은 어떨까요? POA 클래스를 확장하는 다른 클래스를 만들어야합니까?Java Swing을 사용하여 CORBA 콜백 수신

코드

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:[email protected]: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); 
       } 
      } 
     }); 

    } 
+0

코드를 알려주십시오. 도움이 될거야 ... – andersoj

답변

1

그것은 당신이 IDL을 관리하는 경우 POA 클래스를 확장 할 필요가 없습니다 : 생성 할 때 원격 인터페이스에서 생성, RMI/IIOP를 통해 IDL을 콜백을 정의 할 수 있습니다 (rmic -iiop), PortableRemoteObject.exportObject()를 사용해 export합니다. 특정 클래스를 확장 할 필요가 없습니다.

모든 것을 말한 것은 잘못된 대답입니다. JFrame 확장 클래스는 CORBA 콜백 일 필요가 없습니다. CORBA 콜백을 완전히 별개의 클래스로 정의하고 JFrame 확장 클래스에 후크를 제공하여 콜백이 발생할 때 필요한 모든 작업을 수행하십시오.

관련 문제