Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

EventChannelFactory Class Reference

Inheritance diagram for EventChannelFactory:

Inheritance graph
[legend]
Collaboration diagram for EventChannelFactory:

Collaboration graph
[legend]
List of all members.

Public Methods

 EventChannelFactory ()
Identifier export (Object itf, Context hints)
org omg CORBA Object newEventChannel (String address, int port, String type) throws JonathanException
Identifier decode (byte[] data, int offset, int length) throws JonathanException
Identifier decode (UnMarshaller u) throws JonathanException
void bindConsumer (EBinder.EId id, Object consumer, Object channel_proxy) throws JonathanException
Identifier export (Object itf, Context hints)
Object newStub (SessionIdentifier ep, Identifier[] ids, Context hints) throws JonathanException
EventChannel newEventChannel (String address, int port, String type) throws JonathanException
void bindConsumer (Object consumer, EBinder.EId id) throws JonathanException
Identifier decode (byte[] data, int offset, int length) throws JonathanException
Identifier decode (UnMarshaller u) throws JonathanException

Static Public Methods

void bindConsumer (Object consumer, Object channel_proxy) throws JonathanException

Protected Methods

void initialize () throws JonathanException
void initialize (Context c, Object[] used_components) throws JonathanException

Private Methods

 EventChannelFactory (Context _c, Object[] _used_components) throws JonathanException
void initialize (Context _c, Object[] used_components) throws JonathanException
EBinder getEBinder ()
 EventChannelFactory (Context c, Object[] used_components) throws JonathanException
EBinder getEBinder ()

Private Attributes

EBinder ebinder
EBinder channel_factory
MarshallerFactory marshaller_factory

Static Private Methods

EBinder EId getId (Object proxy)

Detailed Description

The EventChannelFactory service allows the construction of EventChannels providing best-effort unreliable and unordered event dissemination. It relies on the RTP protocol on top of IP multicast.

Definition at line 70 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.


Constructor & Destructor Documentation

EventChannelFactory::EventChannelFactory ( ) [inline]
 

Constructs a new instance of EventChannelFactory.

This method should not be called directly by an application: It is here only to let EventChannelFactory be instanciated when one of the org.omg.CORBA.ORB.init(...) methods is called.

Definition at line 82 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00082                                 {
00083       super("/david/orbs/echannel");
00084    }

EventChannelFactory::EventChannelFactory ( Context c,
Object used_components[] ) [inline, private]
 

Definition at line 86 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00087                                {
00088       super();
00089       initialize(_c,_used_components);
00090    }

EventChannelFactory::EventChannelFactory ( Context c,
Object used_components[] ) [inline, private]
 

Definition at line 79 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00080                                {
00081       super();
00082       initialize(c,used_components);
00083    }


Member Function Documentation

void EventChannelFactory::bindConsumer ( Object consumer,
EBinder.EId id ) [inline]
 

Binds a consumer object to the event channel represented by the given identifier.

Parameters:
consumer   the consumer object to add to the channel
id   the identifier of the EventChannel
Exceptions:
JonathanException   thrown if something goes wrong

Definition at line 175 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00176                                {
00177                 channel_factory.bindConsumer(new OneWaySkeleton(consumer),id);
00178         }

void EventChannelFactory::bindConsumer ( EBinder.EId id,
Object consumer,
Object channel_proxy ) [inline]
 

Definition at line 236 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00237                                 {
00238       String stub_type = channel_proxy.getClass().getName();
00239       String skeleton_type = 
00240          stub_type.substring(0,stub_type.length() - 4) + "ImplBase";
00241       Skeleton skeleton = 
00242          ((EStubFactory) stub_factory).newSkeleton(skeleton_type,consumer);
00243       
00244       getEBinder().bindConsumer(new ConsumerDelegate(skeleton),id);
00245         }

void EventChannelFactory::bindConsumer ( Object consumer,
Object channel_proxy ) [inline, static]
 

Binds a consumer object to the event channel represented by the provided_proxy parameter.

Parameters:
consumer   a consumer object;
channel_proxy   a channel proxy.
Exceptions:
JonathanException   if something goes wrong.

Definition at line 176 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00177                                 {
00178       EBinder.EId id = getId(channel_proxy);
00179       if (id != null) {
00180          EventChannelFactory binder = (EventChannelFactory) id.getContext();
00181          binder.bindConsumer(id,consumer,channel_proxy);
00182       } else {
00183          throw new BindException("Unbound channel");   
00184       } 
00185         }   

Identifier EventChannelFactory::decode ( UnMarshaller u ) [inline]
 

Decodes an identifier from the provided unmarshaller.

Parameters:
u   an unmarhaller;
Returns:
an identifier managed by the target naming context;
Exceptions:
JonathanException   if something goes wrong.

Reimplemented from NamingContext.

Definition at line 208 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00209                                {
00210                 return channel_factory.decode(u);
00211         }

Identifier EventChannelFactory::decode ( byte data[],
int offset,
int length ) [inline]
 

Decode an indentifier representing an event channel out of the supplied array of bytes.

Parameters:
data   the array of bytes from which to decode the identifier
offset   the offset in bytes from which to start the decoding
length   the length in bytes of the portion of the byte array to decode
Returns:
an identifier representing the event channel
Exceptions:
JonathanException   thrown if the decoding fails

Reimplemented from NamingContext.

Definition at line 196 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00197                                {
00198                 return channel_factory.decode(data,offset,length);
00199         }

Identifier EventChannelFactory::decode ( UnMarshaller u ) [inline]
 

Returns an identifier, decoded using an UnMarshaller;

Parameters:
u   an unmarshaller;
Returns:
a decoded Identifier.
Exceptions:
JonathanException   if something goes wrong.

Reimplemented from NamingContext.

Definition at line 206 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00207                                {
00208                 return ebinder.decode(u);
00209         }

Identifier EventChannelFactory::decode ( byte data[],
int offset,
int length ) [inline]
 

Returns an identifier, decoded from a byte array portion.

Parameters:
data   the data to decode;
offset   the starting point of the valid data in data</data>;
length   the number of relevant bytes in data</data>;
Returns:
a decoded Identifier.
Exceptions:
JonathanException   if something goes wrong.

Reimplemented from NamingContext.

Definition at line 195 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00196                                {
00197                 return ebinder.decode(data,offset,length);
00198         }

Identifier EventChannelFactory::export ( Object itf,
Context hints ) [inline]
 

This operation has no meaning in this context: an InternalException is always thrown.

Parameters:
itf  
hints  
Returns:
never.

Reimplemented from NamingContext.

Definition at line 105 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00105                                                        {
00106       throw new InternalException("Meaningless operation.");
00107    }

Identifier EventChannelFactory::export ( Object itf,
Context hints ) [inline]
 

This operation has no meaning in this context: an InternalException is always thrown.

Parameters:
itf  
hints  
Returns:
never.

Reimplemented from NamingContext.

Definition at line 127 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00127                                                        {
00128       throw new InternalException("Meaningless operation.");
00129    }

EBinder EventChannelFactory::getEBinder ( ) [inline, private]
 

Definition at line 213 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00213                              {
00214                 return channel_factory;
00215         }

EBinder EventChannelFactory::getEBinder ( ) [inline, private]
 

Definition at line 212 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00212                              {
00213                 return ebinder;
00214         }

EBinder EId EventChannelFactory::getId ( Object proxy ) [inline, static, private]
 

Definition at line 216 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00216                                           {
00217       EBinder.EId id;
00218       if (proxy instanceof ObjectImpl) {
00219          Identifier[] ids =
00220             ((Reference) ((ObjectImpl) proxy)._get_delegate()).getIdentifiers();
00221          Object cid;
00222          for (int i = 0; i < ids.length; i++) {
00223             cid = ids[i];
00224             while (cid instanceof Identifier) {
00225                if (cid instanceof EBinder.EId) {
00226                   return (EBinder.EId) cid;
00227                } else {
00228                   cid = ((Identifier) cid).resolve();
00229                }        
00230             }
00231          }
00232       }
00233       return null;
00234    }

void EventChannelFactory::initialize ( Context c,
Object used_components[] ) [inline, protected]
 

Initializes the EventChannelfactory.

Parameters:
c   the Context instance to be used;
Exceptions:
JonathanException   if something goes wrong.

Definition at line 90 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00091                                {
00092       ChunkFactory chunk_factory = (ChunkFactory) used_components[0];
00093       marshaller_factory = (MarshallerFactory) used_components[1];
00094       channel_factory = new EBinder(chunk_factory,marshaller_factory,this,this);
00095    }

void EventChannelFactory::initialize ( Context c,
Object used_components[] ) [inline, private]
 

Initializes the EventChannelfactory.

Parameters:
c   the Context instance to be used;
Exceptions:
JonathanException   if something goes wrong.

Definition at line 103 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00103                                                                                  {
00104       // ORBClass method
00105       initialize(_c);
00106       // local 
00107       ChunkFactory chunk_factory = (ChunkFactory) used_components[0];
00108       domain = (NamingContext) used_components[1];
00109       marshaller_factory = 
00110          new PortableMarshallerFactory(chunk_factory,
00111                                        (ContextFactory) used_components[3],
00112                                        this,this);
00113       orb_context.addElement("DavidStreamFactory",DavidStreamFactory.class,
00114                              marshaller_factory,(char) 0);
00115       stub_factory = new EStubFactory(this,(ClassPathFinder) used_components[2]);
00116       ebinder = new EBinder(chunk_factory,marshaller_factory,this,stub_factory);
00117    }

void EventChannelFactory::initialize ( ) [inline, protected, virtual]
 

Initializes the EventChannelFactory.

Exceptions:
JonathanException   if something goes wrong.

Reimplemented from ORBClass.

Definition at line 96 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

00096                                                         {
00097       Object[] used_components = 
00098          EventChannelFactoryFactory.factory.getUsedComponents(orb_context);
00099       EventChannelFactoryFactory.factory.register(this,orb_context);
00100       initialize(orb_context,used_components);
00101    }

EventChannel EventChannelFactory::newEventChannel ( String address,
int port,
String type ) [inline]
 

Constructs and returns a new EventChannel

Parameters:
address   the IP multicast address to use
port   the port number to use
type   the type of the EventChannel
Returns:
an EventChannel
Exceptions:
JonathanException   thrown if something goes wrong

Definition at line 162 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00163                                {
00164                 return new EventChannelImpl(address, port, type, this);
00165         }

EventChannel EventChannelFactory::newEventChannel ( String address,
int port,
String type ) [inline]
 

Constructs and returns a new EventChannel.

type must the scoped name of the expected channel object type (not the operations type). The channel type must not be "org.omg.CORBA.Object".

Parameters:
address   the IP multicast address to use
port   the port number to use
type   the type of the EventChannel
Returns:
an EventChannel
Exceptions:
JonathanException   thrown if something goes wrong

Definition at line 143 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

Referenced by NewsSource::main().

00145                                {
00146       int index = type.lastIndexOf('.');
00147       String stub_type;
00148       if (index < 0) {
00149          stub_type = "_" + type + "Stub";
00150       } else {
00151          index++;
00152          stub_type = type.substring(0,index) + "_" + type.substring(index) + "Stub";
00153       }
00154       EStubFactory sf = (EStubFactory) stub_factory;
00155       ObjectImpl channel = sf.newStub(stub_type);
00156       String[] rep_ids = channel._ids();
00157       int nb = rep_ids.length;
00158       String types = rep_ids[0];
00159       for (int i = 1; i < nb; i++) {
00160          types = types + ";" + rep_ids[i];
00161       }
00162       EBinder.EId id = ebinder.newId(address,port,types);
00163       Delegate delegate = sf.newDelegate(id,id.getSessionIdentifier(),types);
00164       channel._set_delegate(delegate);
00165       return channel;
00166         }

Object EventChannelFactory::newStub ( SessionIdentifier ep,
Identifier ids[],
Context hints ) [inline]
 

Builds a new stub adapted for one-way event generation

Parameters:
ep   the protocol SessionIdentifier of the event channel
ids   the set of indentifiers for the stubs
hints   a String containing the type of the EventChannel
Returns:
a stub
Exceptions:
JonathanException   if something goes wrong

Definition at line 117 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

00118                                      {
00119       try {
00120          RemoteStub stub = null;
00121          RemoteRef ref = null;
00122          Class stub_class = null;
00123          ref = new OneWayRefImpl(ep,ids,marshaller_factory);
00124 
00125          Object component = null;
00126          if ((component = hints.getValue("remote_stub",(char) 0)) 
00127              instanceof RemoteStub) {
00128             stub = (RemoteStub) component;
00129          } else if ((component = hints.getValue("interface_type",(char) 0)) 
00130                     instanceof String) {
00131             stub_class = Class.forName((String) component + "_Stub");
00132          } else {
00133             throw new InternalException("Stub class specification required.");
00134          }
00135 
00136          if (stub instanceof StdStub) {
00137             ((StdStub) stub).setRef(ref);
00138          } else {
00139             if (stub != null) {
00140                stub_class = stub.getClass();
00141             }
00142             Constructor cnstr =
00143                stub_class.getConstructor(new Class[] {RemoteRef.class});
00144             stub = (RemoteStub) cnstr.newInstance(new Object[] {ref});
00145          }
00146          return stub;            
00147       } catch (ClassCastException e) {
00148          throw new InternalException("invalid call to newStub");
00149       } catch (Exception e) {
00150          throw new JonathanException(e);
00151       }
00152    }


Member Data Documentation

EBinder EventChannelFactory::channel_factory [private]
 

Definition at line 76 of file jeremie/libs/binding/echannel/EventChannelFactory.java.

EBinder EventChannelFactory::ebinder [private]
 

Definition at line 73 of file david/libs/binding/orbs/echannel/EventChannelFactory.java.

MarshallerFactory EventChannelFactory::marshaller_factory [private]
 

Reimplemented from ORBClass.

Definition at line 77 of file jeremie/libs/binding/echannel/EventChannelFactory.java.


The documentation for this class was generated from the following files:
Generated at Fri May 31 19:24:06 2002 for Jonathan by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001