/////////////////////////////////////////////////////////////////////////
//
// © University of Southampton IT Innovation Centre, 2004
//
// Copyright in this library belongs to the IT Innovation Centre of
// 2 Venture Road, Chilworth Science Park, Southampton, SO16 7NP, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
//      Created by:             Darren Marvin
//      Created date:           2004/04/30
//      Created for project:    GEMSS
//
/////////////////////////////////////////////////////////////////////////
//
//      Dependencies: None
//
/////////////////////////////////////////////////////////////////////////
//
//      Last commit info:       $Author: $
//                              $Date: $
//                              $Revision: $
//
/////////////////////////////////////////////////////////////////////////

package uk.ac.soton.itinnovation.gemss.transportmessaging.messaging.codec.providers.soap;

import eu.gemss.components.transport.servicedescription.interfacetypes.*;
import java.util.logging.*;
import uk.ac.soton.itinnovation.gemss.signal.*;
import uk.ac.soton.itinnovation.gemss.transportmessaging.configuration.*;
import uk.ac.soton.itinnovation.gemss.transportmessaging.messaging.codec.*;

public class SOAPMessageCoDecProvider implements MessageCoDecProvider {

    private static Logger mLogger = Logger.getLogger("uk.ac.soton.itinnovation.gemss.transportmessaging.messaging.codec.providers.soap.SOAPMessageCoDecProvider");
    private static MessagingProviderConfiguration mConfiguration;
    private InterfaceTypeDescriptor[] mDescriptors = null;
    private SignalProcessor mSignalProcessor = null;

    public SOAPMessageCoDecProvider() {
        //create a list
            mDescriptors = new InterfaceTypeDescriptor[1];
            mDescriptors[0] = new WSDL11TypeDescriptor();
    }

    /**
     * Retrieve a list of all the generators supported by the provider
     * @return list of type descriptors
     */
    public InterfaceTypeDescriptor[] getSupportedInterfaceTypeList() {
        return mDescriptors;
    }

    /**
     * Retrieve an instance of the message generator described
     * by the type descriptor
     * @param typeDesc descriptor for required type of message generator
     * @return instance of the required message generator
     */
    public MessageCoDec getMessageCoDec(InterfaceTypeDescriptor typeDesc) throws MessageCoDecException {
        //check if required type matches the supported type
        if(!mDescriptors[0].isEqual(typeDesc)) {
            mLogger.log(Level.SEVERE,"Service interface type described as '" + typeDesc.getDescription() + "' is not supported by provider 'uk.ac.soton.itinnovation.gemss.transportmessaging.messaging.codec.providers.soap.SOAPMessageCoDecProvider'");
            throw new MessageCoDecException("Service interface type described as '" + typeDesc.getDescription() + "' is not supported by provider 'uk.ac.soton.itinnovation.gemss.transportmessaging.messaging.codec.providers.soap.SOAPMessageCoDecProvider'");
        }
        //create a SOAPMessageCoDec
        return new SOAPMessageCoDec();
    }

    /**
     * Sets the processor where provider signals should be sent
     * @param handler
     */
    public void setSignalProcessor(SignalProcessor handler) {
        mSignalProcessor = handler;
    }

    /**
     * Set the messaging provider configuration
     * @param configuration
     */
    public void setMessagingProviderConfiguration(MessagingProviderConfiguration configuration) {
        mConfiguration = configuration;
    }

}
