

package net.jxta.resolver;

import net.jxta.protocol.ResolverQueryMsg;
import net.jxta.protocol.ResolverResponseMsg;

/**
 * Services that wish to act as a resolver handler must implement this interface
 *
 * @see net.jxta.resolver.ResolverService
 * @see net.jxta.protocol.ResolverQueryMsg
 * @see net.jxta.protocol.ResolverResponseMsg
 **/
public interface QueryHandler {

    /**
     * Process the resolver query, and generate response
     * it is the responsibility of the handler to send the response
     *
     * <p/><pre>
     * result = processIncomingQuery(query);
     * if (result != null) {
     *   resolver.sendResponse(query.getSrc(), response);
     *   return ResolverService.OK;
     *  } else return ResolverService.Repropagate;
     * </pre>
     *
     * @param query ResolverQueryMsg query
     * @return int status, {@link net.jxta.resolver.ResolverService#OK OK} 
     * success, {@link net.jxta.resolver.ResolverService#Repropagate Repropagate}
     * to indicate a re-propagation is needed.
     */

    public int processQuery(ResolverQueryMsg query);

    /**
     * Called when messages are received by the ResolverService
     * it calls back this method to deal with received responses
     *
     * @param response ResolverQueryMsg response
     **/
    public void processResponse(ResolverResponseMsg response); 
}
