2 #include "tao/IORInterceptor/IORInfo.h"
3 #include "tao/PortableServer/Root_POA.h"
5 #include "tao/PolicyC.h"
7 #include "tao/ORB_Constants.h"
9 #if !defined (__ACE_INLINE__)
10 # include "tao/IORInterceptor/IORInfo.inl"
11 #endif /* __ACE_INLINE__ */
13 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
15 TAO_IORInfo::TAO_IORInfo (TAO_Root_POA
*poa
)
17 components_established_ (false)
21 TAO_IORInfo::~TAO_IORInfo ()
26 TAO_IORInfo::get_effective_policy (CORBA::PolicyType type
)
28 this->check_validity ();
30 CORBA::Policy_var policy
=
31 this->poa_
->get_policy (type
);
33 if (!CORBA::is_nil (policy
.in ()))
35 return policy
._retn ();
38 // TODO: Now check the global ORB policies.
41 // No policy matching the given PolicyType was found.
42 throw ::CORBA::INV_POLICY (CORBA::OMGVMCID
| 3, CORBA::COMPLETED_NO
);
46 TAO_IORInfo::add_ior_component (const IOP::TaggedComponent
&component
)
48 this->check_validity ();
50 if (this->components_established_
)
51 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
53 // Add the given tagged component to all profiles.
54 this->poa_
->save_ior_component (component
);
58 TAO_IORInfo::add_ior_component_to_profile (
59 const IOP::TaggedComponent
&component
,
60 IOP::ProfileId profile_id
)
62 this->check_validity ();
64 if (this->components_established_
)
65 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
67 this->poa_
->save_ior_component_and_profile_id (component
, profile_id
);
71 TAO_IORInfo::manager_id ()
73 this->check_validity ();
75 PortableServer::POAManager_var poa_manager
= this->poa_
->the_POAManager ();
76 return poa_manager
->get_id ();
79 PortableInterceptor::AdapterState
82 this->check_validity ();
84 return this->poa_
->get_adapter_state ();
87 PortableInterceptor::ObjectReferenceTemplate
*
88 TAO_IORInfo::adapter_template ()
90 this->check_validity ();
92 // Return the Object Reference Template whenever an IOR Interceptor
93 // is invoked. Its value is the template created for the adapter
94 // policies and the IOR Interceptor calls to add_ior_component and
95 // add_ior_component_to_profile. It's a const value and its value
97 PortableInterceptor::ObjectReferenceTemplate
*adapter_template
=
98 this->poa_
->get_adapter_template ();
100 if (adapter_template
== 0)
102 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
105 return adapter_template
;
108 PortableInterceptor::ObjectReferenceFactory
*
109 TAO_IORInfo::current_factory ()
111 this->check_validity ();
113 // Return the current_factory that is used to create the object
114 // references by the adapter. Though initially, its value is the
115 // same as the adapter_template, unlike adapter_template, its value
116 // can be changed. The value of the current_factory can be changed
117 // only during the call to components_established method.
118 PortableInterceptor::ObjectReferenceFactory
*adapter_factory
=
119 this->poa_
->get_obj_ref_factory ();
121 if (adapter_factory
== 0)
123 throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID
| 14, CORBA::COMPLETED_NO
);
126 return adapter_factory
;
130 TAO_IORInfo::current_factory (
131 PortableInterceptor::ObjectReferenceFactory
* current_factory
)
133 this->check_validity ();
135 this->poa_
->set_obj_ref_factory (current_factory
);
139 TAO_IORInfo::check_validity ()
143 // Although not defined by the spec, duplicate the behavior used
144 // by the ORBInitInfo object once CORBA::ORB_init() has been
145 // called. Specifically, the IORInfo object is no longer valid
146 // once the POA has invoked all IORInterceptor interception
147 // points. This also prevents memory access violations from
148 // occuring if the POA is destroyed before this IORInfo object.
149 throw ::CORBA::OBJECT_NOT_EXIST (TAO::VMCID
, CORBA::COMPLETED_NO
);
153 TAO_END_VERSIONED_NAMESPACE_DECL