HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"Distributing Events"
Vol. 2, Issue 10, p. 46

	

Listing 1: Extensions.
 
public class EventObject extends Object 
{// constructor - source is the object the event occurred in    
public EventObject( Object source );    
// getSource() returns the object the event occurred initially upon    
public Object getSource()} 

Listing 2: Client-side Event Handler interface.
 
struct ConnectionInfo {    string hostname;    long port;};
interface ClientEventHandler 
{void bind_succeeded(in Object obj, in ConnectionIno info);        
void bind_failed( in Object obj );   
void server_aborted( in Object obj );    
void rebind_succeeded( in Object obj, in ConnectionIno info);    
void rebind_failed( in Object obj );}; 

Listing 3: Server-side Event Handler interface.
 
interface ImplEventhandler ]
{void bind( in ConnectionInfo info, in Principal, in Object obj );    
void unbind( in ConnectionInfo info,in Principal, in Object obj );    
void client_aborted( in ConnectionInfo info, in Object obj );    
void pre_method( in ConnectionInfo info, in Principal,
in string operation_name, in Object obj );    
void post_method( in ConnectionInfo info, in Principal,
in string operation_name, in Object obj );     
void post_method_exception( in ConnectionInfo info, in Principal,
in string operation_name, in string exception_name,in Object obj ); 

Listing 4: JavaBeans event interfaces in IDL.
 
module TestEvent 
{exception ListenerAlreadyKnown{};    
exception UnknownListener{};    
struct Event {Object source;        
string str;};    
interface EventListener {void handle_event( in Event event );    
};    
interface EventSource 
{void addEventListener( in EventListener listener )             raises(ListenerAlreadyKnown);
void removeEventListener( in EventListener listener )             raises(UnknownListener);}; 

Listing 5: Inserting events in Any objects and their  
extraction.
 
public class EventHelper 
{// insertion of the event into an Any and issuing of the event  
public static void insert
(org.omg.CORBA.Any any, TestEvent.Event value ) 
{}  // receiving the event and extraction of the 
event from the Any  public static TestEvent.Event 
extract(org.omg.CORBA.Any any) {}}

 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.