package com.shopwiki.messaging.rpc;

import java.io.IOException;
import java.util.*;

import com.rabbitmq.client.*;
import com.shopwiki.messaging.MessagingConnector;
import com.shopwiki.messaging.rpc.RpcServer.WorkerFactory;

/**
 * @owner rstewart
 */
public class BasicWorkerFactory implements WorkerFactory {

    private final Map<String, RequestHandler<?,?>> nameToHandler = new LinkedHashMap<String, RequestHandler<?,?>>();

    private final MessagingConnector connector;
    private final int numThreads;

    public BasicWorkerFactory(MessagingConnector connector, int numThreads) {
        this.connector = connector;
        this.numThreads = numThreads;
    }

    public void addHandler(String name, RequestHandler<?,?> handler) {
        nameToHandler.put(name, handler);
    }

    @Override
    public RpcWorkers createWorkers(String queuePrefix) throws IOException {
        Connection conn = connector.getConnection(numThreads);

        List<Channel> channels = new ArrayList<Channel>();
        for (int i = 0; i < numThreads; i++) {
            Channel channel = conn.createChannel();
            channel.basicQos(1);
            channels.add(channel);
        }

        RpcWorkers workers = new RpcWorkers(conn);

        for (String procedureName : nameToHandler.keySet()) {
            RequestHandler<?,?> handler = nameToHandler.get(procedureName);
            RpcWorker worker = new RpcWorker(handler, channels, queuePrefix, procedureName);
            workers.add(worker);
        }

        return workers;
    }
}

@@ -782,24 +782,152 @@
 er);%0A    %7D%0A%0A
+    public Map%3CString, RequestHandler%3C?,?%3E%3E getHandlerMap() %7B%0A        return Collections.unmodifiableMap(nameToHandler);%0A    %7D%0A%0A
     @Overrid

Add a getter for the Handlers Map in rpc/BasicWorkerFactory.java