Changeset 3505


Ignore:
Timestamp:
2002-10-29T16:21:14+13:00 (22 years ago)
Author:
kjdon
Message:

Communicator more general now, Communicators are configured using the <site> element from teh config file of whoever is loading sites - now all types of Communicators should have the same construction method:
comm = new XXXCommunicator();
comm.configure(elem);
comm.setLocalSiteName(name);

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/Communicator.java

    r3502 r3505  
    3333    implements ModuleInterface {
    3434
    35     /** home directory of local site */
    36     protected String site_home_=null;
    3735    /** name of local site */
    3836    protected String local_site_name_ = null;
     37
    3938    /** name of site to connect to */
    40     protected String connection_name_=null;
    41     /** address of site to connect to */
    42     protected String connection_address_=null;
     39    protected String remote_site_name_=null;
     40
    4341    /** converter for String to DOM and vice versa */
    4442    protected XMLConverter converter_= null;
     
    4745    converter_ = new XMLConverter();
    4846    }
    49     public void setSiteHome(String home) {
    50     site_home_ = home;
    51     }
    52     public void setSiteName(String name) {
     47
     48    public void setLocalSiteName(String name) {
    5349    local_site_name_ = name;
    5450    }
    55 
    56     public void setConnectionName(String name) {
    57     connection_name_=name;
     51    /** this should be done as part of configure */
     52    public void setRemoteSiteName(String name) {
     53    remote_site_name_ = name;
    5854    }
    59 
    60     // format of address depends on connection type
    61     public void setConnectionAddress(String address){
    62     connection_address_ = address;
    63     }
    64  
    65     abstract public boolean configure();
     55    /** configures the Communicator using the <site> element */
     56    abstract public boolean configure(Element site_elem);
    6657
    6758    abstract public String process(String xml_in);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java

    r3504 r3505  
    4848    extends Communicator {
    4949
     50    /** address of site to connect to */
     51    protected String remote_site_address_=null;
     52
    5053    /** the call object that does the SOAP talking */
    5154    private Call call_ = null;
     
    6063    call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
    6164    }
    62    
    63     public void setConnectionName(String name) {
    64     System.out.println("name="+name);
    65     connection_name_ = name;
    66     // Set Object URI and Method Name
    67     call_.setTargetObjectURI (name);
    68     call_.setMethodName ("process"); // everything uses process
    69     }
    70    
    71     public boolean configure() {
     65       
     66    public boolean configure(Element site_elem) {
     67
     68    String type = site_elem.getAttribute("type");
     69    if (!type.equals("soap")) {
     70        System.err.println("SOAPCommunicator: wrong type of site");
     71        return false;
     72    }
     73    remote_site_name_ = site_elem.getAttribute("name");
     74    remote_site_address_ = site_elem.getAttribute("address");
     75    if (remote_site_name_==null || remote_site_name_.equals("")) {
     76        System.err.println("SOAPCommunicator: must have name attribute in site element");
     77        return false;
     78    }
     79    if (remote_site_address_==null || remote_site_address_.equals("")) {
     80        System.err.println("SOAPCommunicator: must have address attribute in site element");
     81        return false;
     82    }
     83    call_.setTargetObjectURI(remote_site_name_);
     84    call_.setMethodName("process");
     85
    7286    return true;
    7387    }
     
    119133       
    120134        //  Set the URL for the Web Service
    121         URL url = new URL(connection_address_);
     135        URL url = new URL(remote_site_address_);
    122136       
    123137        // Invoke the Service
     
    138152            Element e = (Element)responses.item(i);
    139153            String from = e.getAttribute("from");
    140             from = GSPath.prependLink(from, connection_name_);
     154            from = GSPath.prependLink(from, remote_site_name_);
    141155            e.setAttribute("from", from);
    142156        }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r3502 r3505  
    365365            String type = s.getAttribute("type");
    366366            String name = s.getAttribute("name");
    367             System.out.println("..."+name+", type="+type);
    368367            if (type.equals("soap")) {
    369368                comm = new SOAPCommunicator();
    370                 comm.setSiteHome(site_home_);
    371                 comm.setConnectionName(name);
    372                 comm.setConnectionAddress(s.getAttribute("address"));
    373                 comm.setSiteName(site_name_);
     369                if (comm.configure(s)) {
     370                comm.setLocalSiteName(site_name_);
    374371               
    375                 // add to map of modules
    376                 module_map_.put(name, comm);
    377                 site_list_.appendChild(doc_.importNode(s, true));
    378                 // need to get collection list and service list from here
    379                 // this may introduce a configure problem - leave as
    380                 // is for now, but fix up later - kjdon
    381                 getRemoteCollectionInfo(comm, name);
    382                 getRemoteServiceInfo(comm, name);
     372                // add to map of modules
     373                module_map_.put(name, comm);
     374                site_list_.appendChild(doc_.importNode(s, true));
     375                // need to get collection list and service
     376                // list from here- this may introduce a
     377                // configure problem - leave as  is for now,
     378                // but fix up later - kjdon
     379                getRemoteCollectionInfo(comm, name);
     380                getRemoteServiceInfo(comm, name);
     381                } else {
     382                System.err.println("couldn't configure soap site:"+name);
     383                }
    383384               
    384385            } else {
Note: See TracChangeset for help on using the changeset viewer.