1 28 29 30 package org.objectweb.ccm.sessiondemo; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class SessionDemo 38 implements Runnable , java.awt.event.ActionListener 39 { 40 private ORBService _orb_service; 42 private ClientHome _client_home; 43 private ServerHome _server_home; 44 45 public 46 SessionDemo(ORBService orbs) 47 { 48 _orb_service = orbs; 50 _client_home = null; 51 _server_home = null; 52 } 53 54 58 final public void 59 run() 60 { 61 try { 62 ValueFactory vfact = new ValueFactoryImpl(org.omg.Components.CookieHelper.id(), new CookieFactoryImpl()); 64 _orb_service.register_valuefactory(vfact); 65 66 RegistrationService regs = org.objectweb.corba.runtime.Runtime.getRegistrationService(); 68 INSRegistrationScheme scheme = (INSRegistrationScheme)regs.get_scheme(INSRegistrationScheme.SCHEME_ID); 69 70 System.err.println("## Obtain homes"); 72 org.omg.CORBA.Object obj = null; 73 obj = scheme.lookup("ClientHome", _orb_service); 74 _client_home = ClientHomeHelper.narrow(obj); 75 obj = scheme.lookup("ServerHome", _orb_service); 76 _server_home = ServerHomeHelper.narrow(obj); 77 78 javax.swing.JPanel panel = new javax.swing.JPanel (new java.awt.BorderLayout ()); 80 javax.swing.JButton newb = new javax.swing.JButton ("new client"); 81 newb.setActionCommand("new"); 82 newb.addActionListener(this); 83 panel.add(newb, java.awt.BorderLayout.NORTH); 84 85 javax.swing.JFrame frame = new javax.swing.JFrame ("Client factory"); 86 frame.getContentPane().add(panel); 87 frame.pack(); 88 frame.show(); 89 90 } catch (Exception ex) { 91 ex.printStackTrace(); 92 throw new Error (ex.getMessage()); 93 } 94 95 System.out.println("Again ...."); 96 } 97 98 102 final public void 103 actionPerformed(java.awt.event.ActionEvent e) 104 { 105 String cmd = e.getActionCommand(); 106 107 try { 108 Client cl1 = _client_home.create(); 109 cl1.connect_server_home(_server_home); 110 cl1.configuration_complete(); 111 } catch (Exception ex) { 112 ex.printStackTrace(); 113 throw new Error (ex.getMessage()); 114 } 115 116 } 117 118 static public Runnable 119 main(ORBService orbs) 120 { 121 return new SessionDemo(orbs); 122 } 123 } 124 125 126 127 128 129 130 131 | Popular Tags |