Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //  The contents of this file are subject to the Mozilla Public License
  //  Version 1.1 (the "License"); you may not use this file except in
  //  compliance with the License. You may obtain a copy of the License
  //  at http://www.mozilla.org/MPL/
  //
  //  Software distributed under the License is distributed on an "AS IS"
  //  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  //  the License for the specific language governing rights and
  //  limitations under the License.
 //
 //  The Original Code is RabbitMQ.
 //
 //  The Initial Developer of the Original Code is VMware, Inc.
 //  Copyright (c) 2007-2011 VMware, Inc.  All rights reserved.
 //
 
 
 package com.rabbitmq.client;
 
 import java.util.Map;
 
Subclass of RpcServer which uses AMQP wire-format encoded tables as requests and replies.
 
 public class MapRpcServer extends RpcServer {
     public MapRpcServer(Channel channelthrows IOException
     { super(channel); }
 
     public MapRpcServer(Channel channelString queueNamethrows IOException
     { super(channelqueueName); }

    
Overridden to delegate to handleMapCall.
 
     public byte[] handleCall(byte[] requestBodyAMQP.BasicProperties replyProperties)
     {
         try {
             return encode(handleMapCall(decode(requestBody), replyProperties));
         } catch (IOException ioe) {
             return new byte[0];
         }
     }
 
     public static Map<StringObjectdecode(byte[] requestBody)
         throws IOException
     {
         MethodArgumentReader reader =
             new MethodArgumentReader(new ValueReader
                                      (new DataInputStream
                                       (new ByteArrayInputStream(requestBody))));
         Map<StringObjectrequest = reader.readTable();
         return request;
     }
 
     public static byte[] encode(Map<StringObjectreply)
         throws IOException
     {
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         MethodArgumentWriter writer = new MethodArgumentWriter(new ValueWriter(new DataOutputStream(buffer)));
         writer.writeTable(reply);
         writer.flush();
         return buffer.toByteArray();
     }

    
Delegates to handleMapCall(Map<String, Object>).
 
     public Map<StringObjecthandleMapCall(Map<StringObjectrequest,
                                              AMQP.BasicProperties replyProperties)
     {
         return handleMapCall(request);
     }

    
Default implementation - override in subclasses. Returns the empty string.
 
     public Map<StringObjecthandleMapCall(Map<StringObjectrequest)
     {
         return new HashMap<StringObject>();
     }

    
Overridden to delegate to handleMapCast.
 
     public void handleCast(byte[] requestBody)
     {
         try {
            handleMapCast(decode(requestBody));
        } catch (IOException ioe) {
            // Do nothing.
        }
    }

    
Default implementation - override in subclasses. Does nothing.
    public void handleMapCast(Map<StringObjectrequestBody) {
        // Do nothing.
    }
New to GrepCode? Check out our FAQ X