// ExtendedServiceLocator.java
//
// Created: February 2006
//
// This file is a component of the BioMoby project.
// Copyright Martin Senger (martin.senger@gmail.com).
//

package org.biomoby.client;

import org.biomoby.shared.MobyService;

/**
 * An extended container allowing to store information how to call a
 * biomoby service using non-biomoby protocols. A typical example
 * (often used for testing a new service even before it is deployed)
 * is to call locally a Java class that implements a Biomoby service
 * by dynamically loading the class into the same JVM (and not using
 * Biomoby-native SOAP protocol). <p>
 *
 * Note that the structure of input data, however, remains still
 * Biomoby compliant. <p>
 *
 * @author <A HREF="mailto:martin.senger@gmail.com">Martin Senger</A>
 * @version $Id: ExtendedServiceLocator.java,v 1.3 2008/03/03 11:34:17 senger Exp $
 */

public class ExtendedServiceLocator
    extends MobyServiceLocator {

//    private static org.apache.commons.logging.Log log =
//       org.apache.commons.logging.LogFactory.getLog (ExtendedServiceLocator.class);

    String localClassName;
    boolean loop = false;

    /**************************************************************************
     * Default constructor.
     *************************************************************************/
    public ExtendedServiceLocator() {
	super();
    }

    /**************************************************************************
     * Another constructor, seeting also a service.
     *************************************************************************/
    public ExtendedServiceLocator (MobyService service) {
	super (service);
    }

    /**************************************************************************
     * Set name of a local class that represents (implements) a
     * service. <p>
     *
     * If this class represent a Biomoby service (a usual case) then
     * the class should have a method that accepts a String and
     * produces a String (both strings complying with the Biomoby
     * data), and that has the same name as a Biomoby service that it
     * represents. <p>
     *
     * @param localClassName a class that will be called instead of a
     * SOAP-based remote Biomoby service
     *************************************************************************/
    public void setLocalClass (String localClassName) {
	this.localClassName = localClassName;
    }
    
    /**************************************************************************
     * Get a name of a local class that represents (implements) a
     * service. <p>
     *
     * @return a class name that will be called instead of a
     * SOAP-based remote Biomoby service
     *************************************************************************/
    public String getLocalClass() {
	return localClassName;
    }
    
    /**************************************************************************
     * Setting 'enabled' to true indicates that no method should be
     * call, at all. Just the same input is turned back as
     * output. This is mainly for testing purposes to see input
     * data. <p>
     *
     * @param enabled true will instruct not to call any service;
     * default is false
     *************************************************************************/
    public void setLoop (boolean enabled) {
	loop = enabled;
    }
    
    /**************************************************************************
     * Get back what can be set by {@link #setLoop}. <p>
     *************************************************************************/
    public boolean isLoop() {
	return loop;
    }
}
