Ejemplo n.º 1
0
ClientInterceptor::
ClientInterceptor (IOP::CodecFactory_var cf)
  : myname_ ("Client_Authentication_Interceptor")
{
  std::cout << "Calling ClientInterceptor constructor." << std::endl;

  // Set up a structure that contains information necessary to
  // create a GIOP 1.2 CDR encapsulation Codec.
  IOP::Encoding encoding;
  encoding.format = IOP::ENCODING_CDR_ENCAPS;
  encoding.major_version = 1;
  encoding.minor_version = 2;

  // Obtain the CDR encapsulation Codec.
  this->codec = cf->create_codec (encoding);
}
MonExec::MonExec()
{
// BEGIN USER INSERT SECTION MonExec::MonExec
	counter = 0;

	//codec

	int dummy = 0;
    CORBA::ORB_var orb = CORBA::ORB_init (dummy, 0);
	CORBA::Object_var obj = orb->resolve_initial_references ("CodecFactory");


	IOP::CodecFactory_var factory = IOP::CodecFactory::_narrow(obj);

    if ( CORBA::is_nil(factory) )
	{
		std::cout << "no CDR" << std::endl;
    	return;
	}

    /* 
	 * Create codec
	 */

    IOP::Encoding how;

    how.major_version = 1;
    how.minor_version = 0;
    how.format		  =	IOP::ENCODING_CDR_ENCAPS;

    try
    {
		m_cdrCodec = factory->create_codec(how);
    }
    catch(const IOP::CodecFactory::UnknownEncoding& _ex)
    {
		std::cout << "no CDR" << std::endl;
    }

// END USER INSERT SECTION MonExec::MonExec
}