axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lilan...@apache.org
Subject cvs commit: xml-axis/contrib/Axis-C++/src/Handlers BasicHandler.hpp BasicHandler.cpp
Date Sun, 02 Feb 2003 09:00:19 GMT
lilantha    2003/02/02 01:00:19

  Added:       contrib/Axis-C++/src/Handlers BasicHandler.hpp
                        BasicHandler.cpp
  Log:
  Handlers
  
  Revision  Changes    Path
  1.1                  xml-axis/contrib/Axis-C++/src/Handlers/BasicHandler.hpp
  
  Index: BasicHandler.hpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #if !defined(_BASIC_HANDLER_HPP)
  #define _BASIC_HANDLER_HPP
  
  #include <list>
  #include <map>
  #include "Handler.hpp"
  
  class DOM_Element;
  class DOM_Document;
  class SOAPMsgContext;
  
  
  /** BasicHandler is a utility class which implements simple
   * property setting/getting behavior, and stubs out a lot of the Handler
   * methods.  Extend this class to make writing your Handlers easier, and
   * then override what you need to.
   */
  
  class BasicHandler : public Handler  
  {
  public:
  	BasicHandler();
  	virtual ~BasicHandler();
  
  
  	/**
       * Init is called when the chain containing this Handler object
       * is instantiated.
       */
  	virtual void Init()=0;
  
      /**
       * Cleanup is called when the chain containing this Handler object
       * is done processing the chain.
       */
  	virtual void Cleanup()=0;
  
      /**
       * Invoke is called to do the actual work of the Handler object.
       * If there is a fault during the processing of this method it is
       * invoke's job to catch the exception and undo any partial work
       * that has been completed.  Once we leave 'invoke' if a fault
       * is thrown, this classes 'onFault' method will be called.
       * Invoke should rethrow any exceptions it catches, wrapped in
       * an AxisFault.
       */
  	virtual void Invoke(SOAPMsgContext& p_msgContext) throw(AxisFault)=0;
  
      /**
       * Called when a subsequent handler throws a fault.
       */
  	virtual void OnFault(SOAPMsgContext& p_msgContext)=0;
  
      /**
       * Can this Handler process this QName?
       */
  	virtual bool CanHandleBlock(const ax::QName& p_qName){return false;}
  
      /**
       * Return a list of QNames which this Handler understands.  By returning
       * a particular QName here, we are committing to fulfilling any contracts
       * defined in the specification of the SOAP header with that QName.
       */
  	virtual std::list<ax::QName>* GetUnderstoodHeaders(){return NULL;}
  
      /**
       * Add the given option (name/value) to this handler's bag of options
       */
  	virtual void SetOption(const std::string& p_strName, void * p_pValue);
  
  	/**
  	 * Set a default value for the given option:
  	 */
  	virtual bool SetOptionDefault(const std::string& p_strName, void * p_pValue);
      
      /**
       * Returns the option corresponding to the 'name' given
       */
  	virtual void* GetOption(const std::string& p_strName);
      
      /**
       * Set the name (i.e. registry key) of this Handler
       */
  	virtual void SetName(const std::string& p_strName){m_strName=p_strName;}
      
      /**
       * Return the name (i.e. registry key) for this Handler
       */
  	virtual std::string GetName(){return m_strName;}
  
      /**
       * Return the entire list of options
       */
  	virtual const Map& GetOptions(){return m_Options;}
  
      /**
       * Sets a whole list of options
       */
  	virtual void SetOptions(const Map& p_Opts){m_Options=p_Opts;}
  
      /**
       * This will return the root element of an XML doc that describes the
       * deployment information about this handler.  This is NOT the WSDL,
       * this is all of the static internal data use by Axis - WSDL takes into
       * account run-time information (like which service we're talking about)
       * this is just the data that's stored in the registry.  Used by the
       * 'list' Admin function.
       */
  	virtual const DOM_Element GetDeploymentData(DOM_Document& p_domDoc);
  
      /**
       * Obtain WSDL information.  Some Handlers will implement this by
       * merely setting properties in the MessageContext, others (providers)
       * will take responsibility for doing the "real work" of generating
       * WSDL for a given service.
       *
       */
  	virtual void GenerateWSDL(SOAPMsgContext& p_msgContext) throw (AxisFault)=0;
  
  
  
  protected:
  	std::string m_strName;
  	Map			m_Options;
  
  
  
  };
  
  #endif // _BASIC_HANDLER_HPP
  
  
  
  1.1                  xml-axis/contrib/Axis-C++/src/Handlers/BasicHandler.cpp
  
  Index: BasicHandler.cpp
  ===================================================================
  /* -*- C++ -*- */
  
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. 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.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
   * ITS 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   *
   *
   * @author Lilantha Darshana (lilantha@virtusa.com)
   *
   */
  
  
  #include "Platform.hpp"
  #include "BasicHandler.hpp"
  #include <typeinfo>
  
  #include <xercesc/util/PlatformUtils.hpp>
  #include <xercesc/util/XMLString.hpp>
  #include <xercesc/util/XMLUniDefs.hpp>
  #include <xercesc/dom/DOM.hpp>
  #include <xercesc/framework/XMLFormatter.hpp>
  #include <xercesc/util/TranscodingException.hpp>
  
  
  
  BasicHandler::BasicHandler()
  {
  
  }
  
  BasicHandler::~BasicHandler()
  {
  
  }
  
  void BasicHandler::SetOption(const std::string& p_strName, void *p_pValue)
  {
  	if(p_pValue) m_Options[p_strName] = p_pValue;
  }
  
  bool BasicHandler::SetOptionDefault(const std::string& p_strName, void * p_pValue)
  {
  	if(m_Options.find(p_strName) != m_Options.end())
  	{
  		SetOption(p_strName, p_pValue);
  		return true;
  	}
  	return false;
  }
  
  void* BasicHandler::GetOption(const std::string& p_strName)
  {
  	Map::const_iterator itr;
  
  	if((itr = m_Options.find(p_strName)) != m_Options.end())
  		return itr->second;
  	return NULL;
  }
  
  const DOM_Element BasicHandler::GetDeploymentData(DOM_Document& p_domDoc)
  {
  	DOM_Element elmRoot = p_domDoc.createElementNS("", "handler");
  
  	elmRoot.setAttribute("class",typeid(*this).name());
  
  	for(Map::const_iterator itr=m_Options.begin();itr != m_Options.end();++itr)
  	{
  		DOM_Element tmpElm = p_domDoc.createElementNS("", "option" );
          tmpElm.setAttribute( "name", itr->first.c_str() );
          tmpElm.setAttribute( "value", ((std::string*)itr->second)->c_str() );
          elmRoot.appendChild( tmpElm );
  	}
  	return elmRoot;
  }
  
  
  
  

Mime
View raw message