Exemplo n.º 1
0
void
IORInterceptor::establish_components (
    PortableInterceptor::IORInfo_ptr info)
{
  try
    {
      PortableInterceptor::ObjectReferenceTemplate_var t =
        info->adapter_template ();

      PortableInterceptor::AdapterName_var a =
        t->adapter_name ();

      // Only execute if POA is not RootPOA.  The RootPOA will not
      // have our custom policy, but the child POA we created will.
      if (a->length () > 1)
        {
          CORBA::Policy_var policy (
            info->get_effective_policy (Test::POLICY_TYPE));

          Test::Policy_var test_policy (Test::Policy::_narrow (
            policy.in ()));

          this->success_ = true;
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "EXCEPTION: ""IORInterceptor::establish_components:");

      ACE_ASSERT (false);
    }
}
Exemplo n.º 2
0
void
TAO_LB_IORInterceptor::components_established (
    PortableInterceptor::IORInfo_ptr info)
{
  int argc = 0;
  ACE_TCHAR **argv= 0;
  CORBA::ORB_var orb = CORBA::ORB_init (argc,
                                        argv,
                                        this->orb_id_.in ());

  // Save a copy of the current ObjectReferenceFactory.
  PortableInterceptor::ObjectReferenceFactory_var old_orf =
    info->current_factory ();

  PortableInterceptor::ObjectReferenceFactory * tmp;
  ACE_NEW_THROW_EX (tmp,
                    TAO_LB_ObjectReferenceFactory (old_orf.in (),
                                                   this->object_groups_,
                                                   this->repository_ids_,
                                                   this->location_.in (),
                                                   orb.in (),
                                                   this->lm_.in ()),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  PortableInterceptor::ObjectReferenceFactory_var orf = tmp;

  info->current_factory (orf.in ());
}
Exemplo n.º 3
0
void
FOO_IORInterceptor::components_established (
    PortableInterceptor::IORInfo_ptr info)
{
  // Construct a dummy tagged component.
  IOP::TaggedComponent component;

  component.tag = 0;
  component.component_data.length (1);


  try
    {
      // Add the tagged component to all profiles.
      //
      // This call should fail since it shouldn't be possible to add
      // an IOR component after establish_components() has been
      // called.
      info->add_ior_component (component);

      // The above call should NOT have succeeded.
      throw CORBA::INTERNAL ();
    }
  catch (const CORBA::BAD_INV_ORDER& ex)
    {
      if (ex.minor () != (CORBA::OMGVMCID | 14))
        {
          ex._tao_print_exception ("Unexpected exception");

          throw;
        }
    }

  try
    {
      // Add the tagged component to all profiles.
      //
      // This call should fail since it shouldn't be possible to add
      // an IOR component after establish_components() has been
      // called.
      info->add_ior_component_to_profile (component,
                                          IOP::TAG_INTERNET_IOP);

      // The above call should NOT have succeeded.
      throw CORBA::INTERNAL ();
    }
  catch (const CORBA::BAD_INV_ORDER& ex)
    {
      if (ex.minor () != (CORBA::OMGVMCID | 14))
        {
          ex._tao_print_exception ("Unexpected exception");

          throw;
        }
    }
}
Exemplo n.º 4
0
void
ServerIORInterceptor::establish_components (
                                            PortableInterceptor::IORInfo_ptr info)
{
  const char * permission = "ServerRequiresAuth";

  // arbitrary tag.
  CORBA::ULong tagID = 9654;

  IOP::TaggedComponent myTag;

  myTag.tag = tagID;
  const CORBA::ULong len =
    static_cast<CORBA::ULong> (ACE_OS::strlen (permission));
  myTag.component_data.length (len + 1);

  CORBA::Octet *buf = myTag.component_data.get_buffer();

  ACE_OS::memcpy (buf, permission, len + 1);

  // add tagged component
  info->add_ior_component (myTag);

  std::cout << "Created Tagged IOR." << std::endl;
}
Exemplo n.º 5
0
void
FOO_IORInterceptor::establish_components (
    PortableInterceptor::IORInfo_ptr info)
{
  // According to the Portable Interceptors specification,
  // IORInterceptor::establish_components() must not throw an
  // exception.  We check for exceptions despite this fact.  The ORB
  // does the right thing, and ignores any IOR interceptors that throw
  // an exception.

  CORBA::String_var name = this->name ();

  CORBA::Any data;
  data <<= name.in ();

  CORBA::OctetSeq_var encoded_data =
    this->codec_->encode_value (data);

  // Construct a tagged component.
  IOP::TaggedComponent component;

  component.tag = FOO::COMPONENT_ID;

  const CORBA::ULong maximum   = encoded_data->maximum ();
  const CORBA::ULong length    = encoded_data->length ();
  CORBA::Octet * buffer  = encoded_data->get_buffer ();
  const CORBA::Boolean release = 0;  // OctetSeq retains ownership.

  ACE_ASSERT (maximum > 1);  // Sanity check.
  ACE_ASSERT (length > 1);   // Sanity check.

  component.component_data.replace (maximum, length, buffer, release);

  ACE_ASSERT (component.component_data.length () == length);

  // Add the tagged component to all profiles.
  info->add_ior_component (component);

  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) Added tagged component containing the\n"
              "(%P|%t)   string \"%C\" to all profiles.\n",
              name.in ()));


  // Add the tagged component to all IIOP profiles.
  info->add_ior_component_to_profile (component,
                                      IOP::TAG_INTERNET_IOP);

  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) Added tagged component containing the\n"
              "(%P|%t)   string \"%C\" to all IIOP profiles.\n",
              name.in ()));


  try
    {
      // Verify that policy retrieval internals work, and do not cause
      // memory access violations.
      CORBA::Policy_var policy =
        info->get_effective_policy (PortableServer::LIFESPAN_POLICY_ID);

      ACE_DEBUG ((LM_DEBUG,
                  "(%P|%t) Successfully retrieved effective policy.\n"));
    }
  catch (const CORBA::INV_POLICY& ex)
    {
      if (ex.minor () != (CORBA::OMGVMCID | 3))
        throw;
    }
}