FileDocCategorySizeDatePackage
TestService.javaAPI DocExample7526Tue May 29 16:58:14 BST 2007wsrm.timeout.server

TestService

public class TestService extends Object implements com.sun.xml.ws.rm.jaxws.util.ProcessingFilter

Fields Summary
private boolean
duplicatesReceived
private boolean
timedOutOnce
public static String
sequenceId
private com.sun.xml.ws.rm.jaxws.runtime.InboundSequence
sequence
public static int
count
public static HashMap
messages
public WebServiceContext
wscontext
Constructors Summary
Methods Summary
public voidclearImpl(java.lang.String s)

        System.out.println("clear called");
        sequenceId = null;
        System.out.println("sequenceId = \"" + sequenceId + "\"");
        
        
        messages = 
            new HashMap<Integer, Integer>();
        count = 0;
        duplicatesReceived = false;
        timedOutOnce = false;
    
    
public java.lang.StringgetBufferSize(java.lang.String s)

        return Integer.toString(
                sequence.getSequenceConfig().getBufferSize());
    
public java.lang.StringgetFlowControl(java.lang.String s)

        return Boolean.toString(sequence.getSequenceConfig().getFlowControl());
    
public java.lang.StringgetInactivityTimeout(java.lang.String s)

        InboundSequence iseq = RMDestination
                .getRMDestination().getInboundSequence(sequenceId);
        SequenceConfig config = iseq.getSequenceConfig();
        
        System.out.println("timeout = " + config.getInactivityTimeout());
        String ret = Long.toString(
                config.getInactivityTimeout());
        return ret;
    
public java.lang.StringgetOrdered(java.lang.String s)

        return Boolean.toString(
         
            sequence.getSequenceConfig().getOrdered());    
    
public java.lang.StringgetSequenceId(java.lang.String s)

        return sequenceId;
    
public java.lang.StringgetSessionId(java.lang.String s)

    
        
        String id = null;
        if (wscontext != null ) { 
            id = (String)wscontext.getMessageContext().
                            get("com.sun.xml.ws.sessionid");
        } 
        
        if (id != null) {
            return id;
        } else {
            return "no session id";
        }
    
public booleanhandleClientRequestMessage(com.sun.xml.ws.rm.Message mess)

        return true;
    
public booleanhandleClientResponseMessage(com.sun.xml.ws.rm.Message mess)

       return true;
    
public voidhandleEndpointRequestMessage(com.sun.xml.ws.rm.Message mess)

     
        //first message will be call to clear() which sets sequenceId to null.
        //next message belongs to sequence we want to track
        if (sequenceId == null) {
            sequence = (InboundSequence)mess.getSequence();
            sequenceId = mess.getSequence().getId();
        }
        
        synchronized (this) {
            if (mess.getSequence().getId().equals(sequenceId)) {
                
                int messageNumber = mess.getMessageNumber();
                if (messages.containsValue(messageNumber)) {
                    duplicatesReceived = true;
                }
                messages.put(count++, mess.getMessageNumber());
       
            }
        }
    
public booleanhandleEndpointResponseMessage(com.sun.xml.ws.rm.Message mess)

        return true;
    
public voidhandleOutboundHeaders(com.sun.xml.ws.rm.Message mess)

public java.lang.StringisSequenceAlive(java.lang.String s)

        
        Sequence seq = RMDestination.
                getRMDestination().getInboundSequence(s);
        if (seq == null) {
            return "false";
        } else {
            return "true";
        } 
      
    
public voidprocessImpl(java.lang.String s)

        if (s.equals("block")) {
            try {
                Thread.sleep(3000);
            } catch (Exception e) {}
        }
        System.out.println("received message " + s.toString());
         System.out.println("sequenceId = \"" + sequenceId + "\"");
         System.out.println("sequence = \"" + sequence + "\"");
    
public java.lang.StringreportCount(java.lang.String s)

        System.out.println("reportCount.. count = " + count);
        return Integer.toString(count);
    
public java.lang.StringreportDuplicates(java.lang.String s)

        if (duplicatesReceived) {
            return "true";
        } else {
            return "false";
        }
    
public java.lang.StringreportSequence(java.lang.String s)

        String result = "";
  
        for (int i = 0; i < count; i++) {
            String num = messages.get(i).toString();
            result += num;
            result += ",";
        }
        
        return result;
    
public voidsetContext(javax.xml.ws.WebServiceContext context)

   
        
        this.wscontext = context;
    
public java.lang.StringtestTimeout(java.lang.String s)

        if (!timedOutOnce) {
            timedOutOnce = true;
            
            try {
                Thread.currentThread().sleep(10000);
            } catch (Exception e) {}
            return "false";
        } else {
            return "true";
        }