zeus.actors.factories
Class IIOP_Z_HTTP_TransportFactory

java.lang.Object
  extended byzeus.actors.factories.IIOP_Z_HTTP_TransportFactory
All Implemented Interfaces:
TransportFactory

public class IIOP_Z_HTTP_TransportFactory
extends java.lang.Object
implements TransportFactory

IIOP_Z_HTTP_TransportFactory is a simple implementation of the TransportFactory that takes an address string and returns an appropriate transport for that agent.

  • if the agent is a zeus agent then a wrapped version of the standard zeus postman and server is returned.
  • if the agent is using a FIPA_97 IIOP transport then a wrapped FIPA_Agent_97 is returned
  • if the agent is using a FIPA_99 IIOP transport then a wrapped FIPA.MTS is returned
  • if any other transport is detected then an error is raised.
  • Note: we will seek to support other transports, but it is likely that this transport factory will not: so basically ensure that you DO NOT directly instantiate this class.

    TO USE THIS
    Call zeus.actors.service.TransportFactoryMethod.getTransportFactory(), this will return a class of type TransportFactory. In the initial implementation it will always be this class, *but* in the future we may implement lightweightTransportFactory, IIOP_HTTP_TransportFactory or JMS_TransportFactory, and use a system property to define which one is returned by the TransportFactoryMethod in a given agent...

    ISSUES

    is this at all sensible? Or am I making a mountain out of a mole hill?
    need context to make zeus transport

    Since:
    1.1
    Author:
    Simon Thompson

    Field Summary
    private  int _maxSize
               
    private  ZeusAgentContext context
               
    private  java.io.File file
               
    private static ConnectionPool pool
               
     
    Constructor Summary
    IIOP_Z_HTTP_TransportFactory()
               
     
    Method Summary
    (package private)  void debug(java.lang.String str)
               
     OutTray getTransport(java.lang.String address)
              this method returns a transport for this address. having called this all you need to do to send a message is call Transport.send(Envelope); HOW IT WORKS 1) check and see if the address starts with the key word(s) iiop/iiopname 2) split out the address (name.domain.type) and port (:9000) and use them to initialise an orb 3) then churn through the naming contexts that it uses - if an address is of the form iiop://name.domain.type:9000/xxx/yyy/zzz/acc then this means that there are three naming contexts (xxx,yyy,zzz) which must be found before we can get hold of acc. 4) when we have acc we will know because an ClassCastException will have been thrown.. so handle it by trying to cast to either FIPA_Agent_97 or FIPA.MTS.
    private  org.omg.CORBA.Object resolveNaming(org.omg.CosNaming.NamingContext nc, org.omg.CORBA.ORB orb, java.lang.String name)
              primative at the mo - walks the whole tree
     void setContext(ZeusAgentContext context)
               
     void setLog(java.io.File file)
              implement this so that the correct transport is returned for a AID
    private  void testNamingContext(org.omg.CosNaming.NamingContext nc, org.omg.CORBA.ORB orb)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    context

    private ZeusAgentContext context

    _maxSize

    private int _maxSize

    pool

    private static ConnectionPool pool

    file

    private java.io.File file
    Constructor Detail

    IIOP_Z_HTTP_TransportFactory

    public IIOP_Z_HTTP_TransportFactory()
    Method Detail

    setContext

    public void setContext(ZeusAgentContext context)

    setLog

    public void setLog(java.io.File file)
    Description copied from interface: TransportFactory
    implement this so that the correct transport is returned for a AID

    Specified by:
    setLog in interface TransportFactory

    getTransport

    public OutTray getTransport(java.lang.String address)
                         throws TransportUnsupportedException
    this method returns a transport for this address. having called this all you need to do to send a message is call Transport.send(Envelope);

    HOW IT WORKS

    1) check and see if the address starts with the key word(s) iiop/iiopname 2) split out the address (name.domain.type) and port (:9000) and use them to initialise an orb 3) then churn through the naming contexts that it uses - if an address is of the form iiop://name.domain.type:9000/xxx/yyy/zzz/acc then this means that there are three naming contexts (xxx,yyy,zzz) which must be found before we can get hold of acc. 4) when we have acc we will know because an ClassCastException will have been thrown.. so handle it by trying to cast to either FIPA_Agent_97 or FIPA.MTS. If you can do that then no probs, use the result to initialise a transport object of the appropriate type and return it. 5) if no cast works then throw an UnsupportedTransportException 6) Handle the http: case (throw an Exception) 7) Otherwise try a Zeus address, and if this works then return a zeus transport object

    ISSUES

    This is a bad, bad method: appologies (I am in a hurry and rather up against it here!). There is far too much code in one block and it is very complex - so refactor, refactor!

    Specified by:
    getTransport in interface TransportFactory
    Throws:
    TransportUnsupportedException

    testNamingContext

    private void testNamingContext(org.omg.CosNaming.NamingContext nc,
                                   org.omg.CORBA.ORB orb)

    resolveNaming

    private org.omg.CORBA.Object resolveNaming(org.omg.CosNaming.NamingContext nc,
                                               org.omg.CORBA.ORB orb,
                                               java.lang.String name)
    primative at the mo - walks the whole tree


    debug

    void debug(java.lang.String str)


    Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.