Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / RTScheduling / RTScheduler_Initializer.cpp
blob81e1b7ae75a95dc52527a148038ded0c014857bd
1 // -*- C++ -*-
2 #include "tao/RTScheduling/RTScheduler_Initializer.h"
3 #include "tao/RTScheduling/Request_Interceptor.h"
5 #include "tao/RTScheduling/RTScheduler.h"
6 #include "tao/RTScheduling/Current.h"
7 #include "tao/RTScheduling/RTScheduler_Manager.h"
9 #include "tao/PI_Server/PI_Server.h"
11 #include "tao/PI/ORBInitInfo.h"
13 #include "tao/Exception.h"
14 #include "tao/ORB_Core.h"
15 #include "tao/debug.h"
16 #include "ace/Service_Repository.h"
17 #include "ace/Svc_Conf.h"
19 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
21 void
22 TAO_RTScheduler_ORB_Initializer::pre_init (
23 PortableInterceptor::ORBInitInfo_ptr info)
26 // Register all of the RT related services.
29 // Create the RT_Current.
31 // Narrow to a TAO_ORBInitInfo object to get access to the
32 // orb_core() TAO extension.
34 if (TAO_debug_level > 0)
35 TAOLIB_DEBUG ((LM_DEBUG,
36 "In pre_init\n"));
38 TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
40 if (CORBA::is_nil (tao_info.in ()))
42 if (TAO_debug_level > 0)
43 TAOLIB_ERROR ((LM_ERROR,
44 "(%P|%t) Security_ORBInitializer::pre_init:\n"
45 "(%P|%t) Unable to narrow "
46 "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
47 "(%P|%t) \"TAO_ORBInitInfo *.\"\n"));
49 throw ::CORBA::INTERNAL ();
52 TAO_RTScheduler_Current *tmp_current = 0;
53 ACE_NEW_THROW_EX (tmp_current,
54 TAO_RTScheduler_Current,
55 CORBA::NO_MEMORY (
56 CORBA::SystemException::_tao_minor_code (
57 TAO::VMCID,
58 ENOMEM),
59 CORBA::COMPLETED_NO));
60 this->current_ = tmp_current;
62 this->current_->init (tao_info->orb_core ());
64 CORBA::Object_var current_obj =
65 RTScheduling::Current::_narrow (this->current_.in ());
67 info->register_initial_reference ("RTScheduler_Current", current_obj.in ());
69 Client_Interceptor *client_interceptor = 0;
70 ACE_NEW_THROW_EX (client_interceptor,
71 Client_Interceptor,
72 CORBA::NO_MEMORY (
73 CORBA::SystemException::_tao_minor_code (
74 TAO::VMCID,
75 ENOMEM),
76 CORBA::COMPLETED_NO));
78 PortableInterceptor::ClientRequestInterceptor_var safe_client =
79 client_interceptor;
81 info->add_client_request_interceptor (client_interceptor);
83 Server_Interceptor *server_interceptor = 0;
84 ACE_NEW_THROW_EX (server_interceptor,
85 Server_Interceptor (this->current_.in ()),
86 CORBA::NO_MEMORY (
87 CORBA::SystemException::_tao_minor_code (
88 TAO::VMCID,
89 ENOMEM),
90 CORBA::COMPLETED_NO));
92 PortableInterceptor::ServerRequestInterceptor_var safe_server =
93 server_interceptor;
95 info->add_server_request_interceptor (server_interceptor);
97 // Set the RTScheduler_Manager
98 TAO_RTScheduler_Manager *manager = 0;
100 ACE_NEW_THROW_EX (manager,
101 TAO_RTScheduler_Manager (tao_info->orb_core ()),
102 CORBA::NO_MEMORY (
103 CORBA::SystemException::_tao_minor_code (
104 TAO::VMCID,
105 ENOMEM),
106 CORBA::COMPLETED_NO));
109 TAO_RTScheduler_Manager_var safe_manager = manager;
111 info->register_initial_reference ("RTSchedulerManager", manager);
114 void
115 TAO_RTScheduler_ORB_Initializer::post_init (PortableInterceptor::ORBInitInfo_ptr info)
117 // @@ This is busted. TAO_ORBInitInfo should do proper reference
118 // counting.
119 // Narrow to a TAO_ORBInitInfo object to get access to the
120 // orb_core() TAO extension.
121 //TAO_ORBInitInfo_var tao_info = TAO_ORBInitInfo::_narrow (info);
123 if (TAO_debug_level > 0)
124 TAOLIB_DEBUG ((LM_DEBUG,
125 "In post_init\n"));
127 CORBA::Object_var rt_current_obj =
128 info->resolve_initial_references (TAO_OBJID_RTCURRENT);
130 RTCORBA::Current_var rt_current =
131 RTCORBA::Current::_narrow (rt_current_obj.in ());
133 if (CORBA::is_nil (rt_current.in ()))
135 TAOLIB_DEBUG ((LM_DEBUG,
136 "(%P|%t) ::post_init\n"
137 "(%P|%t) Unable to narrow to RTCORBA::Current\n"));
138 throw ::CORBA::INTERNAL ();
141 this->current_->rt_current (rt_current.in ());
144 TAO_END_VERSIONED_NAMESPACE_DECL