Ignore:
Timestamp:
03/11/15 13:56:46 (9 years ago)
Author:
pharms
Message:
  • created support for client names
  • adapted support for service names
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java

    r1884 r1906  
    6565    /** 
    6666     * <p> 
    67      * the name of the service; this is either the path or, if a path map is available 
     67     * the name of the client; this is either the host/ip and port of the sender or, if a path 
     68     * map is available, a human readable name that may be based also on the receiver 
     69     * </p> 
     70     */ 
     71    private final String clientName; 
     72    
     73    /** 
     74     * <p> 
     75     * the name of the service; this is either the path or, if a path map is available, a human 
     76     * readable name that is mapped to the path 
    6877     * </p> 
    6978     */ 
     
    107116        StringBuffer nameBuffer = new StringBuffer("SOAPEvent"); 
    108117         
    109         boolean somethingAdded = false; 
    110          
     118        // determine the client name 
     119        if (urlNameMap == null) { 
     120            clientName = exchange.getSender().getHost() + ":" + exchange.getSender().getPort(); 
     121        } 
     122        else { 
     123            // check for a mapping of the sender host 
     124            String key = "clientName.sender." + exchange.getSender().getHost(); 
     125            String value = urlNameMap.getProperty(key); 
     126             
     127            if (value == null) { 
     128                key += ":" + exchange.getSender().getPort(); 
     129                value = urlNameMap.getProperty(key); 
     130            } 
     131             
     132            if (value == null) { 
     133                key = "clientName.receiver." + exchange.getReceiver().getHost(); 
     134                value = urlNameMap.getProperty(key); 
     135            } 
     136             
     137            if (value == null) { 
     138                key += ":" + exchange.getReceiver().getPort(); 
     139                value = urlNameMap.getProperty(key); 
     140            } 
     141             
     142            if (value != null) { 
     143                clientName = value; 
     144            } 
     145            else { 
     146                clientName = exchange.getSender().getHost() + ":" + exchange.getSender().getPort(); 
     147            } 
     148        } 
     149 
     150        nameBuffer.append(clientName); 
     151         
     152        // determine the service name 
    111153        if (path != null) { 
    112             nameBuffer.append("("); 
    113             if( urlNameMap==null ) { 
     154            nameBuffer.append(", "); 
     155            if (urlNameMap == null) { 
    114156                serviceName = path; 
    115             } else { 
    116                 String value = urlNameMap.getProperty(path); 
    117                 if( value!=null ) { 
     157            } 
     158            else { 
     159                String value = urlNameMap.getProperty("serviceName.path." + path); 
     160                if (value != null) { 
    118161                    serviceName = value; 
    119                 } else { 
     162                } 
     163                else { 
    120164                    serviceName = path; 
    121165                } 
    122166            } 
    123167            nameBuffer.append(serviceName); 
    124             somethingAdded = true; 
    125         } else { 
     168        } 
     169        else { 
    126170            serviceName = "NA"; 
    127171        } 
    128172         
    129173        if (calledMethod != null) { 
    130             nameBuffer.append(somethingAdded ? ", " : "("); 
     174            nameBuffer.append(", "); 
    131175            nameBuffer.append(calledMethod); 
    132             somethingAdded = true; 
    133176        } 
    134177         
     
    137180         
    138181        if ((senderStr != null) && (receiverStr != null)) { 
    139             nameBuffer.append(somethingAdded ? ", " : "("); 
     182            nameBuffer.append(", "); 
    140183            nameBuffer.append(senderStr); 
    141184            nameBuffer.append(" --> "); 
    142185            nameBuffer.append(receiverStr); 
    143             somethingAdded = true; 
    144186        } 
    145187        else if (senderStr != null) { 
    146             nameBuffer.append(somethingAdded ? ", " : "("); 
     188            nameBuffer.append(", "); 
    147189            nameBuffer.append(senderStr); 
    148             somethingAdded = true; 
    149190        } 
    150191        else if (receiverStr != null) { 
    151             nameBuffer.append(somethingAdded ? ", " : "("); 
     192            nameBuffer.append(", "); 
    152193            nameBuffer.append(receiverStr); 
    153             somethingAdded = true; 
    154         } 
    155          
    156         if (somethingAdded) { 
    157             nameBuffer.append(")"); 
    158         } 
     194        } 
     195         
     196        nameBuffer.append(")"); 
    159197         
    160198        this.name = nameBuffer.toString(); 
     
    170208    public String getCalledMethod() { 
    171209        return calledMethod; 
     210    } 
     211     
     212    /** 
     213     * <p> 
     214     * the name of the client calling in this request 
     215     * </p> 
     216     * 
     217     * @return the name of the client calling in this request 
     218     */ 
     219    public String getClientName() { 
     220        return clientName; 
    172221    } 
    173222     
     
    229278                super.equals(obj) && 
    230279                HTTPUtils.equals(calledMethod, ((SOAPEventType) obj).calledMethod) && 
    231                 HTTPUtils.equals(serviceName, ((SOAPEventType) obj).serviceName); 
     280                HTTPUtils.equals(serviceName, ((SOAPEventType) obj).serviceName) && 
     281                HTTPUtils.equals(clientName, ((SOAPEventType) obj).clientName); 
    232282        } 
    233283        else { 
     
    247297        if( serviceName != null ) { 
    248298            hashCode += serviceName.hashCode(); 
     299        } 
     300        if( clientName != null ) { 
     301            hashCode += clientName.hashCode(); 
    249302        } 
    250303        return hashCode; 
Note: See TracChangeset for help on using the changeset viewer.