Changeset 9276


Ignore:
Timestamp:
2005-03-04T13:26:17+13:00 (19 years ago)
Author:
kjdon
Message:

can now send the same message to several modules - use a comma separated list in the to field.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java

    r7824 r9276  
    257257        mainResult.appendChild(this.doc.importNode(result, true));
    258258        } else {
    259         // find the module to pass it on to
    260         // need to put the request into a message element
    261         Element mess = message_doc.createElement(GSXML.MESSAGE_ELEM);
    262         mess.appendChild(req);
    263         String obj = GSPath.getFirstLink(path);
    264         if (this.module_map.containsKey(obj)) {
    265             result = ((ModuleInterface)this.module_map.get(obj)).process(mess);
    266             if (result !=null ) {
    267             // append the contents of the message to the mainResult - there will only be one response at this stage
    268             mainResult.appendChild(this.doc.importNode(GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM), true));
    269             } else {
    270             System.err.println("MessageRouter Error: request had null result!");
     259        String [] modules = path.split(",");
     260        for (int j=0; j<modules.length; j++) {
     261            String this_mod = modules[j];
     262            // find the module to pass it on to
     263            // need to put the request into a message element
     264            Element mess = message_doc.createElement(GSXML.MESSAGE_ELEM);
     265            req.setAttribute(GSXML.TO_ATT, this_mod);
     266            mess.appendChild(req);
     267            String obj = GSPath.getFirstLink(this_mod);
     268            if (this.module_map.containsKey(obj)) {
     269            result = ((ModuleInterface)this.module_map.get(obj)).process(mess);
     270            if (result !=null ) {
     271                // append the contents of the message to the mainResult - there will only be one response at this stage
     272                mainResult.appendChild(this.doc.importNode(GSXML.getChildByTagName(result, GSXML.RESPONSE_ELEM), true));
     273            } else {
     274                // add in a place holder response
     275                Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
     276                response.setAttribute(GSXML.FROM_ATT, this_mod);
     277                mainResult.appendChild(response);
     278                System.err.println("MessageRouter Error: request had null result!");
     279            }
     280           
     281            } else {   
     282            System.err.println("MessageRouter Error: request has illegal module name in:\n"+this.converter.getString(req));
    271283            }
    272         } else {   
    273             System.err.println("MessageRouter Error: request has illegal module name in:\n"+this.converter.getString(req));
    274284        }
    275285        }
Note: See TracChangeset for help on using the changeset viewer.