Ignore:
Timestamp:
2003-03-18T15:06:40+12:00 (21 years ago)
Author:
kjdon
Message:

changed the way the process methods are called - now if one is not found for the actuall class, the superclasses are checked for the method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/service/ServiceRack.java

    r3851 r3900  
    172172        Element response = null;
    173173        if (service_info_map_.containsKey(to)) {
    174            
    175174            try {
    176             Class c = this.getClass();
    177             Class []params = {Class.forName("org.w3c.dom.Element")};
    178             Method m = c.getDeclaredMethod("process"+to, params);
     175            Class c = this.getClass();
     176            Class []params = {Class.forName("org.w3c.dom.Element")};
     177
     178            String method_name = "process"+to;
     179            Method m = null;
     180            while (c != null) {
     181           
     182            try {
     183                m = c.getDeclaredMethod(method_name, params);
     184                // if this has worked, break
     185                break;
     186            } catch (NoSuchMethodException e) {
     187                System.out.println("method not found for this class, trying super class");
     188                c = c.getSuperclass();
     189            } catch (SecurityException e) {
     190                System.out.println("security exception for finding a method, returning null");
     191                return null;
     192            }
     193            } // while
     194            if (m != null) {
    179195            Object []args = {request};
    180             response = (Element)m.invoke(this, args);
    181            
    182             } catch (Exception e) {
    183             System.out.println("ServiceRack: Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
    184             return null;
     196            try {
     197                response = (Element)m.invoke(this, args);
     198               
     199            } catch (Exception e) {
     200                System.out.println("ServiceRack: Trying to call a processService type method (process"+to+") on a subclass("+this.getClass().getName()+"), but an exception happened:"+e.toString());
     201                return null;
     202            }
     203            } else {
     204            System.out.println("no method found");
    185205            }
    186206            if (response !=null) {
    187207            mainResult.appendChild(doc_.importNode(response, true));
     208            }
     209                       
     210            } catch (ClassNotFoundException e) {
     211            System.out.println("ServiceRack error:element class not found");
     212            return null;
    188213            }
    189214        } else {
     
    194219        }
    195220    } // for each request
    196 
    197 
     221   
    198222    return mainResult;
    199223       
Note: See TracChangeset for help on using the changeset viewer.