/*
 * $Id: SequentialBindingAlgorithm.java,v 1.3 2006/01/27 16:39:04 rampil Exp $
 * Copyright (c) 2005 LOGICAL-PARADOX.ORG
 */
package org.logical_paradox.rss.dsr.algorithm;

import org.logical_paradox.rss.dsr.ServiceList;

/**
 * SequentialBindingAlgorithm
 * 順番割り当てを行なうアルゴリズム
 * @author satoshi akabane@logical-paradox.org
 * @version $Revision: 1.3 $
 */
public class SequentialBindingAlgorithm extends ServiceBindingAlgorithm {
	/** サービス割り当てカウント */
	protected int serviceBindingCnt = 0;

	/**
	 * コンストラクタ
	 */
	public SequentialBindingAlgorithm() {
	}

	/**
	 * サービスを選択して，サービス名を返す
	 * @param services サービスリスト
	 * @return 選択されたサービスのノードID
	 */
	@Override
	public synchronized String getService(ServiceList services) {
		String[] serviceNames = services.serviceNames();
		if(serviceBindingCnt >= serviceNames.length) {
			serviceBindingCnt = 0;
		}
		String serviceName = serviceNames[serviceBindingCnt++];

		return serviceName;
	}
}

// end of SequentialBindingAlgorithm.java
