/**
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -
 - JASS: Java Advanced tranSaction Support
 -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -
 - This module was originally developed by 
 -
 -    LSD (Distributed Systems Lab, http://lsd.ls.fi.upm.es/lsd/lsd.htm)
 -    at Universidad Politecnica de Madrid (UPM) as an ObjectWeb Consortium
 -    (http://www.objectweb.org) project.
 -
 -    This project has been partially funded by the European Commission under
 -    the IST programme of V FP grant IST-2001-37126 and by the Spanish
 -    Ministry of Science & Technology (MCyT) grants TIC2002-10376-E and
 -    TIC2001-1586-C03-02
 -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -  The original code and portions created by LSD are 
 -  Copyright (c) 2004 LSD (UPM)  
 -  All rights reserved.
 -  
 - Redistribution and use in source and binary forms, with or without 
 - modification, are permitted provided that the following conditions are met:
 -
 - -Redistributions of source code must retain the above copyright notice, this
 - list of conditions and the following disclaimer. 
 -
 - -Redistributions in binary form must reproduce the above copyright notice, 
 - this list of conditions and the following disclaimer in the documentation 
 - and/or other materials provided with the distribution. 
 -
 - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 - POSSIBILITY OF SUCH DAMAGE.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -
 -  Author: Francisco Perez Sorrosal (frperezs)
 -
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/

package org.objectweb.jass.hls.ont;

import javax.activity.coordination.ServiceManager;
import javax.activity.coordination.SignalSet;
import javax.activity.coordination.SubordinateSignalSet;
import javax.activity.coordination.RecoverableAction;
import javax.activity.*;
import javax.activity.propertygroup.PropertyGroupManager;
import java.io.Serializable;

/**
 * Implements the ONT service manager. An object of this class will be 
 * registered on the Activity Service instance by the ONT service 
 * implementation.
 * @author fran
 * Date: Feb 12, 2004
 * org.objectweb.jass.hls.ontONTServiceManager.java
 */
public class ONTServiceManager implements ServiceManager {

	public static String SERVICE_NAME = "javax.activity.opennested";

	private ServiceInformation serviceInfo;

	/**
	 * Constructor for the ONT service manager implementation. Sets the service
	 * information (only the service name).
	 */
	public ONTServiceManager() {
		serviceInfo =
			new ServiceInformation(SERVICE_NAME, null, (Serializable) null);
	}

	// ServiceManager implementation ----------------------------

	/**
	 * Retruns the ONT service information (it only has the service name).  
	 */
	public ServiceInformation getServiceInformation() {
		return serviceInfo;
	}

	/**
	 * Returns an instance of the unique signal set for the ONT service. If the
	 * required signal set is not valid, it throws the 
	 * SignalSetUnknownException.
	 */
	public SignalSet getSignalSet(String signalSetName)
		throws SignalSetUnknownException, NoImplementException {

		if (!signalSetName.equals(ONTCompletionSS.COMPLETION_SS_NAME))
			throw new SignalSetUnknownException();
		// We always return the unique SignalSet
		return new ONTCompletionSS();
	}

	/**
	 * Not necessary for ONT service.
	 */
	public SubordinateSignalSet getSubordinateSignalSet(String signalSetName)
		throws SignalSetUnknownException, NoImplementException {
		return null;
	}

	/**
	 * Not necessary for ONT service.
	 */
	public PropertyGroupManager getPropertyGroupManager(String propertyGroupName)
		throws PropertyGroupUnknownException {
		return null;
	}

	/**
	 * Not necessary for ONT service.
	 */
	public String[] getPropertyGroupNames() {
		return null;
	}

	/**
	 * Returns the name of the ONT completion signal set.
	 */
	public String getCompletionSignalSetName() {
		return ONTCompletionSS.COMPLETION_SS_NAME;
	}

	/**
	 * Not necessary for current ONT service implementation.
	 */
	public int getActivityType() {
		return 2;
	}

	/**
	 * Not yet implemented.
	 */
	public void activityImported(ServiceInformation serviceInfo) {
	}

	/**
	 * Not yet implemented.
	 */

	public SignalSet[] recoverSignalSets(GlobalId globalId)
		throws ActivityCompletedException, SystemException {
		return null;
	}

	/**
	 * Not yet implemented.
	 */
	public RecoverableAction[] recoverActions(
		GlobalId globalId,
		String signalSetName)
		throws SignalSetUnknownException, ActivityCompletedException, SystemException {
		return new RecoverableAction[0];
	}

}
