You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2004/12/06 11:45:37 UTC

cvs commit: ws-axis/c/src/transport/axis2 ChannelFactory.cpp ChannelFactory.hpp

damitha     2004/12/06 02:45:37

  Added:       c/src/transport/axis2 ChannelFactory.cpp ChannelFactory.hpp
  Log:
  Sorry forgot to put those files in my  earlier commit
  
  Revision  Changes    Path
  1.1                  ws-axis/c/src/transport/axis2/ChannelFactory.cpp
  
  Index: ChannelFactory.cpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /**
   * This class 
   *
   * @author Susantha Kumara (skumara@virtusa.com, susantha@opensource.lk)
   * @author damitha kumarage (damitha@hsenid.lk, damitha@opensource.lk)
   *
   */
  
  #include "../../platforms/PlatformAutoSense.hpp"
  
  #include "ChannelFactory.hpp"
  //#include "../SSLChannel.hpp"
  #include <stdio.h>
  #include "AxisTransportException.h"
  //#include "../../common/AxisTrace.h"
                                                                                                                               
  //extern AXIS_CPP_NAMESPACE_PREFIX AxisTrace* g_pAT;
  //extern AXIS_CPP_NAMESPACE_PREFIX AxisConfig* g_pConfig;
  
  AXIS_CPP_NAMESPACE_START
  
  const char* ChannelFactory::m_pcLibraryName = 0;
  DLHandler ChannelFactory::m_LibHandler = 0;
  CREATE_OBJECT3 ChannelFactory::m_Create = 0;
  DELETE_OBJECT3 ChannelFactory::m_Delete = 0;
  
  ChannelFactory::ChannelFactory()
  {
  	m_LibHandler = 0;
  }
  
  ChannelFactory::~ChannelFactory()
  {
  
  }
  
  int ChannelFactory::initialize(const char* pcLibraryName)
  {
      //m_pcLibraryName = g_pConfig->getAxisConfProperty(AXCONF_SSLCHANNEL);
        m_pcLibraryName = pcLibraryName;
  
  	if (!loadLib())
  	{
          m_Create = (CREATE_OBJECT3) PLATFORM_GETPROCADDR(m_LibHandler, CREATE_FUNCTION3);
          m_Delete = (DELETE_OBJECT3) PLATFORM_GETPROCADDR(m_LibHandler, DELETE_FUNCTION3);
          if (!m_Create || !m_Delete)
          {
              unloadLib();
              char *s = new char[strlen(m_pcLibraryName)+1];
              strcpy(s,m_pcLibraryName);
              throw AxisTransportException(SERVER_TRANSPORT_LOADING_SSLCHANNEL_FAILED, s);
          }
  	}
  	else
  	{
          char *s = new char[strlen(m_pcLibraryName)+1];
          strcpy(s,m_pcLibraryName);
          throw AxisTransportException(SERVER_TRANSPORT_LOADING_SSLCHANNEL_FAILED, s);
  	}
     return AXIS_SUCCESS;
  }
  
  int ChannelFactory::uninitialize()
  {
  	return unloadLib();
  }
  
  /**
   * Should create an instance of Secure Channel
   */
  SecureChannel* ChannelFactory::getSecureChannelObject()
  {
  	SecureChannel* pSecure = 0;
  	if (m_Create) m_Create(&pSecure);
  	return pSecure;
  }
  
  void ChannelFactory::destroySecureChannelObject(SecureChannel* pObject)
  {
  	m_Delete(pObject);
  }
  
  int ChannelFactory::loadLib()
  {
      m_LibHandler = PLATFORM_LOADLIB(m_pcLibraryName);
      if (!m_LibHandler)
      {
          throw AxisTransportException(SERVER_TRANSPORT_LOADING_SSLCHANNEL_FAILED);
      }
  
      return AXIS_SUCCESS;
  }
  
  int ChannelFactory::unloadLib()
  {
      PLATFORM_UNLOADLIB(m_LibHandler);
  
      return AXIS_SUCCESS;
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/transport/axis2/ChannelFactory.hpp
  
  Index: ChannelFactory.hpp
  ===================================================================
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   */
  
  /**
   * This class 
   *
   * @author Susantha Kumara (skumara@virtusa.com, susantha@opensource.lk)
   * @author damitha kumarage (damitha@hsenid.lk, damitha@opensource.lk)
   *
   */
  
  
  #if !defined(AXIS_CHANNELFACTORY_H__OF_AXIS_INCLUDED_)
  #define AXIS_CHANNELFACTORY_H__OF_AXIS_INCLUDED_
  
  #include "../../platforms/PlatformAutoSense.hpp"
  
  #include <axis/GDefine.hpp>
  //#include "../SSLChannel.hpp"
  #include "SecureChannel.hpp"
  
  #define CREATE_FUNCTION3 "CreateInstance"
  #define DELETE_FUNCTION3 "DestroyInstance"
  
  typedef int (* CREATE_OBJECT3) (SecureChannel** inst);
  typedef int (* DELETE_OBJECT3) (SecureChannel* inst);
  AXIS_CPP_NAMESPACE_START
  class ChannelFactory  
  {
  public:
  	ChannelFactory();
  	virtual ~ChannelFactory();
  	/**
       * Used to initialize the global object. Following tasks are done
       * 1. Get the parser library name from the configuration file.
       * 2. Load that dynamic parser library.
       * 3. Get the function pointers of the exported functions
       * 4. Get any other information about the library.
       */
  	static int initialize(const char* pcLibraryName);
  	/** 
  	 * Used to uninitialize the global object.
  	 * 1. Unloads dynamic parser library.
  	 */
  	static int uninitialize();
  	/**
  	 * Used to create a parser object 
  	 */
  	static SecureChannel* getSecureChannelObject();
  	/**
  	 * Destroys the parser object 
  	 */
  	static void destroySecureChannelObject(SecureChannel* pObject);
  
  	static int loadLib();
  	static int unloadLib();
  
  private:
  	static const char* m_pcLibraryName;
  	static DLHandler m_LibHandler;
      static CREATE_OBJECT3 m_Create;
      static DELETE_OBJECT3 m_Delete;
  
  };
  AXIS_CPP_NAMESPACE_END
  #endif