Changeset 14399

Show
Ignore:
Timestamp:
03.09.2007 13:16:35 (12 years ago)
Author:
xiao
Message:

modify the method configureServices so that if a service class is not found in package org.greenstone.gsdl3.service, try the service name alone in case the package is already specified in the name.

Files:
1 modified

Legend:

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

    r14262 r14399  
    6161 * @see Communicator 
    6262 * 
    63  */ 
     63  * Since some service classes are moved into a separate directory in order for them to be checked out from a different repository, 
     64 * we modify the configureServices method to search some of the classes in other place if they are not found in the service directory. 
     65*/ 
    6466public class MessageRouter implements  ModuleInterface { 
    6567   
     
    239241     
    240242    logger.debug("MR received request"); 
    241     logger.info(this.converter.getString(message)); 
     243    //logger.info(this.converter.getString(message)); 
    242244    // check that its a correct message tag 
    243245    if (!message.getTagName().equals(GSXML.MESSAGE_ELEM)) { 
     
    303305          if (this.module_map.containsKey(obj)) { 
    304306            copied_request.setAttribute(GSXML.TO_ATT, this_mod); 
     307//            logger.info("::::::::::::::: \n"+this.converter.getString(req)); 
    305308            result = ((ModuleInterface)this.module_map.get(obj)).process(mess); 
    306309            if (result !=null ) { 
     
    309312              if (res != null){ 
    310313                mainResult.appendChild(this.doc.importNode(res, true)); 
     314  
    311315              } 
    312316            } else { 
     
    363367      String service_name = n.getAttribute(GSXML.NAME_ATT); 
    364368      logger.info("..."+service_name); 
     369       
     370      Class service_class = null; 
    365371      try { 
    366         ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+service_name).newInstance(); 
     372          service_class = Class.forName("org.greenstone.gsdl3.service."+service_name); 
     373      } catch(ClassNotFoundException e) { 
     374           
     375          try { 
     376              //try the service_name alone in case the package name is already specified 
     377              service_class = Class.forName(service_name); 
     378               
     379          }catch(ClassNotFoundException ae) { 
     380              logger.info(ae.getMessage()); 
     381          } 
     382      } 
     383      try { 
     384           
     385        //ServiceRack s = (ServiceRack)Class.forName("org.greenstone.gsdl3.service."+service_name).newInstance(); 
     386        ServiceRack s = (ServiceRack)service_class.newInstance(); 
    367387        s.setSiteHome(this.site_home); 
    368388        s.setSiteAddress(this.site_http_address);