diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-06 10:18:42 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-06 10:18:42 +0000 |
commit | 0eba5bcfd80728d74c5bc9c0c7c99c86983f58dd (patch) | |
tree | fbe2bd13cb702c9fc7d9efe5ccfda57b4690d3ea /TAO | |
parent | 3ba06db921b12860cd7865fa695e9a5ca47314ed (diff) | |
download | ATCD-0eba5bcfd80728d74c5bc9c0c7c99c86983f58dd.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
48 files changed, 4595 insertions, 2333 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index 02e8eba8c0c..94afd67a47f 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,90 @@ +Tue Apr 06 05:04:51 1999 Irfan Pyarali <irfan@cs.wustl.edu> + + * tao/POA.cpp: Phase two of the new POA design is complete. + + - We now have support for active demuxing of POA. For transient + POAs, we directly use an active demuxing key in the object key + since transient POAs cannot be reactivated. For persistent + POAs, we have added a active demux hint field in the object + key. This hint is in addition to the persistent POA name. + + - The use of the active demux hint for the POA name in the + object key is optional. If used, the lookups are faster + (unless the hint is invalidated by a deactivation or by + restarting a persistent POA). However, using the hint results + in a larger IOR, and more memory being used in the active + object map. This option can be controlled through the + -ORBactivehintinpoanames runtime switch and is turned on by + default. + + - The POA related classes have been rewritten with respect to + exceptions. Memory management in case of exceptions from + servants and in case of dynamic memory / constructor failures + have been greatly improved through the use of auto pointer and + the new ACE_NEW_THROW_EX macro. One of the problems related + to exceptions was that the POA Current was not reset properly. + This has also been fixed. + + - New file Object_Adapter contains an abstraction for all the + POAs in the ORB. This class is used to hold the Object + Adapter lock and the tables for the POAs in the ORB. The + point of contact for dispatching requests and finding servants + has changed from the RootPOA to the Object Adapter. The file + also contains classes to iterate through a folded POA name. + + - New file Key_Adapters contains the common classes used by the + Object_Adapter class and the Active_Object_Map class. These + common classes are usually used for similar maps such as the + ACE_Active_Map_Manager_Adapter and + ACE_Hash_Map_Manager_Ex_Adapter. + + - POA name separator was changed from '/' to '\0'. Since POA + names are strings, this makes a better choice since there is + no chance of a conflict with the string specified by the + user. + + - The POA name separator change also led to the removal of the + TAO specific extension which allowed users to specify a nested + POA name in find_POA() and create_POA(). The + Explicit_Activation, FindPOA, and NewPOA examples were changed + not to use the above TAO extention. + + - Fixed RootPOA example to remove extra exception code left + there by Bala. + + - Collocation table now maps addresses to Object Adapters + instead to the Root POAs. + + - POA objects and POA Manager objects now contain a reference to + lock rather than a lock instance. The locks coming from the + Object Adapter. This change was made to centralize the + locking and reduce the number of locks grabbed during request + dispatching. + + * tao/Active_Object_Map.cpp: + + - Fixed the calculation of <system_id_size>. + + - Removed a memory leak by iterating over the entries left in + the user id map and deleting the dynamically allocated + <Map_Entry>s. + + - Made sure that the user can specify the map sizes if desired. + + * tao/Connect.cpp (handle_message): Reduced the number of calls + made to access the object_key and its buffer. + + * tao/Object_KeyC.h: Added operator!= for Object Keys. + + * tao/poa_macros.h (TAO_POA_GUARD_RETURN and TAO_POA_GUARD): Added + new macros. + + * examples/POA/Adapter_Activator/: Added new example to test the + dynamic creation of POAs when dispatching requests. The + original POAs are deleted once the object references have been + created. After this, an adapter activator is install in the + RootPOA to reactivate the POAs on demand. + Tue Apr 6 02:40:31 1999 Nanbor Wang <nanbor@cs.wustl.edu> * examples/Simple/Simple_util.cpp (init): We have to make sure we diff --git a/TAO/docs/Options.html b/TAO/docs/Options.html index b8e544743e6..4ab81f5cd6a 100644 --- a/TAO/docs/Options.html +++ b/TAO/docs/Options.html @@ -264,6 +264,7 @@ copied instead of appended to the CDR stream.</TD></TR> <H3><CODE>TAO_Default_Server_Strategy_Factory</CODE><A NAME="DefaultServer"></A></H3> <p><em>Note:</em> <code>-ORBdemuxstrategy</code> flag has been changed to <code>-ORBsystemidpolicydemuxstrategy</code> and <code>-ORBuseridpolicydemuxstrategy</code>. +<p><em>Note:</em> <code>-ORBtablesize</code> flag has been changed to <code>-ORBactiveobjectmapsize</code>. <blockquote> <P><TABLE BORDER="2" CELLSPACING="2" CELLPADDING="0" > @@ -271,37 +272,37 @@ copied instead of appended to the CDR stream.</TD></TR> <TH>Option</TH> <TH>Description</TH></TR> <TR> -<TD><CODE>-ORBconcurrency</CODE> <EM>which</EM></TD> -<TD>Specify which concurrency strategy to use. Range of values is <code>reactive</code> + +<TD><CODE>-ORBconcurrency</CODE> <EM>which</EM></TD> <TD>Specify which +concurrency strategy to use. Range of values is <code>reactive</code> for a purely Reactor-driven concurrency strategy or -<code>thread-per-connection</code> for creating a new thread to service each connection.</TD></TR> -<TR> -<TD><CODE>-ORBtablesize</CODE> <EM>object table size</EM></TD> -<TD>Specify the size of the object table. If not specified, the default value -is 64.</TD></TR> -<TR> +<code>thread-per-connection</code> for creating a new thread to +service each connection.</TD></TR> <TR> + +<TD><CODE>-ORBactiveobjectmapsize</CODE> <EM>active object map +size</EM></TD> <TD>Specify the size of the active object map. If not +specified, the default value is 64.</TD></TR> <TR> <TD><CODE>-ORBuseridpolicydemuxstrategy</CODE> <EM>user id policy based demultiplexing strategy</EM></TD> <TD>Specify the demultiplexing lookup strategy to be used with the user id policy. The -<EM>demultiplexing strategy</EM> can be one of <CODE>dynamic</CODE>, -<CODE>linear</CODE>, or <CODE>user</CODE>. This option defaults to -use the <CODE>dynamic</CODE> strategy. </TD></TR> <TR> +<EM>demultiplexing strategy</EM> can be one of <CODE>dynamic</CODE> or +<CODE>linear</CODE>. This option defaults to use the +<CODE>dynamic</CODE> strategy. </TD></TR> <TR> <TD><CODE>-ORBsystemidpolicydemuxstrategy</CODE> <EM>system id policy based demultiplexing strategy</EM></TD> <TD>Specify the demultiplexing lookup strategy to be used with the system id policy. The <EM>demultiplexing strategy</EM> can be one of <CODE>dynamic</CODE>, -<CODE>linear</CODE>, <CODE>active</CODE>, or <CODE>user</CODE>. This -option defaults to use the <CODE>active</CODE> strategy. </TD></TR> -<TR> +<CODE>linear</CODE>, or <CODE>active</CODE>. This option defaults to +use the <CODE>active</CODE> strategy. </TD></TR> <TR> <TD><CODE>-ORBuniqueidpolicyreversedemuxstrategy</CODE> <EM>unique id policy based reverse demultiplexing strategy</EM></TD> <TD>Specify the reverse demultiplexing lookup strategy to be used with the unique id policy. The <EM>reverse demultiplexing strategy</EM> can be one of -<CODE>dynamic</CODE> or <CODE>user</CODE>. This option defaults to use -the <CODE>dynamic</CODE> strategy. </TD></TR> <TR> +<CODE>dynamic</CODE> or <CODE>linear</CODE>. This option defaults to +use the <CODE>dynamic</CODE> strategy. </TD></TR> <TR> <TD><CODE>-ORBallowreactivationofsystemids</CODE> <EM>allows reactivation of system ids</EM></TD> <TD>Specify whether system ids @@ -323,6 +324,33 @@ to larger IORs. Note that this option is disregarded or <CODE>1</CODE>. This option defaults to <CODE>1</CODE>. </TD></TR> <TR> +<TD><CODE>-ORBpoamapsize</CODE> <EM>poa map size</EM></TD> <TD>Specify +the size of the poa map. If not specified, the default value is +24.</TD></TR> <TR> + +<TD><CODE>-ORBpersiententidpolicydemuxstrategy</CODE> <EM>persistent +id policy based demultiplexing strategy</EM></TD> <TD>Specify the +demultiplexing lookup strategy to be used with the persistent id +policy. The <EM>demultiplexing strategy</EM> can be one of +<CODE>dynamic</CODE> or <CODE>linear</CODE>. This option defaults to +use the <CODE>dynamic</CODE> strategy. </TD></TR> <TR> + +<TD><CODE>-ORBtransientidpolicydemuxstrategy</CODE> <EM>transient id +policy based demultiplexing strategy</EM></TD> <TD>Specify the +demultiplexing lookup strategy to be used with the transient id +policy. The <EM>demultiplexing strategy</EM> can be one of +<CODE>dynamic</CODE>, <CODE>linear</CODE>, or +<CODE>active</CODE>. This option defaults to use the +<CODE>active</CODE> strategy. </TD></TR> <TR> + +<TD><CODE>-ORBactivehintinpoanames</CODE> <EM>adds an active hint in +poa names</EM></TD> <TD>Specify whether an active hint should be added +to poa names. With active hints, poa names can be found quickly. +However, they lead to larger IORs. The +<EM>-ORBactivehintinpoanames</EM> can be <CODE>0</CODE> or +<CODE>1</CODE>. This option defaults to <CODE>1</CODE>. </TD></TR> +<TR> + <TD><CODE>-ORBthreadflags</CODE> <EM>thread flags</EM></TD> <TD>Specify the flags used for thread creation. Flags can be any logical-OR combination of <CODE>THR_DETACHED</CODE>, diff --git a/TAO/examples/POA/Adapter_Activator/Adaptor_Activator.dsw b/TAO/examples/POA/Adapter_Activator/Adaptor_Activator.dsw new file mode 100644 index 00000000000..f121fae15c3 --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/Adaptor_Activator.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "server"=.\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/examples/POA/Adapter_Activator/Makefile b/TAO/examples/POA/Adapter_Activator/Makefile new file mode 100644 index 00000000000..a8290a286a3 --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/Makefile @@ -0,0 +1,310 @@ +# +# $Id$ +# + +BIN = server + +LSRC = $(addsuffix .cpp,$(BIN)) + +CPPFLAGS += -I$(TAO_ROOT) -I../Generic_Servant + +LDLIBS = -lGeneric_Servant -lTAO +LDFLAGS += -L$(TAO_ROOT)/tao -L../Generic_Servant + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VBIN) + +INSTALL = + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU + +ifndef TAO_ROOT +TAO_ROOT = $(ACE_ROOT)/TAO +endif + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +.obj/server.o .obj/server.so .shobj/server.o .shobj/server.so: server.cpp \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/Get_Opt.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i \ + $(ACE_ROOT)/ace/Get_Opt.i \ + $(TAO_ROOT)/tao/Timeprobe.h \ + $(ACE_ROOT)/ace/Timeprobe.h \ + ../Generic_Servant/MyFooServant.h ../Generic_Servant/FooS.h \ + ../Generic_Servant/FooC.h \ + $(TAO_ROOT)/tao/corba.h \ + $(TAO_ROOT)/tao/corbafwd.h \ + $(ACE_ROOT)/ace/CDR_Stream.h \ + $(ACE_ROOT)/ace/Message_Block.h \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Message_Block.i \ + $(ACE_ROOT)/ace/Message_Block_T.h \ + $(ACE_ROOT)/ace/Message_Block_T.i \ + $(ACE_ROOT)/ace/Message_Block_T.cpp \ + $(ACE_ROOT)/ace/CDR_Stream.i \ + $(TAO_ROOT)/tao/try_macros.h \ + $(TAO_ROOT)/tao/orbconf.h \ + $(ACE_ROOT)/ace/CORBA_macros.h \ + $(TAO_ROOT)/tao/Environment.h \ + $(TAO_ROOT)/tao/Environment.i \ + $(TAO_ROOT)/tao/ORB.h \ + $(TAO_ROOT)/tao/Exception.h \ + $(TAO_ROOT)/tao/Exception.i \ + $(TAO_ROOT)/tao/ORB.i \ + $(TAO_ROOT)/tao/Any.h \ + $(TAO_ROOT)/tao/CDR.h \ + $(TAO_ROOT)/tao/Typecode.h \ + $(TAO_ROOT)/tao/Typecode.i \ + $(TAO_ROOT)/tao/CDR.i \ + $(TAO_ROOT)/tao/Any.i \ + $(TAO_ROOT)/tao/NVList.h \ + $(TAO_ROOT)/tao/NVList.i \ + $(TAO_ROOT)/tao/Principal.h \ + $(TAO_ROOT)/tao/Sequence.h \ + $(TAO_ROOT)/tao/Managed_Types.h \ + $(TAO_ROOT)/tao/Managed_Types.i \ + $(TAO_ROOT)/tao/Sequence.i \ + $(TAO_ROOT)/tao/Principal.i \ + $(TAO_ROOT)/tao/Request.h \ + $(TAO_ROOT)/tao/Request.i \ + $(TAO_ROOT)/tao/Server_Request.h \ + $(TAO_ROOT)/tao/Object_KeyC.h \ + $(TAO_ROOT)/tao/Object_KeyC.i \ + $(TAO_ROOT)/tao/GIOP.h \ + $(TAO_ROOT)/tao/Sequence_T.h \ + $(TAO_ROOT)/tao/Sequence_T.i \ + $(TAO_ROOT)/tao/Sequence_T.cpp \ + $(TAO_ROOT)/tao/GIOP.i \ + $(TAO_ROOT)/tao/Object.h \ + $(TAO_ROOT)/tao/Object.i \ + $(TAO_ROOT)/tao/Server_Request.i \ + $(TAO_ROOT)/tao/Context.h \ + $(TAO_ROOT)/tao/Context.i \ + $(TAO_ROOT)/tao/varout.h \ + $(TAO_ROOT)/tao/varout.i \ + $(TAO_ROOT)/tao/varout.cpp \ + $(TAO_ROOT)/tao/Marshal.h \ + $(TAO_ROOT)/tao/Marshal.i \ + $(TAO_ROOT)/tao/singletons.h \ + $(ACE_ROOT)/ace/Singleton.h \ + $(ACE_ROOT)/ace/Singleton.i \ + $(ACE_ROOT)/ace/Singleton.cpp \ + $(TAO_ROOT)/tao/PolicyC.h \ + $(TAO_ROOT)/tao/PolicyC.i \ + $(TAO_ROOT)/tao/CurrentC.h \ + $(TAO_ROOT)/tao/CurrentC.i \ + $(TAO_ROOT)/tao/POA.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager.h \ + $(ACE_ROOT)/ace/Functor.h \ + $(ACE_ROOT)/ace/Functor.i \ + $(ACE_ROOT)/ace/Functor_T.h \ + $(ACE_ROOT)/ace/Functor_T.i \ + $(ACE_ROOT)/ace/Functor_T.cpp \ + $(ACE_ROOT)/ace/Hash_Map_Manager.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Hash_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Service_Config.h \ + $(ACE_ROOT)/ace/Service_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.h \ + $(ACE_ROOT)/ace/Shared_Object.i \ + $(ACE_ROOT)/ace/Service_Object.i \ + $(ACE_ROOT)/ace/Service_Config.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h \ + $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ + $(TAO_ROOT)/tao/POAC.h \ + $(TAO_ROOT)/tao/POAC.i \ + $(TAO_ROOT)/tao/Servant_Base.h \ + $(TAO_ROOT)/tao/Servant_Base.i \ + $(TAO_ROOT)/tao/POAS.h \ + $(TAO_ROOT)/tao/POA_CORBA.h \ + $(TAO_ROOT)/tao/DynAnyC.h \ + $(TAO_ROOT)/tao/DynAnyC.i \ + $(TAO_ROOT)/tao/POAS.i \ + $(TAO_ROOT)/tao/Active_Object_Map.h \ + $(ACE_ROOT)/ace/Map.h \ + $(ACE_ROOT)/ace/Map.i \ + $(ACE_ROOT)/ace/Map_T.h \ + $(ACE_ROOT)/ace/Pair.h \ + $(ACE_ROOT)/ace/Pair.i \ + $(ACE_ROOT)/ace/Pair_T.h \ + $(ACE_ROOT)/ace/Pair_T.i \ + $(ACE_ROOT)/ace/Pair_T.cpp \ + $(ACE_ROOT)/ace/Map_Manager.h \ + $(ACE_ROOT)/ace/Map_Manager.i \ + $(ACE_ROOT)/ace/Map_Manager.cpp \ + $(ACE_ROOT)/ace/Active_Map_Manager.h \ + $(ACE_ROOT)/ace/Active_Map_Manager.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.h \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.i \ + $(ACE_ROOT)/ace/Active_Map_Manager_T.cpp \ + $(ACE_ROOT)/ace/Map_T.i \ + $(ACE_ROOT)/ace/Map_T.cpp \ + $(TAO_ROOT)/tao/Server_Strategy_Factory.h \ + $(ACE_ROOT)/ace/Strategies_T.h \ + $(ACE_ROOT)/ace/Strategies.h \ + $(ACE_ROOT)/ace/Strategies.i \ + $(ACE_ROOT)/ace/Synch_Options.h \ + $(ACE_ROOT)/ace/Synch_Options.i \ + $(ACE_ROOT)/ace/Thread_Manager.h \ + $(ACE_ROOT)/ace/Thread_Manager.i \ + $(ACE_ROOT)/ace/Strategies_T.i \ + $(ACE_ROOT)/ace/Strategies_T.cpp \ + $(ACE_ROOT)/ace/Service_Repository.h \ + $(ACE_ROOT)/ace/Service_Types.h \ + $(ACE_ROOT)/ace/Service_Types.i \ + $(ACE_ROOT)/ace/Service_Repository.i \ + $(ACE_ROOT)/ace/WFMO_Reactor.h \ + $(ACE_ROOT)/ace/Message_Queue.h \ + $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ + $(ACE_ROOT)/ace/Message_Queue_T.h \ + $(ACE_ROOT)/ace/Message_Queue_T.i \ + $(ACE_ROOT)/ace/Message_Queue_T.cpp \ + $(ACE_ROOT)/ace/Message_Queue.i \ + $(ACE_ROOT)/ace/WFMO_Reactor.i \ + $(TAO_ROOT)/tao/Connect.h \ + $(ACE_ROOT)/ace/Acceptor.h \ + $(ACE_ROOT)/ace/Svc_Handler.h \ + $(ACE_ROOT)/ace/Task.h \ + $(ACE_ROOT)/ace/Task.i \ + $(ACE_ROOT)/ace/Task_T.h \ + $(ACE_ROOT)/ace/Task_T.i \ + $(ACE_ROOT)/ace/Task_T.cpp \ + $(ACE_ROOT)/ace/Module.h \ + $(ACE_ROOT)/ace/Module.i \ + $(ACE_ROOT)/ace/Module.cpp \ + $(ACE_ROOT)/ace/Stream_Modules.h \ + $(ACE_ROOT)/ace/Stream_Modules.i \ + $(ACE_ROOT)/ace/Stream_Modules.cpp \ + $(ACE_ROOT)/ace/Svc_Handler.i \ + $(ACE_ROOT)/ace/Svc_Handler.cpp \ + $(ACE_ROOT)/ace/Dynamic.h \ + $(ACE_ROOT)/ace/Dynamic.i \ + $(ACE_ROOT)/ace/Acceptor.i \ + $(ACE_ROOT)/ace/Acceptor.cpp \ + $(ACE_ROOT)/ace/SOCK_Acceptor.h \ + $(ACE_ROOT)/ace/SOCK_Stream.h \ + $(ACE_ROOT)/ace/SOCK_IO.h \ + $(ACE_ROOT)/ace/SOCK.h \ + $(ACE_ROOT)/ace/Addr.h \ + $(ACE_ROOT)/ace/Addr.i \ + $(ACE_ROOT)/ace/IPC_SAP.h \ + $(ACE_ROOT)/ace/IPC_SAP.i \ + $(ACE_ROOT)/ace/SOCK.i \ + $(ACE_ROOT)/ace/SOCK_IO.i \ + $(ACE_ROOT)/ace/INET_Addr.h \ + $(ACE_ROOT)/ace/INET_Addr.i \ + $(ACE_ROOT)/ace/SOCK_Stream.i \ + $(ACE_ROOT)/ace/Time_Value.h \ + $(ACE_ROOT)/ace/SOCK_Acceptor.i \ + $(TAO_ROOT)/tao/Connect.i \ + $(TAO_ROOT)/tao/params.h \ + $(TAO_ROOT)/tao/params.i \ + $(TAO_ROOT)/tao/Active_Object_Map.i \ + $(TAO_ROOT)/tao/POAManager.h \ + $(TAO_ROOT)/tao/poa_macros.h \ + $(TAO_ROOT)/tao/POAManager.i \ + $(TAO_ROOT)/tao/POA.i \ + $(TAO_ROOT)/tao/Stub.h \ + $(TAO_ROOT)/tao/Pluggable.h \ + $(TAO_ROOT)/tao/MProfile.h \ + $(TAO_ROOT)/tao/MProfile.i \ + $(TAO_ROOT)/tao/Stub.i \ + $(TAO_ROOT)/tao/ORB_Core.h \ + $(TAO_ROOT)/tao/IIOP_Connector.h \ + $(ACE_ROOT)/ace/Connector.h \ + $(ACE_ROOT)/ace/Connector.i \ + $(ACE_ROOT)/ace/Connector.cpp \ + $(ACE_ROOT)/ace/SOCK_Connector.h \ + $(ACE_ROOT)/ace/SOCK_Connector.i \ + $(TAO_ROOT)/tao/IIOP_Acceptor.h \ + $(TAO_ROOT)/tao/ORB_Core.i \ + $(ACE_ROOT)/ace/Dynamic_Service.h \ + $(ACE_ROOT)/ace/Dynamic_Service.cpp \ + $(TAO_ROOT)/tao/Operation_Table.h \ + $(TAO_ROOT)/tao/Client_Strategy_Factory.h \ + $(TAO_ROOT)/tao/Invocation.h \ + $(TAO_ROOT)/tao/Invocation.i \ + $(TAO_ROOT)/tao/InconsistentTypeCodeC.h \ + $(TAO_ROOT)/tao/DynAny_i.h \ + $(TAO_ROOT)/tao/Union.h \ + ../Generic_Servant/generic_servant_export.h ../Generic_Servant/FooC.i \ + ../Generic_Servant/FooS_T.h ../Generic_Servant/FooS_T.i \ + ../Generic_Servant/FooS_T.cpp ../Generic_Servant/FooS.i + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/examples/POA/Adapter_Activator/README b/TAO/examples/POA/Adapter_Activator/README new file mode 100644 index 00000000000..6f7a41e48b3 --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/README @@ -0,0 +1,49 @@ +// $Id$ + +This example is very similar to the Explicit_Activation example except +that the POAs are deleted once the object references have been +created. After this, an adapter activator is install in the RootPOA to +reactivate the POAs on demand. + +The server program is available here. Use the Generic_Servant/client +program to test this. + +________________________________________ + +To test this example, type run_test.pl +________________________________________ + +Or +________________________________________ + +Run the server as follows: + +% ./server -f output + +This will produce three output files: output_1, output_2, and output_3 + +Run the client as follows: + +% cd $TAO_ROOT/examples/POA/Generic_Servant +% ./client -f ../Explicit_Activation/output_1 +% ./client -f ../Explicit_Activation/output_2 +% ./client -f ../Explicit_Activation/output_3 +________________________________________ + +Or +________________________________________ + +Run the server as follows: + +% ./server -ORBobjrefstyle URL & + +Run the client as follows: + +% cd $TAO_ROOT/examples/POA/Generic_Servant +% ./client -k <IOR> + +Comments : +========= + - As soon as, the server prints out the IOR, cut it and use it for +running the client. +________________________________________ diff --git a/TAO/examples/POA/Adapter_Activator/run_test.pl b/TAO/examples/POA/Adapter_Activator/run_test.pl new file mode 100755 index 00000000000..70f9c45c46c --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/run_test.pl @@ -0,0 +1,75 @@ +#$Id$ +# -*- perl -*- +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +unshift @INC, '../../../../bin'; +require ACEutils; + +$iorfile = "ior"; + +$oneway = ""; +$iterations = 100; + +$extra_args = ""; + +# Parse the arguments +for ($i = 0; $i <= $#ARGV; $i++) +{ + SWITCH: + { + if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") + { + print "run_test [-h] [-i iterations] [-o] [-f ior file]\n"; + print "\n"; + print "-h -- prints this information\n"; + print "-f -- ior file\n"; + print "-i iterations -- specifies iterations\n"; + print "-o -- call issued are oneways\n"; + exit; + } + if ($ARGV[$i] eq "-o") + { + $oneway = "-o"; + last SWITCH; + } + if ($ARGV[$i] eq "-i") + { + $iterations = $ARGV[$i + 1]; + $i++; + last SWITCH; + } + if ($ARGV[$i] eq "-f") + { + $iorfile = $ARGV[$i + 1]; + $i++; + last SWITCH; + } + $extra_args .= " " . $ARGV[$i]; + } +} + +$iorfile_1 = $iorfile."_1"; +$iorfile_2 = $iorfile."_2"; +$iorfile_3 = $iorfile."_3"; + +unlink $iorfile_1; +unlink $iorfile_2; +unlink $iorfile_3; + +$SV = Process::Create ($EXEPREFIX."server$Process::EXE_EXT", "-f $iorfile $extra_args"); + +ACE::waitforfile ($iorfile_1); +ACE::waitforfile ($iorfile_2); +ACE::waitforfile ($iorfile_3); + +$status = system ("../Generic_Servant/client$Process::EXE_EXT $extra_args $oneway -i $iterations -f $iorfile_1"); +$status = system ("../Generic_Servant/client$Process::EXE_EXT $extra_args $oneway -i $iterations -f $iorfile_2"); +$status = system ("../Generic_Servant/client$Process::EXE_EXT $extra_args $oneway -i $iterations -f $iorfile_3 -x"); + +unlink $iorfile_1; +unlink $iorfile_2; +unlink $iorfile_3; + +exit $status; diff --git a/TAO/examples/POA/Adapter_Activator/server.cpp b/TAO/examples/POA/Adapter_Activator/server.cpp new file mode 100644 index 00000000000..66a31b5b079 --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/server.cpp @@ -0,0 +1,420 @@ +// $Id$ + +// ================================================================ +// +// = LIBRARY +// TAO/tests/POA/Adapter_Activator +// +// = FILENAME +// server.cpp +// +// = DESCRIPTION +// This example is very similar to the Explicit_Activation example +// except that the POAs are deleted once the object references have +// been created. After this, an adapter activator is install in the +// RootPOA to reactivate the POAs on demand. +// +// Similar to the Explicit_Activation, the client for this example +// is Generic_Servant. +// +// = AUTHOR +// Irfan Pyarali +// +// ================================================================ + +#include "ace/Get_Opt.h" +#include "MyFooServant.h" + +ACE_RCSID(Adapter_Activator, server, "$Id$") + +class Adapter_Activator : public POA_PortableServer::AdapterActivator +{ +public: + + Adapter_Activator (PortableServer::POAManager_ptr poa_manager, + CORBA::ORB_ptr orb); + + CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent, + const char *name, + CORBA_Environment &ACE_TRY_ENV); + + CORBA::PolicyList first_poa_policies_; + CORBA::PolicyList second_poa_policies_; + +private: + + PortableServer::POAManager_var poa_manager_; + CORBA::ORB_var orb_; +}; + +Adapter_Activator::Adapter_Activator (PortableServer::POAManager_ptr poa_manager, + CORBA::ORB_ptr orb) + : poa_manager_ (PortableServer::POAManager::_duplicate (poa_manager)), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +CORBA::Boolean +Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, + const char *name, + CORBA::Environment &ACE_TRY_ENV) +{ + if (ACE_OS::strcmp (name, "firstPOA") == 0) + { + PortableServer::POA_var child = parent->create_POA (name, + this->poa_manager_.in (), + this->first_poa_policies_, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + // Creation of firstPOA is over. Destroy the Policy objects. + for (CORBA::ULong i = 0; + i < this->first_poa_policies_.length (); + ++i) + { + this->first_poa_policies_[i]->destroy (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + } + + PortableServer::AdapterActivator_var activator = this->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + child->the_activator (activator.in (), + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + MyFooServant *foo_impl = new MyFooServant (this->orb_.in (), + child.in (), + 28); + + child->set_servant (foo_impl, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + // Finally everything is fine + return 1; + } + else if (ACE_OS::strcmp (name, "secondPOA") == 0) + { + PortableServer::POA_var child = parent->create_POA (name, + this->poa_manager_.in (), + this->second_poa_policies_, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + // Creation of secondPOA is over. Destroy the Policy objects. + for (CORBA::ULong i = 0; + i < this->second_poa_policies_.length (); + ++i) + { + this->second_poa_policies_[i]->destroy (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + } + + MyFooServant *foo_impl = new MyFooServant (this->orb_.in (), + child.in (), + 29); + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId ("third Foo"); + + child->activate_object_with_id (oid.in (), + foo_impl, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + // Finally everything is fine + return 1; + } + else + { + // Unknown POA. + return 0; + } +} + +static char *ior_output_file = 0; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "f:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + ior_output_file = get_opts.optarg; + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-f ior_output_file]" + "\n", + argv [0]), + -1); + } + + // Indicates successful parsing of command line. + return 0; +} + +static int +write_iors_to_file (const char *first_ior, + const char *second_ior, + const char *third_ior) +{ + if (ior_output_file == 0) + // No filename was specified; simply return + return 0; + + char ior_output_file_1[BUFSIZ]; + char ior_output_file_2[BUFSIZ]; + char ior_output_file_3[BUFSIZ]; + + ACE_OS::sprintf (ior_output_file_1, "%s_1", ior_output_file); + ACE_OS::sprintf (ior_output_file_2, "%s_2", ior_output_file); + ACE_OS::sprintf (ior_output_file_3, "%s_3", ior_output_file); + + FILE *output_file_1 = ACE_OS::fopen (ior_output_file_1, "w"); + FILE *output_file_2 = ACE_OS::fopen (ior_output_file_2, "w"); + FILE *output_file_3 = ACE_OS::fopen (ior_output_file_3, "w"); + + if (output_file_1 == 0 || + output_file_2 == 0 || + output_file_3 == 0) + ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output files for writing IORs: %s, %s %s\n", + ior_output_file_1, + ior_output_file_2, + ior_output_file_3), + -1); + + u_int result = 0; + + result = ACE_OS::fprintf (output_file_1, + "%s", + first_ior); + if (result != ACE_OS::strlen (first_ior)) + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + first_ior, + ior_output_file_1), + -1); + + result = ACE_OS::fprintf (output_file_2, + "%s", + second_ior); + if (result != ACE_OS::strlen (second_ior)) + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + second_ior, + ior_output_file_2), + -1); + + result = ACE_OS::fprintf (output_file_3, + "%s", + third_ior); + if (result != ACE_OS::strlen (third_ior)) + ACE_ERROR_RETURN ((LM_ERROR, + "ACE_OS::fprintf failed while writing %s to %s\n", + third_ior, + ior_output_file_3), + -1); + + ACE_OS::fclose (output_file_1); + ACE_OS::fclose (output_file_2); + ACE_OS::fclose (output_file_3); + + return 0; +} + +int +main (int argc, char **argv) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + // Initialize the ORB first. + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + 0, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + int result = parse_args (argc, argv); + if (result != 0) + return result; + + // Obtain the RootPOA. + CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); + + // Get the POA_var object from Object_var. + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Get the POAManager of the RootPOA. + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + Adapter_Activator adapter_activator (poa_manager.in (), + orb.in ()); + + PortableServer::AdapterActivator_var activator = adapter_activator._this (ACE_TRY_ENV); + ACE_TRY_CHECK; + + root_poa->the_activator (activator.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POA_var first_poa; + PortableServer::POA_var second_poa; + + { + // Policies for the firstPOA to be created. + CORBA::PolicyList &policies = adapter_activator.first_poa_policies_; + policies.length (4); + + // Id Assignment Policy + policies[0] = + root_poa->create_id_assignment_policy (PortableServer::SYSTEM_ID, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Lifespan policy + policies[1] = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Request Processing policy + policies[2] = + root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Id Uniqueness + policies[3] = + root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Create the firstPOA under the RootPOA. + first_poa = root_poa->create_POA ("firstPOA", + poa_manager.in (), + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + + { + // Policies for the secondPOA to be created. + CORBA::PolicyList &policies = adapter_activator.second_poa_policies_; + policies.length (2); + + // Id Assignment Policy + policies[0] = + root_poa->create_id_assignment_policy (PortableServer::USER_ID, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Lifespan policy + policies[1] = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Create the secondPOA under the firstPOA. + second_poa = first_poa->create_POA ("secondPOA", + poa_manager.in (), + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + + // Create a servant. + MyFooServant first_foo_impl (orb.in (), + root_poa.in (), + 27); + + PortableServer::ObjectId_var first_oid = + root_poa->activate_object (&first_foo_impl, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Get Object Reference for the first_foo_impl object. + Foo_var first_foo = first_foo_impl._this (ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::Object_var second_foo = + first_poa->create_reference ("IDL:Foo:1.0", + ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::ObjectId_var third_oid = + PortableServer::string_to_ObjectId ("third Foo"); + + CORBA::Object_var third_foo = + second_poa->create_reference_with_id (third_oid.in (), + "IDL:Foo:1.0", + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Stringyfy all the object references and print them out. + CORBA::String_var first_ior = + orb->object_to_string (first_foo.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::String_var second_ior = + orb->object_to_string (second_foo.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::String_var third_ior = + orb->object_to_string (third_foo.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, + "%s\n%s\n%s\n", + first_ior.in (), + second_ior.in (), + third_ior.in ())); + + int write_result = write_iors_to_file (first_ior.in (), + second_ior.in (), + third_ior.in ()); + if (write_result != 0) + return write_result; + + first_poa->destroy (1, + 1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (orb->run () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); + + // Destroy RootPOA (also destroys all child POAs). + root_poa->destroy (1, + 1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); + + return 0; +} diff --git a/TAO/examples/POA/Adapter_Activator/server.dsp b/TAO/examples/POA/Adapter_Activator/server.dsp new file mode 100644 index 00000000000..3fdab5e5a91 --- /dev/null +++ b/TAO/examples/POA/Adapter_Activator/server.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="POA Adapter Activator Server" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=POA Adapter Activator Server - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak"\
+ CFG="POA Adapter Activator Server - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "POA Adapter Activator Server - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "POA Adapter Activator Server - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "POA Adapter Activator Server - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /I "..\..\..\.." /I "..\Generic_Servant\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 tao.lib ace.lib ..\Generic_Servant\Generic_Servant.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "POA Adapter Activator Server - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /I "..\..\..\.." /I "..\Generic_Servant\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\Generic_Servant\Generic_Servantd.lib TAOd.lib aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "POA Adapter Activator Server - Win32 Release"
+# Name "POA Adapter Activator Server - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/examples/POA/Explicit_Activation/README b/TAO/examples/POA/Explicit_Activation/README index fdf1a3bf367..fd31291356c 100644 --- a/TAO/examples/POA/Explicit_Activation/README +++ b/TAO/examples/POA/Explicit_Activation/README @@ -21,7 +21,7 @@ This will produce three output files: output_1, output_2, and output_3 Run the client as follows: -% cd $TAO_ROOT/tests/POA/Generic_Servant +% cd $TAO_ROOT/examples/POA/Generic_Servant % ./client -f ../Explicit_Activation/output_1 % ./client -f ../Explicit_Activation/output_2 % ./client -f ../Explicit_Activation/output_3 @@ -36,13 +36,11 @@ Run the server as follows: Run the client as follows: -% cd $TAO_ROOT/tests/POA/Generic_Servant +% cd $TAO_ROOT/examples/POA/Generic_Servant % ./client -k <IOR> -Comments : +Comments : ========= - As soon as, the server prints out the IOR, cut it and use it for running the client. ________________________________________ - - diff --git a/TAO/examples/POA/Explicit_Activation/server.cpp b/TAO/examples/POA/Explicit_Activation/server.cpp index 4b18703c7c9..79d3d96ecb8 100644 --- a/TAO/examples/POA/Explicit_Activation/server.cpp +++ b/TAO/examples/POA/Explicit_Activation/server.cpp @@ -10,7 +10,7 @@ // // = DESCRIPTION // In this example, -// - A new POA ( firstPOA) is created, and the different functions +// - A new POA (firstPOA) is created, and the different functions // for the explicit activation of objects are demonstrated. // - The Foo application class objects (defined in // ./../Generic_Servant/MyFooServant) are used as sample objects. @@ -128,30 +128,30 @@ write_iors_to_file (const char *first_ior, int main (int argc, char **argv) { - // CORBA::Environment env; - ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - // Initialize the ORB first. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, ACE_TRY_ENV); + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + 0, + ACE_TRY_ENV); ACE_TRY_CHECK; - int result = parse_args (argc, argv); if (result != 0) return result; - + // Obtain the RootPOA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); // Get the POA_var object from Object_var. PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in (), ACE_TRY_ENV); + PortableServer::POA::_narrow (obj.in (), + ACE_TRY_ENV); ACE_TRY_CHECK; - + // Get the POAManager of the RootPOA. PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (ACE_TRY_ENV); @@ -163,12 +163,14 @@ main (int argc, char **argv) // Id Assignment Policy policies[0] = - root_poa->create_id_assignment_policy (PortableServer::USER_ID, ACE_TRY_ENV); + root_poa->create_id_assignment_policy (PortableServer::USER_ID, + ACE_TRY_ENV); ACE_TRY_CHECK; // Lifespan policy policies[1] = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT, ACE_TRY_ENV); + root_poa->create_lifespan_policy (PortableServer::PERSISTENT, + ACE_TRY_ENV); ACE_TRY_CHECK; // Create the firstPOA under the RootPOA. @@ -179,7 +181,7 @@ main (int argc, char **argv) policies, ACE_TRY_ENV); ACE_TRY_CHECK; - + // Create the secondPOA under the firstPOA. name = "secondPOA"; PortableServer::POA_var second_poa = @@ -187,45 +189,48 @@ main (int argc, char **argv) poa_manager.in (), policies, ACE_TRY_ENV); - + ACE_TRY_CHECK; + // Creation of POAs is over. Destroy the Policy objects. for (CORBA::ULong i = 0; - i < policies.length () && ACE_TRY_ENV.exception () == 0; + i < policies.length (); ++i) { - CORBA::Policy_ptr policy = policies[i]; - policy->destroy (ACE_TRY_ENV); + policies[i]->destroy (ACE_TRY_ENV); + ACE_TRY_CHECK; } - // Create two Objects of Class MyFooServant (defined in // ./../GenericServant/MyFooServant.h) Create one object at RootPOA // and the other at firstPOA. - MyFooServant first_foo_impl (orb.in (), root_poa.in (), 27); - MyFooServant second_foo_impl (orb.in (), first_poa.in (), 28); - + MyFooServant first_foo_impl (orb.in (), + root_poa.in (), + 27); + MyFooServant second_foo_impl (orb.in (), + first_poa.in (), + 28); + // Do "activate_object" to activate the first_foo_impl object. It // returns ObjectId for that object. Operation Used : - // ObjectId activate_object( in Servant p_servant) + // ObjectId activate_object(in Servant p_servant) // raises (ServantAlreadyActive, WrongPolicy); PortableServer::ObjectId_var first_oid = - root_poa->activate_object (&first_foo_impl, ACE_TRY_ENV); + root_poa->activate_object (&first_foo_impl, + ACE_TRY_ENV); ACE_TRY_CHECK; - - + // Get Object Reference for the first_foo_impl object. Foo_var first_foo = first_foo_impl._this (ACE_TRY_ENV); ACE_TRY_CHECK; - - + // Get ObjectId for object secondFoo and use that ObjectId to // activate the second_foo_impl object. // Operation Used : - // void activate_object_with_id( in ObjectId oid, in Servant p_servant) + // void activate_object_with_id(in ObjectId oid, in Servant p_servant) // raises (ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy); PortableServer::ObjectId_var second_oid = PortableServer::string_to_ObjectId ("secondFoo"); - + first_poa->activate_object_with_id (second_oid.in (), &second_foo_impl, ACE_TRY_ENV); @@ -235,7 +240,6 @@ main (int argc, char **argv) Foo_var second_foo = second_foo_impl._this (ACE_TRY_ENV); ACE_TRY_CHECK; - // Get ObjectId for the string thirdPOA Create the object reference // for thirdPOA using that ObjectId. Operation Used : // Object create_reference_with_id (in ObjectId oid, in CORBA::RepositoryId intf ); @@ -245,62 +249,58 @@ main (int argc, char **argv) PortableServer::ObjectId_var third_oid = PortableServer::string_to_ObjectId ("thirdFoo"); */ - + // This will test how the POA handles a user given ID PortableServer::ObjectId_var third_oid = PortableServer::string_to_ObjectId ("third Foo"); third_oid[5] = (CORBA::Octet) '\0'; - + CORBA::Object_var third_foo = second_poa->create_reference_with_id (third_oid.in (), - "IDL:Foo:1.0", ACE_TRY_ENV); + "IDL:Foo:1.0", + ACE_TRY_ENV); ACE_TRY_CHECK; - // Stringyfy all the object references and print them out. CORBA::String_var first_ior = orb->object_to_string (first_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - CORBA::String_var second_ior = orb->object_to_string (second_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - - + CORBA::String_var third_ior = orb->object_to_string (third_foo.in (), ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "%s\n%s\n%s\n", first_ior.in (), second_ior.in (), third_ior.in ())); - + int write_result = write_iors_to_file (first_ior.in (), - second_ior.in (), - third_ior.in ()); + second_ior.in (), + third_ior.in ()); if (write_result != 0) return write_result; - // Activate thirdPOA using its ObjectID. + // Activate third servant using its ObjectID. MyFooServant third_foo_impl (orb.in (), second_poa.in (), 29); second_poa->activate_object_with_id (third_oid.in (), &third_foo_impl, ACE_TRY_ENV); ACE_TRY_CHECK; - + poa_manager->activate (ACE_TRY_ENV); ACE_TRY_CHECK; - if (orb->run () == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); - // Destroy RootPOA. ( Also destroys firstPOA) + // Destroy RootPOA (also destroys all child POAs). root_poa->destroy (1, 1, ACE_TRY_ENV); @@ -316,6 +316,6 @@ main (int argc, char **argv) } ACE_ENDTRY; ACE_CHECK_RETURN (-1); - + return 0; } diff --git a/TAO/examples/POA/FindPOA/FindPOA.cpp b/TAO/examples/POA/FindPOA/FindPOA.cpp index a1215d46459..44edc46c1b2 100644 --- a/TAO/examples/POA/FindPOA/FindPOA.cpp +++ b/TAO/examples/POA/FindPOA/FindPOA.cpp @@ -28,13 +28,13 @@ main (int argc, char **argv) // Initialize the ORB char str[256]; // Exception message - ACE_TRY + ACE_TRY { ACE_OS::strcpy (str, "CORBA::ORB_init"); - + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, ACE_TRY_ENV); ACE_TRY_CHECK; - + // Get Object reference to RootPOA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); @@ -47,15 +47,15 @@ main (int argc, char **argv) // Get a TAO_Adapter_Activator reference TAO_Adapter_Activator activator_impl; - + ACE_OS::strcpy (str, "TAO_Adapter_Activator::_this"); PortableServer::AdapterActivator_var activator = activator_impl._this (ACE_TRY_ENV); ACE_TRY_CHECK; - + // Register the TAO_Adapter_Activator reference to be the RootPOA's // Adapter Activator. - ACE_OS::strcpy (str,"PortableServer::POA::the_activator"); + ACE_OS::strcpy (str,"PortableServer::POA::the_activator"); root_poa->the_activator (activator.in (), ACE_TRY_ENV); ACE_TRY_CHECK; @@ -67,7 +67,7 @@ main (int argc, char **argv) 1, ACE_TRY_ENV); ACE_TRY_CHECK; - + name = "secondPOA"; PortableServer::POA_var second_poa = first_poa->find_POA (name.c_str (), @@ -91,7 +91,7 @@ main (int argc, char **argv) ACE_TRY_CHECK; ACE_DEBUG ((LM_DEBUG, - "%s\n%s\n%s\n%s\n", + "%s\n%s\n%s\n", root_poa_name.in (), first_poa_name.in (), second_poa_name.in ())); diff --git a/TAO/examples/POA/Identity/Identity.dsp b/TAO/examples/POA/Identity/Identity.dsp index 8acd57a0362..dbf16356da3 100644 --- a/TAO/examples/POA/Identity/Identity.dsp +++ b/TAO/examples/POA/Identity/Identity.dsp @@ -1,25 +1,25 @@ -# Microsoft Developer Studio Project File - Name="Identity" - Package Owner=<4>
+# Microsoft Developer Studio Project File - Name="POA Identity" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
-CFG=Identity - Win32 Debug
+CFG=POA Identity - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
-!MESSAGE
+!MESSAGE
!MESSAGE NMAKE /f "Identity.mak".
-!MESSAGE
+!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "Identity.mak" CFG="Identity - Win32 Debug"
-!MESSAGE
+!MESSAGE
+!MESSAGE NMAKE /f "Identity.mak" CFG="POA Identity - Win32 Debug"
+!MESSAGE
!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Identity - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Identity - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
+!MESSAGE
+!MESSAGE "POA Identity - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "POA Identity - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
@@ -28,7 +28,7 @@ CFG=Identity - Win32 Debug CPP=cl.exe
RSC=rc.exe
-!IF "$(CFG)" == "Identity - Win32 Release"
+!IF "$(CFG)" == "POA Identity - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
@@ -51,7 +51,7 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ace.lib tao.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..tao" /libpath:"..\..\..\..\ace"
-!ELSEIF "$(CFG)" == "Identity - Win32 Debug"
+!ELSEIF "$(CFG)" == "POA Identity - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
@@ -75,12 +75,12 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 aced.lib taod.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
-!ENDIF
+!ENDIF
# Begin Target
-# Name "Identity - Win32 Release"
-# Name "Identity - Win32 Debug"
+# Name "POA Identity - Win32 Release"
+# Name "POA Identity - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
@@ -112,9 +112,9 @@ SOURCE=.\testS.cpp SOURCE=.\test.idl
-!IF "$(CFG)" == "Identity - Win32 Release"
+!IF "$(CFG)" == "POA Identity - Win32 Release"
-USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
+USERDEP__TEST_="..\..\..\..\bin\Release\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler on $(InputPath)
InputPath=.\test.idl
InputName=test
@@ -150,9 +150,9 @@ BuildCmds= \ $(BuildCmds)
# End Custom Build
-!ELSEIF "$(CFG)" == "Identity - Win32 Debug"
+!ELSEIF "$(CFG)" == "POA Identity - Win32 Debug"
-USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
+USERDEP__TEST_="..\..\..\..\bin\tao_idl.exe"
# Begin Custom Build - Invoking TAO_IDL Compiler on $(InputPath)
InputPath=.\test.idl
InputName=test
@@ -188,7 +188,7 @@ BuildCmds= \ $(BuildCmds)
# End Custom Build
-!ENDIF
+!ENDIF
# End Source File
# End Group
diff --git a/TAO/examples/POA/Makefile b/TAO/examples/POA/Makefile index b3f0b00b444..32574c8b614 100644 --- a/TAO/examples/POA/Makefile +++ b/TAO/examples/POA/Makefile @@ -10,15 +10,19 @@ # Local macros #---------------------------------------------------------------------------- -DIRS = Default_Servant \ +DIRS = Generic_Servant \ + Adapter_Activator \ + DSI \ + Default_Servant \ + Explicit_Activation \ FindPOA \ Forwarding \ - Generic_Servant \ - Explicit_Activation \ + Identity \ + Loader \ NewPOA \ On_Demand_Activation \ + On_Demand_Loading \ RootPOA \ - Identity \ TIE # The following test hasn't been updated yet diff --git a/TAO/examples/POA/NewPOA/NewPOA.cpp b/TAO/examples/POA/NewPOA/NewPOA.cpp index 80058d2f059..d9afbb72c53 100644 --- a/TAO/examples/POA/NewPOA/NewPOA.cpp +++ b/TAO/examples/POA/NewPOA/NewPOA.cpp @@ -10,12 +10,12 @@ // = DESCRIPTION // This program demonstrates creation of new POAs, as children of the root POA or the // existing POA. -// There are five new POA created in this example. +// There are three new POA created in this example. // The hierarchy of POAs looks like this. // // /-->first_poa-->first_poa/second_poa // RootPOA-- -// \-->third_poa-->third_poa/fourth_poa-->third_poa/fourth_poa/fifth_poa +// \-->third_poa // // = AUTHOR // Irfan Pyarali @@ -90,28 +90,22 @@ main (int argc, char **argv) } // Creation of the new POA, i.e. firstPOA/secondPOA - name += TAO_POA::name_separator (); - name += "secondPOA"; + name = "secondPOA"; PortableServer::POA_var second_poa = - root_poa->create_POA (name.c_str (), - PortableServer::POAManager::_nil (), - policies, - env); + first_poa->create_POA (name.c_str (), + PortableServer::POAManager::_nil (), + policies, + env); if (env.exception () != 0) { env.print_exception ("PortableServer::POA::create_POA"); return -1; } - // Creating thirdPOA/fourthPOA/fifthPOA. The non-existing thirdPOA - // and thirdPOA/fourthPOA are created automatically. + // Creating thirdPOA. name = "thirdPOA"; - name += TAO_POA::name_separator (); - name += "forthPOA"; - name += TAO_POA::name_separator (); - name += "fifthPOA"; - PortableServer::POA_var fifth_poa = + PortableServer::POA_var third_poa = root_poa->create_POA (name.c_str (), PortableServer::POAManager::_nil (), policies, @@ -163,8 +157,8 @@ main (int argc, char **argv) return -1; } - CORBA::String_var fifth_poa_name = - fifth_poa->the_name (env); + CORBA::String_var third_poa_name = + third_poa->the_name (env); if (env.exception () != 0) { env.print_exception ("PortableServer::POA::_narrow"); @@ -176,8 +170,8 @@ main (int argc, char **argv) root_poa_name.in (), first_poa_name.in (), second_poa_name.in (), - fifth_poa_name.in ())); - + third_poa_name.in ())); + // This should destroy all its children root_poa->destroy (1, 1, diff --git a/TAO/examples/POA/README b/TAO/examples/POA/README index d3f7c475390..4c90b58d80e 100644 --- a/TAO/examples/POA/README +++ b/TAO/examples/POA/README @@ -101,3 +101,11 @@ these applications further. not hijacked to store the DLL and factory function name. This information is provided to the Servant Managers on creation. + + . Explicit_Activation + + This example is very similar to the + Explicit_Activation example except that the POAs are + deleted once the object references have been + created. After this, an adapter activator is install + in the RootPOA to reactivate the POAs on demand. diff --git a/TAO/examples/POA/RootPOA/RootPOA.cpp b/TAO/examples/POA/RootPOA/RootPOA.cpp index 619dbeaceb3..a7a3538466a 100644 --- a/TAO/examples/POA/RootPOA/RootPOA.cpp +++ b/TAO/examples/POA/RootPOA/RootPOA.cpp @@ -25,41 +25,27 @@ ACE_RCSID(RootPOA, RootPOA, "$Id$") int main (int argc, char **argv) { - // CORBA::Environment env; - // Initilize the ORB ACE_TRY_NEW_ENV { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, ACE_TRY_ENV); ACE_TRY_CHECK; - ACE_PRINT_TAO_EXCEPTION (ACE_TRY_ENV, - "CORBA::ORB_init"); - ACE_CHECK_RETURN (-1); - - // Resolve the initial references for the name RootPOA thus getting // an object of type CORBA::Object. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); - + // apply _narrow on the object of type CORBA::Object, to make it a // POA class Object. PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in (), ACE_TRY_ENV); - - ACE_PRINT_TAO_EXCEPTION (ACE_TRY_ENV, - "PortableServer::POA::_narrow"); - ACE_CHECK_RETURN (-1); + ACE_TRY_CHECK; // Get the name of the root POA. CORBA::String_var poa_name = root_poa->the_name (ACE_TRY_ENV); - - ACE_PRINT_TAO_EXCEPTION (ACE_TRY_ENV, - "PortableServer::POA::_narrow"); - ACE_CHECK_RETURN (-1); - + ACE_TRY_CHECK; ACE_DEBUG ((LM_DEBUG, "The RootPOA is : %s\n", @@ -69,19 +55,15 @@ main (int argc, char **argv) root_poa->destroy (1, 1, ACE_TRY_ENV); - - ACE_PRINT_TAO_EXCEPTION (ACE_TRY_ENV, - "PortableServer::POA::destroy"); - ACE_CHECK_RETURN (-1); - + ACE_TRY_CHECK; } ACE_CATCHANY { ACE_DEBUG ((LM_DEBUG, "Exceptions raised \n")); - ACE_CHECK_RETURN (-1); + ACE_CHECK_RETURN (-1); } ACE_ENDTRY; - + return 0; } diff --git a/TAO/examples/TAO_Examples.dsw b/TAO/examples/TAO_Examples.dsw index c97872ca9ae..a081f08c9b4 100644 --- a/TAO/examples/TAO_Examples.dsw +++ b/TAO/examples/TAO_Examples.dsw @@ -3,6 +3,18 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ###############################################################################
+Project: "POA Adapter Activator Server"=.\POA\Adapter_Activator\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "POA DSI Client"=.\POA\DSI\client.dsp - Package Owner=<4>
Package=<5>
@@ -129,6 +141,18 @@ Package=<4> ###############################################################################
+Project: "POA Identity"=.\POA\Identity\Identity.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "POA Loader Server"=.\POA\Loader\server.dsp - Package Owner=<4>
Package=<5>
diff --git a/TAO/tao/Active_Object_Map.cpp b/TAO/tao/Active_Object_Map.cpp index be99d972a6d..1e16edfac16 100644 --- a/TAO/tao/Active_Object_Map.cpp +++ b/TAO/tao/Active_Object_Map.cpp @@ -1,227 +1,198 @@ // $Id$ #include "tao/Active_Object_Map.h" -#include "tao/params.h" #if !defined (__ACE_INLINE__) # include "tao/Active_Object_Map.i" #endif /* __ACE_INLINE__ */ -//////////////////////////////////////////////////////////////////////////////// - -TAO_Incremental_Key_Generator::TAO_Incremental_Key_Generator (void) - : counter_ (0) -{ -} - -int -TAO_Incremental_Key_Generator::operator() (PortableServer::ObjectId &id) -{ - // Resize to accommodate the counter. - id.length (sizeof this->counter_); - - // Add new key data. - ACE_OS::memcpy (id.get_buffer (), - &++this->counter_, - sizeof this->counter_); - - // Success. - return 0; -} +#include "ace/Auto_Ptr.h" //////////////////////////////////////////////////////////////////////////////// -u_long -TAO_ObjectId_Hash::operator () (const PortableServer::ObjectId &id) const -{ - return ACE::hash_pjw ((const char *) id.get_buffer (), - id.length ()); -} - -//////////////////////////////////////////////////////////////////////////////// - -int -TAO_Ignore_Original_Key_Adapter::encode (const PortableServer::ObjectId &original_key, - const ACE_Active_Map_Manager_Key &active_key, - PortableServer::ObjectId &modified_key) -{ - // Size of active key. - size_t active_key_size = active_key.size (); - - // Resize to accommodate both the original data and the new active key. - modified_key.length (active_key_size); - - // Copy active key data into user key. - active_key.encode (modified_key.get_buffer ()); - - // Success. - return 0; -} +/* static */ +size_t TAO_Active_Object_Map::system_id_size_ (0); -int -TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, - ACE_Active_Map_Manager_Key &active_key) -{ - // Read off value of index and generation. - active_key.decode (modified_key.get_buffer ()); - - // Success. - return 0; -} - -int -TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, - PortableServer::ObjectId &original_key) +void +TAO_Active_Object_Map::set_system_id_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters) { - // Smartly copy all the data; <original_key does not own the data>. - original_key.replace (modified_key.maximum (), - modified_key.length (), - ACE_const_cast (CORBA::Octet *, - modified_key.get_buffer ()), - 0); - - // Success. - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// + if (TAO_Active_Object_Map::system_id_size_ == 0) + { + if (creation_parameters.allow_reactivation_of_system_ids_) + { + switch (creation_parameters.object_lookup_strategy_for_system_id_policy_) + { + case TAO_LINEAR: -int -TAO_Preserve_Original_Key_Adapter::encode (const PortableServer::ObjectId &original_key, - const ACE_Active_Map_Manager_Key &active_key, - PortableServer::ObjectId &modified_key) -{ - // Size of active key. - size_t active_key_size = active_key.size (); + TAO_Active_Object_Map::system_id_size_ = sizeof (CORBA::ULong); + break; - // Resize to accommodate both the original data and the new active key. - modified_key.length (active_key_size + original_key.length ()); + case TAO_DYNAMIC_HASH: + default: - // Copy active key data into user key. - active_key.encode (modified_key.get_buffer ()); + TAO_Active_Object_Map::system_id_size_ = sizeof (CORBA::ULong); + break; + } - // Copy the original key after the active key. - ACE_OS::memcpy (modified_key.get_buffer () + active_key_size, - original_key.get_buffer (), - original_key.length ()); + size_t hint_size; + if (creation_parameters.use_active_hint_in_ids_) + { + hint_size = ACE_Active_Map_Manager_Key::size (); + } + else + { + hint_size = 0; + } - // Success. - return 0; -} + TAO_Active_Object_Map::system_id_size_ += hint_size; + } + else + { + switch (creation_parameters.object_lookup_strategy_for_system_id_policy_) + { + case TAO_LINEAR: -int -TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, - ACE_Active_Map_Manager_Key &active_key) -{ - // Read off value of index and generation. - active_key.decode (modified_key.get_buffer ()); + TAO_Active_Object_Map::system_id_size_ = sizeof (CORBA::ULong); + break; - // Success. - return 0; -} + case TAO_DYNAMIC_HASH: -int -TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, - PortableServer::ObjectId &original_key) -{ - // Size of active key. - size_t active_key_size = ACE_Active_Map_Manager_Key::size (); + TAO_Active_Object_Map::system_id_size_ = sizeof (CORBA::ULong); + break; - // Smartly copy all the data; <original_key does not own the data>. - original_key.replace (modified_key.maximum () - active_key_size, - modified_key.length () - active_key_size, - ACE_const_cast (CORBA::Octet *, - modified_key.get_buffer ()) + active_key_size, - 0); + case TAO_ACTIVE_DEMUX: + default: - // Success. - return 0; + TAO_Active_Object_Map::system_id_size_ = ACE_Active_Map_Manager_Key::size (); + break; + } + } + } } -//////////////////////////////////////////////////////////////////////////////// - TAO_Active_Object_Map::TAO_Active_Object_Map (int user_id_policy, int unique_id_policy, int persistent_id_policy, - const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters) + const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters, + CORBA_Environment &ACE_TRY_ENV) : user_id_map_ (0), servant_map_ (0), id_uniqueness_strategy_ (0), lifespan_strategy_ (0), id_assignment_strategy_ (0), - id_hint_strategy_ (0), - system_id_size_ (0) + id_hint_strategy_ (0) { + TAO_Active_Object_Map::set_system_id_size (creation_parameters); + + TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy = 0; if (unique_id_policy) { - ACE_NEW (this->id_uniqueness_strategy_, - TAO_Unique_Id_Strategy); + ACE_NEW_THROW_EX (id_uniqueness_strategy, + TAO_Unique_Id_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } else { - ACE_NEW (this->id_uniqueness_strategy_, - TAO_Multiple_Id_Strategy); + ACE_NEW_THROW_EX (id_uniqueness_strategy, + TAO_Multiple_Id_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } + // Give ownership to the auto pointer. + auto_ptr<TAO_Id_Uniqueness_Strategy> new_id_uniqueness_strategy (id_uniqueness_strategy); + TAO_Lifespan_Strategy *lifespan_strategy = 0; if (persistent_id_policy) { - ACE_NEW (this->lifespan_strategy_, - TAO_Persistent_Strategy); + ACE_NEW_THROW_EX (lifespan_strategy, + TAO_Persistent_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } else { - ACE_NEW (this->lifespan_strategy_, - TAO_Transient_Strategy); + ACE_NEW_THROW_EX (lifespan_strategy, + TAO_Transient_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } + // Give ownership to the auto pointer. + auto_ptr<TAO_Lifespan_Strategy> new_lifespan_strategy (lifespan_strategy); + TAO_Id_Assignment_Strategy *id_assignment_strategy = 0; if (user_id_policy) { - ACE_NEW (this->id_assignment_strategy_, - TAO_User_Id_Strategy); + ACE_NEW_THROW_EX (id_assignment_strategy, + TAO_User_Id_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } else { if (unique_id_policy) { - ACE_NEW (this->id_assignment_strategy_, - TAO_System_Id_With_Unique_Id_Strategy); + ACE_NEW_THROW_EX (id_assignment_strategy, + TAO_System_Id_With_Unique_Id_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } else { - ACE_NEW (this->id_assignment_strategy_, - TAO_System_Id_With_Multiple_Id_Strategy); + ACE_NEW_THROW_EX (id_assignment_strategy, + TAO_System_Id_With_Multiple_Id_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } } + // Give ownership to the auto pointer. + auto_ptr<TAO_Id_Assignment_Strategy> new_id_assignment_strategy (id_assignment_strategy); + TAO_Id_Hint_Strategy *id_hint_strategy = 0; if ((user_id_policy || creation_parameters.allow_reactivation_of_system_ids_) && creation_parameters.use_active_hint_in_ids_) { - ACE_NEW (this->id_hint_strategy_, - TAO_Active_Hint_Strategy); + ACE_NEW_THROW_EX (id_hint_strategy, + TAO_Active_Hint_Strategy (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; } else { - ACE_NEW (this->id_hint_strategy_, - TAO_No_Hint_Strategy); + ACE_NEW_THROW_EX (id_hint_strategy, + TAO_No_Hint_Strategy, + CORBA::NO_MEMORY ()); + ACE_CHECK; } + // Give ownership to the auto pointer. + auto_ptr<TAO_Id_Hint_Strategy> new_id_hint_strategy (id_hint_strategy); + servant_map *sm = 0; if (unique_id_policy) { switch (creation_parameters.reverse_object_lookup_strategy_for_unique_id_policy_) { case TAO_LINEAR: - ACE_NEW (this->servant_map_, - servant_linear_map (creation_parameters.active_object_map_size_)); + ACE_NEW_THROW_EX (sm, + servant_linear_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; + case TAO_DYNAMIC_HASH: default: - ACE_NEW (this->servant_map_, - servant_hash_map (creation_parameters.active_object_map_size_)); + ACE_NEW_THROW_EX (sm, + servant_hash_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; } } + // Give ownership to the auto pointer. + auto_ptr<servant_map> new_servant_map (sm); + user_id_map *uim = 0; if (user_id_policy || creation_parameters.allow_reactivation_of_system_ids_) { @@ -229,21 +200,19 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (int user_id_policy, { case TAO_LINEAR: - ACE_NEW (this->user_id_map_, - user_id_linear_map (creation_parameters.active_object_map_size_)); - - this->system_id_size_ = sizeof (CORBA::ULong); - + ACE_NEW_THROW_EX (uim, + user_id_linear_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; case TAO_DYNAMIC_HASH: default: - ACE_NEW (this->user_id_map_, - user_id_hash_map (creation_parameters.active_object_map_size_)); - - this->system_id_size_ = sizeof (CORBA::ULong); - + ACE_NEW_THROW_EX (uim, + user_id_hash_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; } } @@ -253,43 +222,59 @@ TAO_Active_Object_Map::TAO_Active_Object_Map (int user_id_policy, { case TAO_LINEAR: - ACE_NEW (this->user_id_map_, - user_id_linear_map (creation_parameters.active_object_map_size_)); - - this->system_id_size_ = sizeof (CORBA::ULong); - + ACE_NEW_THROW_EX (uim, + user_id_linear_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; case TAO_DYNAMIC_HASH: - ACE_NEW (this->user_id_map_, - user_id_hash_map (creation_parameters.active_object_map_size_)); - - this->system_id_size_ = sizeof (CORBA::ULong); - + ACE_NEW_THROW_EX (uim, + user_id_hash_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; case TAO_ACTIVE_DEMUX: default: - ACE_NEW (this->user_id_map_, - user_id_active_map (creation_parameters.active_object_map_size_)); - - this->system_id_size_ = ACE_Active_Map_Manager_Key::size (); - + ACE_NEW_THROW_EX (uim, + user_id_active_map (creation_parameters.active_object_map_size_), + CORBA::NO_MEMORY ()); + ACE_CHECK; break; } } - - this->id_uniqueness_strategy_->set_active_object_map (this); - this->lifespan_strategy_->set_active_object_map (this); - this->id_assignment_strategy_->set_active_object_map (this); - - this->system_id_size_ += this->id_hint_strategy_->hint_size (); + // Give ownership to the auto pointer. + auto_ptr<user_id_map> new_user_id_map (uim); + + id_uniqueness_strategy->set_active_object_map (this); + lifespan_strategy->set_active_object_map (this); + id_assignment_strategy->set_active_object_map (this); + + // Finally everything is fine. Make sure to take ownership away + // from the auto pointer. + this->id_uniqueness_strategy_ = new_id_uniqueness_strategy.release (); + this->lifespan_strategy_ = new_lifespan_strategy.release (); + this->id_assignment_strategy_ = new_id_assignment_strategy.release (); + this->id_hint_strategy_ = new_id_hint_strategy.release (); + this->servant_map_ = new_servant_map.release (); + this->user_id_map_ = new_user_id_map.release (); } TAO_Active_Object_Map::~TAO_Active_Object_Map (void) { + user_id_map::iterator iterator = this->user_id_map_->begin (); + user_id_map::iterator end = this->user_id_map_->end (); + for (; + iterator != end; + ++iterator) + { + user_id_map::value_type map_entry = *iterator; + delete map_entry.second (); + } + delete this->id_uniqueness_strategy_; delete this->lifespan_strategy_; delete this->id_assignment_strategy_; @@ -502,10 +487,10 @@ TAO_Active_Object_Map::find_user_id_using_system_id (const PortableServer::Objec return 0; } -size_t +/* static */ size_t TAO_Active_Object_Map::system_id_size (void) { - return this->system_id_size_; + return TAO_Active_Object_Map::system_id_size_; } //////////////////////////////////////////////////////////////////////////////// @@ -964,6 +949,11 @@ TAO_Id_Hint_Strategy::~TAO_Id_Hint_Strategy (void) //////////////////////////////////////////////////////////////////////////////// +TAO_Active_Hint_Strategy::TAO_Active_Hint_Strategy (CORBA::ULong map_size) + : system_id_map_ (map_size) +{ +} + TAO_Active_Hint_Strategy::~TAO_Active_Hint_Strategy (void) { } @@ -1074,10 +1064,24 @@ TAO_No_Hint_Strategy::system_id (PortableServer::ObjectId_out system_id, #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class auto_ptr<TAO_Id_Uniqueness_Strategy>; +template class auto_ptr<TAO_Lifespan_Strategy>; +template class auto_ptr<TAO_Id_Assignment_Strategy>; +template class auto_ptr<TAO_Id_Hint_Strategy>; +template class auto_ptr<TAO_Active_Object_Map::servant_map>; +template class auto_ptr<TAO_Active_Object_Map::user_id_map>; + +template class ACE_Auto_Basic_Ptr<TAO_Id_Uniqueness_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Lifespan_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Id_Assignment_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Id_Hint_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Active_Object_Map::servant_map>; +template class ACE_Auto_Basic_Ptr<TAO_Active_Object_Map::user_id_map>; + // Common typedefs. typedef PortableServer::ObjectId id; typedef PortableServer::Servant servant; -typedef TAO_Active_Object_Map::Map_Entry * value; +typedef TAO_Active_Object_Map::Map_Entry *value; typedef ACE_Pair<id, value> id_expanded_value; typedef ACE_Reference_Pair<const id, value> id_value_type; @@ -1086,7 +1090,7 @@ typedef ACE_Equal_To<id> id_compare_keys; typedef ACE_Equal_To<servant> servant_compare_keys; typedef TAO_ObjectId_Hash id_hash; typedef TAO_Servant_Hash servant_hash; -typedef ACE_Noop_Key_Generator<PortableServer::Servant> noop_servant_key_generator; +typedef ACE_Noop_Key_Generator<servant> noop_servant_key_generator; // Common template class ACE_Reference_Pair<const id, value>; @@ -1159,6 +1163,20 @@ template class ACE_Map_Entry<servant, value>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_ptr<TAO_Id_Uniqueness_Strategy> +#pragma instantiate auto_ptr<TAO_Lifespan_Strategy> +#pragma instantiate auto_ptr<TAO_Id_Assignment_Strategy> +#pragma instantiate auto_ptr<TAO_Id_Hint_Strategy> +#pragma instantiate auto_ptr<TAO_Active_Object_Map::servant_map> +#pragma instantiate auto_ptr<TAO_Active_Object_Map::user_id_map> + +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Id_Uniqueness_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Lifespan_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Id_Assignment_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Id_Hint_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Active_Object_Map::servant_map> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Active_Object_Map::user_id_map> + // Common typedefs. typedef PortableServer::ObjectId id; typedef PortableServer::Servant servant; @@ -1171,7 +1189,7 @@ typedef ACE_Equal_To<id> id_compare_keys; typedef ACE_Equal_To<servant> servant_compare_keys; typedef TAO_ObjectId_Hash id_hash; typedef TAO_Servant_Hash servant_hash; -typedef ACE_Noop_Key_Generator<PortableServer::Servant> noop_servant_key_generator; +typedef ACE_Noop_Key_Generator<servant> noop_servant_key_generator; // Common #pragma instantiate ACE_Reference_Pair<const id, value> diff --git a/TAO/tao/Active_Object_Map.h b/TAO/tao/Active_Object_Map.h index e8c1cda6467..998047e44ae 100644 --- a/TAO/tao/Active_Object_Map.h +++ b/TAO/tao/Active_Object_Map.h @@ -17,10 +17,9 @@ #ifndef TAO_ACTIVE_OBJECT_MAP_H #define TAO_ACTIVE_OBJECT_MAP_H -#include "tao/corbafwd.h" -#include "tao/Servant_Base.h" -#include "ace/Map.h" +#include "tao/Key_Adapters.h" #include "tao/Server_Strategy_Factory.h" +#include "tao/Servant_Base.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -28,96 +27,6 @@ //////////////////////////////////////////////////////////////////////////////// -class TAO_Incremental_Key_Generator -{ - // = TITLE - // Defines a key generator. - // - // = DESCRIPTION - // This class is used in adapters of maps that do not produce keys. -public: - - TAO_Incremental_Key_Generator (void); - - int operator() (PortableServer::ObjectId &id); - -protected: - - CORBA::ULong counter_; -}; - -//////////////////////////////////////////////////////////////////////////////// - -class TAO_Export TAO_ObjectId_Hash -{ - // = TITLE - // Hashing class for Object Ids. - // - // = DESCRIPTION - // Define the hash() method for Object Ids. -public: - - u_long operator () (const PortableServer::ObjectId &id) const; - // Returns hash value. -}; - -//////////////////////////////////////////////////////////////////////////////// - -class TAO_Ignore_Original_Key_Adapter -{ - // = TITLE - // A key adapter (encode/decode) class. - // - // = DESCRIPTION - // Define the encoding and decoding methods for converting - // between Object Ids and active keys. This class ignores the - // <original_key> passed to it. -public: - - int encode (const PortableServer::ObjectId &original_key, - const ACE_Active_Map_Manager_Key &active_key, - PortableServer::ObjectId &modified_key); - - int decode (const PortableServer::ObjectId &modified_key, - ACE_Active_Map_Manager_Key &active_key); - - int decode (const PortableServer::ObjectId &modified_key, - PortableServer::ObjectId &original_key); -}; - -//////////////////////////////////////////////////////////////////////////////// - -class TAO_Preserve_Original_Key_Adapter -{ - // = TITLE - // A key adapter (encode/decode) class. - // - // = DESCRIPTION - // Define the encoding and decoding methods for converting - // between Object Ids and active keys. This class remembers the - // <original_key> passed to it. -public: - - int encode (const PortableServer::ObjectId &original_key, - const ACE_Active_Map_Manager_Key &active_key, - PortableServer::ObjectId &modified_key); - - int decode (const PortableServer::ObjectId &modified_key, - ACE_Active_Map_Manager_Key &active_key); - - int decode (const PortableServer::ObjectId &modified_key, - PortableServer::ObjectId &original_key); -}; - -//////////////////////////////////////////////////////////////////////////////// - -// Comparison of Object Ids. Defined in Stub.cpp for TAO_opaque (an -// alias of PortableServer::ObjectId). -extern TAO_Export int operator== (const PortableServer::ObjectId &l, - const PortableServer::ObjectId &r); - -//////////////////////////////////////////////////////////////////////////////// - // Forward declarations. class TAO_Id_Uniqueness_Strategy; class TAO_Lifespan_Strategy; @@ -136,7 +45,8 @@ public: TAO_Active_Object_Map (int user_id_policy, int unique_id_policy, int persistent_id_policy, - const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters); + const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters, + CORBA_Environment &ACE_TRY_ENV); // Constructor. ~TAO_Active_Object_Map (void); @@ -206,9 +116,12 @@ public: // Can be used with any policy. When the SYSTEM_ID policy is used, // the <system_id> is identical to <user_id>. - size_t system_id_size (void); + static size_t system_id_size (void); // Can be used with any policy. + static void set_system_id_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters); + // Set the system id size. + struct Map_Entry { // = TITLE @@ -287,7 +200,7 @@ public: TAO_Id_Hint_Strategy *id_hint_strategy_; // Id hint strategy. - size_t system_id_size_; + static size_t system_id_size_; // Size of the system id produced by the map. }; @@ -587,6 +500,8 @@ class TAO_Active_Hint_Strategy : public TAO_Id_Hint_Strategy // Strategy for adding active hints to ids. public: + TAO_Active_Hint_Strategy (CORBA::ULong map_size); + virtual ~TAO_Active_Hint_Strategy (void); // Virtual destructor. @@ -649,4 +564,4 @@ public: # include "tao/Active_Object_Map.i" #endif /* __ACE_INLINE__ */ -#endif /* TAO_ACTIVE_OBJECT_MAP_T_H */ +#endif /* TAO_ACTIVE_OBJECT_MAP_H */ diff --git a/TAO/tao/Connect.cpp b/TAO/tao/Connect.cpp index b8983d8e04d..0de9f13342a 100644 --- a/TAO/tao/Connect.cpp +++ b/TAO/tao/Connect.cpp @@ -264,43 +264,45 @@ TAO_Server_Connection_Handler::handle_message (TAO_InputCDR &input, response_required = request.response_expected (); + const CORBA::Octet *object_key = request.object_key ().get_buffer (); + #if !defined (TAO_NO_IOR_TABLE) - if (ACE_OS::memcmp (request.object_key ().get_buffer (), + if (ACE_OS::memcmp (object_key, &TAO_POA::objectkey_prefix[0], TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE) != 0) { - ACE_CString object_id (ACE_reinterpret_cast (const char *, request.object_key ().get_buffer ()), + ACE_CString object_id (ACE_reinterpret_cast (const char *, object_key), TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE, 0, 0); - + if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "Simple Object key %s. Doing the Table Lookup ...\n", object_id.c_str ())); - + CORBA::Object_ptr object_reference; - + // Do the Table Lookup. int status = this->orb_core_->orb ()->_tao_find_in_IOR_table (object_id, object_reference); - + // If ObjectID not in table or reference is nil raise OBJECT_NOT_EXIST. if (CORBA::is_nil (object_reference) || status == -1) ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO), -1); - + // ObjectID present in the table with an associated NON-NULL reference. // Throw a forward request exception. CORBA::Object_ptr dup = CORBA::Object::_duplicate (object_reference); - + ACE_THROW_RETURN (PortableServer::ForwardRequest (dup), -1); } #endif - + // So, we read a request, now handle it using something more // primitive than a CORBA2 ServerRequest pseudo-object. @@ -313,11 +315,10 @@ TAO_Server_Connection_Handler::handle_message (TAO_InputCDR &input, // with a single write so that they're not accidentally interleaved // over the transport (as could happen using TCP). - this->orb_core_->root_poa ()->dispatch_servant (request.object_key (), - request, - 0, - this->orb_core_, - ACE_TRY_ENV); + this->orb_core_->object_adapter ()->dispatch_servant (request.object_key (), + request, + 0, + ACE_TRY_ENV); // NEED TO CHECK FOR any errors present in <env> and set the return // code appropriately. ACE_CHECK_RETURN (-1); @@ -351,8 +352,6 @@ TAO_Server_Connection_Handler::handle_locate (TAO_InputCDR &input, request_id = locateRequestHeader.request_id; response_required = 1; - TAO_POA *the_poa = this->orb_core_->root_poa (); - char repbuf[ACE_CDR::DEFAULT_BUFSIZE]; TAO_OutputCDR dummy_output (repbuf, sizeof(repbuf)); // This output CDR is not used! @@ -406,11 +405,10 @@ TAO_Server_Connection_Handler::handle_locate (TAO_InputCDR &input, this->orb_core_, env); - the_poa->dispatch_servant (serverRequest.object_key (), - serverRequest, - 0, - this->orb_core_, - env); + this->orb_core_->object_adapter ()->dispatch_servant (serverRequest.object_key (), + serverRequest, + 0, + env); if (serverRequest.exception_type () == TAO_GIOP_NO_EXCEPTION && env.exception () == 0) @@ -782,7 +780,7 @@ TAO_Server_Connection_Handler::handle_input (ACE_HANDLE) } // @@ For pluggable protocols, added a reference to the corresponding -// transport obj. +// transport obj. TAO_Client_Connection_Handler::TAO_Client_Connection_Handler (ACE_Thread_Manager *t) : TAO_IIOP_Handler_Base (t == 0 ? TAO_ORB_Core_instance ()->thr_mgr () : t), expecting_response_ (0), @@ -917,7 +915,7 @@ TAO_Client_Connection_Handler::check_unexpected_data (void) // -1 is a somewhat ugly shutdown // // Both will result in us returning -1 and this connection - // getting closed + // getting closed // if (TAO_orbdebug) ACE_DEBUG ((LM_WARNING, diff --git a/TAO/tao/Key_Adapters.cpp b/TAO/tao/Key_Adapters.cpp new file mode 100644 index 00000000000..427f7053231 --- /dev/null +++ b/TAO/tao/Key_Adapters.cpp @@ -0,0 +1,140 @@ +// $Id$ + +#include "tao/Key_Adapters.h" + +#if !defined (__ACE_INLINE__) +# include "tao/Key_Adapters.i" +#endif /* __ACE_INLINE__ */ + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Incremental_Key_Generator::TAO_Incremental_Key_Generator (void) + : counter_ (0) +{ +} + +int +TAO_Incremental_Key_Generator::operator() (PortableServer::ObjectId &id) +{ + // Resize to accommodate the counter. + id.length (sizeof this->counter_); + + // Add new key data. + ACE_OS::memcpy (id.get_buffer (), + &++this->counter_, + sizeof this->counter_); + + // Success. + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// + +u_long +TAO_ObjectId_Hash::operator () (const PortableServer::ObjectId &id) const +{ + return ACE::hash_pjw ((const char *) id.get_buffer (), + id.length ()); +} + +//////////////////////////////////////////////////////////////////////////////// + +int +TAO_Ignore_Original_Key_Adapter::encode (const PortableServer::ObjectId &original_key, + const ACE_Active_Map_Manager_Key &active_key, + PortableServer::ObjectId &modified_key) +{ + // Size of active key. + size_t active_key_size = active_key.size (); + + // Resize to accommodate both the original data and the new active key. + modified_key.length (active_key_size); + + // Copy active key data into user key. + active_key.encode (modified_key.get_buffer ()); + + // Success. + return 0; +} + +int +TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, + ACE_Active_Map_Manager_Key &active_key) +{ + // Read off value of index and generation. + active_key.decode (modified_key.get_buffer ()); + + // Success. + return 0; +} + +int +TAO_Ignore_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, + PortableServer::ObjectId &original_key) +{ + // Smartly copy all the data; <original_key does not own the data>. + original_key.replace (modified_key.maximum (), + modified_key.length (), + ACE_const_cast (CORBA::Octet *, + modified_key.get_buffer ()), + 0); + + // Success. + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// + +int +TAO_Preserve_Original_Key_Adapter::encode (const PortableServer::ObjectId &original_key, + const ACE_Active_Map_Manager_Key &active_key, + PortableServer::ObjectId &modified_key) +{ + // Size of active key. + size_t active_key_size = active_key.size (); + + // Resize to accommodate both the original data and the new active key. + modified_key.length (active_key_size + original_key.length ()); + + // Copy active key data into user key. + active_key.encode (modified_key.get_buffer ()); + + // Copy the original key after the active key. + ACE_OS::memcpy (modified_key.get_buffer () + active_key_size, + original_key.get_buffer (), + original_key.length ()); + + // Success. + return 0; +} + +int +TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, + ACE_Active_Map_Manager_Key &active_key) +{ + // Read off value of index and generation. + active_key.decode (modified_key.get_buffer ()); + + // Success. + return 0; +} + +int +TAO_Preserve_Original_Key_Adapter::decode (const PortableServer::ObjectId &modified_key, + PortableServer::ObjectId &original_key) +{ + // Size of active key. + size_t active_key_size = ACE_Active_Map_Manager_Key::size (); + + // Smartly copy all the data; <original_key does not own the data>. + original_key.replace (modified_key.maximum () - active_key_size, + modified_key.length () - active_key_size, + ACE_const_cast (CORBA::Octet *, + modified_key.get_buffer ()) + active_key_size, + 0); + + // Success. + return 0; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/TAO/tao/Key_Adapters.h b/TAO/tao/Key_Adapters.h new file mode 100644 index 00000000000..9994c8878ee --- /dev/null +++ b/TAO/tao/Key_Adapters.h @@ -0,0 +1,127 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// Key_Adapters.h +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + +#ifndef TAO_KEY_ADAPTERS_H +#define TAO_KEY_ADAPTERS_H + +#include "tao/corbafwd.h" +#include "ace/Map.h" +#include "tao/POAC.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +//////////////////////////////////////////////////////////////////////////////// + +class TAO_Incremental_Key_Generator +{ + // = TITLE + // Defines a key generator. + // + // = DESCRIPTION + // This class is used in adapters of maps that do not produce keys. +public: + + TAO_Incremental_Key_Generator (void); + + int operator() (PortableServer::ObjectId &id); + +protected: + + CORBA::ULong counter_; +}; + +//////////////////////////////////////////////////////////////////////////////// + +class TAO_Export TAO_ObjectId_Hash +{ + // = TITLE + // Hashing class for Object Ids. + // + // = DESCRIPTION + // Define the hash() method for Object Ids. +public: + + u_long operator () (const PortableServer::ObjectId &id) const; + // Returns hash value. +}; + +//////////////////////////////////////////////////////////////////////////////// + +class TAO_Ignore_Original_Key_Adapter +{ + // = TITLE + // A key adapter (encode/decode) class. + // + // = DESCRIPTION + // Define the encoding and decoding methods for converting + // between Object Ids and active keys. This class ignores the + // <original_key> passed to it. +public: + + int encode (const PortableServer::ObjectId &original_key, + const ACE_Active_Map_Manager_Key &active_key, + PortableServer::ObjectId &modified_key); + + int decode (const PortableServer::ObjectId &modified_key, + ACE_Active_Map_Manager_Key &active_key); + + int decode (const PortableServer::ObjectId &modified_key, + PortableServer::ObjectId &original_key); +}; + +//////////////////////////////////////////////////////////////////////////////// + +class TAO_Preserve_Original_Key_Adapter +{ + // = TITLE + // A key adapter (encode/decode) class. + // + // = DESCRIPTION + // Define the encoding and decoding methods for converting + // between Object Ids and active keys. This class remembers the + // <original_key> passed to it. +public: + + int encode (const PortableServer::ObjectId &original_key, + const ACE_Active_Map_Manager_Key &active_key, + PortableServer::ObjectId &modified_key); + + int decode (const PortableServer::ObjectId &modified_key, + ACE_Active_Map_Manager_Key &active_key); + + int decode (const PortableServer::ObjectId &modified_key, + PortableServer::ObjectId &original_key); +}; + +//////////////////////////////////////////////////////////////////////////////// + +// Comparison of Object Ids. Defined in Stub.cpp for TAO_opaque (an +// alias of PortableServer::ObjectId). +extern TAO_Export int operator== (const PortableServer::ObjectId &l, + const PortableServer::ObjectId &r); + +extern TAO_Export int operator!= (const PortableServer::ObjectId &l, + const PortableServer::ObjectId &r); + +//////////////////////////////////////////////////////////////////////////////// + +#if defined (__ACE_INLINE__) +# include "tao/Key_Adapters.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_KEY_ADAPTERS_H */ diff --git a/TAO/tao/Key_Adapters.i b/TAO/tao/Key_Adapters.i new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/tao/Key_Adapters.i @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/tao/Makefile b/TAO/tao/Makefile index 79238bbcda9..c7de6ba12e7 100644 --- a/TAO/tao/Makefile +++ b/TAO/tao/Makefile @@ -30,6 +30,8 @@ PUB_HDRS = \ ORB_Core POA_FILES = \ + Object_Adapter \ + Key_Adapters \ POA \ POAC \ POAS \ diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp index 889128e9168..7446404e0fe 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -815,11 +815,11 @@ CORBA_ORB::resolve_initial_references (CORBA::String name, // Get the table of initial references specified through -ORBInitRef. TAO_IOR_LookupTable *table = this->orb_core_->orb_params ()->ior_lookup_table (); - + ACE_CString ior; ACE_CString object_id ((const char *) name); - - // Is the service name in the IOR Table. + + // Is the service name in the IOR Table. if (table->find_ior (object_id, ior) == 0) return this->string_to_object (ior.c_str (), TAO_IN_ENV); else @@ -828,15 +828,15 @@ CORBA_ORB::resolve_initial_references (CORBA::String name, // -ORBDefaultInitRef. char * default_init_ref = this->orb_core_->orb_params ()->default_init_ref (); - + // Check if a DefaultInitRef was specified. if (ACE_OS::strlen (default_init_ref) != 0) { ACE_CString list_of_profiles; - + // Used by the strtok_r. char *lasts = 0; - + // Append the given object ID to all the end-points of // Default Init Ref. for (char *str = ACE_OS::strtok_r (default_init_ref, @@ -852,17 +852,17 @@ CORBA_ORB::resolve_initial_references (CORBA::String name, list_of_profiles += object_id; list_of_profiles += ACE_CString (","); } - + // Clean up. delete [] default_init_ref; - + // Replace the last extra comma with a null. list_of_profiles[list_of_profiles.length () - 1] = '\0'; - + return this->string_to_object (list_of_profiles.c_str (), TAO_IN_ENV); } - + delete default_init_ref; } @@ -1474,7 +1474,7 @@ CORBA_ORB::iioploc_string_to_object (const char *string, // Count the No. of profiles in the given list. int profile_count = 1; - + for (size_t i = 0; i < ACE_OS::strlen (list_of_profiles); i++) @@ -1482,41 +1482,41 @@ CORBA_ORB::iioploc_string_to_object (const char *string, if (*(list_of_profiles + i) == ',') profile_count++; } - + TAO_MProfile mp (profile_count); - + // Extract the comma separated profiles in the list and // populate the Multiple Profile. TAO_IIOP_Profile *pfile; char *lasts = 0; - + for (char *str = ACE_OS::strtok_r (list_of_profiles, ",", &lasts); str != 0 ; str = ACE_OS::strtok_r (0, ",",&lasts)) - + { ACE_NEW_RETURN (pfile, TAO_IIOP_Profile (str, env), CORBA::Object::_nil ()); - + // Give up ownership of the profile. mp.give_profile (pfile); } - + // Dont need the list of profiles any more. ACE_OS::free (list_of_profiles); - + // Now make the TAO_Stub ... TAO_Stub *data; ACE_NEW_RETURN (data, TAO_Stub ((char *) 0, &mp, this->orb_core_), CORBA::Object::_nil ()); - + // Create the CORBA level proxy. TAO_ServantBase *servant = this->_get_collocated_servant (data); - + // This will increase the ref_count on data by one ACE_NEW_RETURN (obj, CORBA_Object (data, @@ -1631,22 +1631,22 @@ CORBA_ORB::_get_collocated_servant (TAO_Stub *sobj) // a server that is restarted with more endpoints (or // less), shouldn't old, persistent IORs, still be treated // as collocated? - TAO_POA *poa = 0; + TAO_Object_Adapter *object_adapter = 0; if (pfile->tag () == TAO_IOP_TAG_INTERNET_IOP) { const ACE_INET_Addr &addr = - ACE_dynamic_cast (TAO_IIOP_Profile*,pfile)->object_addr(); + ACE_dynamic_cast (TAO_IIOP_Profile *, pfile)->object_addr (); - poa = this->orb_core_->get_collocated_poa (addr); + object_adapter = this->orb_core_->get_collocated_object_adapter (addr); } else ACE_ERROR ((LM_ERROR, "get_collocated_poa NOT Supported for NON-IIOP profile!\n")); - if (poa != 0) + if (object_adapter != 0) { PortableServer::Servant servant = - poa->find_servant (objkey.in (), env); + object_adapter->find_servant (objkey.in (), env); if (env.exception ()) { #if 0 @@ -1685,15 +1685,15 @@ CORBA_ORB::_tao_add_to_IOR_table (ACE_CString &object_id, ACE_ERROR_RETURN ((LM_ERROR, "Unable to add IOR to table\n"), -1); - + CORBA::String_var string = this->object_to_string (obj); - + if (string.in () == 0 || string.in ()[0] == '\0') return -1; - + ACE_CString ior (string.in ()); - + if (this->lookup_table_.add_ior (object_id, ior) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Unable to add IOR to table\n"), @@ -1708,14 +1708,14 @@ CORBA_ORB::_tao_find_in_IOR_table (ACE_CString &object_id, CORBA::Object_ptr &obj) { ACE_CString ior; - + if (this->lookup_table_.find_ior (object_id, ior) != 0) ACE_ERROR_RETURN ((LM_ERROR, "No match for the given ObjectID\n"), -1); - + obj = this->string_to_object (ior.c_str ()); - + return 0; } diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 661e5e93c91..b6732d645e0 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -92,13 +92,13 @@ TAO_ORB_Core::add_to_ior_table (ACE_CString init_ref, TAO_IOR_LookupTable &table ACE_ERROR_RETURN ((LM_ERROR, "Unable to parse -ORBInitRef parameter\n"), -1); - + ACE_CString object_id = init_ref.substr (0,index); ACE_CString ior = init_ref.substr (index+1); - + // Add the objectID-IOR to the table and return the status. return table.add_ior (object_id, ior); - + } int @@ -898,7 +898,7 @@ TAO_ORB_Core::create_and_set_root_poa (const char *adapter_name, // Need to do double-checked locking here to cover the case of // multiple threads using a global resource policy. if (poa_manager == 0) - poa_manager = new TAO_POA_Manager; + poa_manager = new TAO_POA_Manager (this->object_adapter ()->lock ()); TAO_POA_Policies *root_poa_policies = 0; if (policies == 0) @@ -916,6 +916,8 @@ TAO_ORB_Core::create_and_set_root_poa (const char *adapter_name, *poa_manager, *policies, 0, + this->object_adapter ()->lock (), + *this, env); if (delete_policies) @@ -933,27 +935,29 @@ TAO_ORB_Core::add_to_collocation_table (void) { TAO_GLOBAL_Collocation_Table *collocation_table = this->resource_factory ()->get_global_collocation_table (); if (collocation_table != 0) - return collocation_table->bind (this->orb_params ()->addr (), this->root_poa ()); + return collocation_table->bind (this->orb_params ()->addr (), + this->object_adapter ()); } return 0; } -TAO_POA * -TAO_ORB_Core::get_collocated_poa (const ACE_INET_Addr &addr) +TAO_Object_Adapter * +TAO_ORB_Core::get_collocated_object_adapter (const ACE_INET_Addr &addr) { if (this->using_collocation ()) { TAO_GLOBAL_Collocation_Table *collocation_table = this->resource_factory ()->get_global_collocation_table (); if (collocation_table != 0) { - TAO_POA *poa; - if (collocation_table->find (addr, poa) == 0) - return poa; + TAO_Object_Adapter *object_adapter; + if (collocation_table->find (addr, + object_adapter) == 0) + return object_adapter; } else { if (addr == this->orb_params ()->addr ()) - return this->root_poa (); + return this->object_adapter (); } } return 0; @@ -1276,6 +1280,7 @@ rtype TAO_Resource_Factory::methodname(void)\ return 0;\ } +IMPLEMENT_PRE_GET_METHOD(object_adapter, TAO_Object_Adapter *, object_adapter_) IMPLEMENT_PRE_GET_METHOD(get_reactor, ACE_Reactor *, r_) IMPLEMENT_PRE_GET_METHOD(get_thr_mgr, ACE_Thread_Manager *, tm_) IMPLEMENT_PRE_GET_METHOD(get_acceptor, TAO_Acceptor *, a_) @@ -1538,7 +1543,9 @@ TAO_Resource_Factory::get_global_collocation_table (void) } TAO_Resource_Factory::Pre_Allocated::Pre_Allocated (void) - : r_ (TAO_ORB_CORE::instance ()->resource_factory ()->reactor_lock ()), + : object_adapter_ (TAO_ORB_CORE::instance ()->server_factory ()->active_object_map_creation_parameters (), + *TAO_ORB_CORE::instance ()), + r_ (TAO_ORB_CORE::instance ()->resource_factory ()->reactor_lock ()), cached_connect_strategy_ (TAO_ORB_CORE::instance ()->client_factory ()->create_client_creation_strategy ()) { // Make sure that the thread manager does not wait for threads @@ -1680,16 +1687,16 @@ template class ACE_TSS<TAO_Resource_Factory::Pre_Allocated>; template class ACE_Singleton<TAO_Resource_Factory::App_Allocated, ACE_SYNCH_MUTEX>; template class ACE_TSS_Singleton<TAO_Resource_Factory::App_Allocated, ACE_SYNCH_MUTEX>; template class ACE_TSS<TAO_Resource_Factory::App_Allocated>; -template class ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Manager_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Entry<ACE_INET_Addr, TAO_POA *>; +template class ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Manager_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Entry<ACE_INET_Addr, TAO_Object_Adapter *>; template class ACE_Hash<ACE_INET_Addr>; template class ACE_Equal_To<ACE_INET_Addr>; -template class ACE_Hash_Map_Iterator_Base_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Iterator<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Reverse_Iterator<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Iterator<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Reverse_Iterator<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock>; template class ACE_Guard<TAO_Collocation_Table_Lock>; template class ACE_Read_Guard<TAO_Collocation_Table_Lock>; template class ACE_Write_Guard<TAO_Collocation_Table_Lock>; @@ -1738,16 +1745,16 @@ template class ACE_Select_Reactor_T< ACE_Select_Reactor_Token_T<ACE_Noop_Token> #pragma instantiate ACE_Singleton<TAO_Resource_Factory::App_Allocated, ACE_SYNCH_MUTEX> #pragma instantiate ACE_TSS_Singleton<TAO_Resource_Factory::App_Allocated, ACE_SYNCH_MUTEX> #pragma instantiate ACE_TSS<TAO_Resource_Factory::App_Allocated> -#pragma instantiate ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Entry<ACE_INET_Addr, TAO_POA *> +#pragma instantiate ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Entry<ACE_INET_Addr, TAO_Object_Adapter *> #pragma instantiate ACE_Hash<ACE_INET_Addr> #pragma instantiate ACE_Equal_To<ACE_INET_Addr> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Iterator<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_POA *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_INET_Addr, TAO_Object_Adapter *, ACE_Hash<ACE_INET_Addr>, ACE_Equal_To<ACE_INET_Addr>, TAO_Collocation_Table_Lock> #pragma instantiate ACE_Guard<TAO_Collocation_Table_Lock> #pragma instantiate ACE_Read_Guard<TAO_Collocation_Table_Lock> #pragma instantiate ACE_Write_Guard<TAO_Collocation_Table_Lock> diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 320d06abffd..8f72d2678dd 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -27,6 +27,7 @@ #include "tao/POAC.h" #include "tao/POA.h" #include "tao/POAManager.h" +#include "tao/Object_Adapter.h" #include "tao/params.h" @@ -56,7 +57,7 @@ public: }; // @@ Will this work, changing ACE_INET_Addr to ACE_Addr?? -typedef ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_POA *, TAO_Collocation_Table_Lock> +typedef ACE_Hash_Map_Manager<ACE_INET_Addr, TAO_Object_Adapter *, TAO_Collocation_Table_Lock> TAO_GLOBAL_Collocation_Table; class TAO_Cached_Connector_Lock : public ACE_Adaptive_Lock @@ -162,7 +163,7 @@ public: ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *tm); ACE_Thread_Manager *thr_mgr (void); - // = Set/get <Acceptor> for the POA. + // = Set/get <rootPOA>. TAO_POA *root_poa (TAO_POA *np); TAO_POA *root_poa (const char *adapter_name = TAO_DEFAULT_ROOTPOA_NAME, TAO_POA_Manager *poa_manager = 0, @@ -172,6 +173,9 @@ public: TAO_POA_Manager *poa_manager = 0, const TAO_POA_Policies *policies = 0); + TAO_Object_Adapter *object_adapter (void); + // Get <Object Adapter>. + int inherit_from_parent_thread (TAO_ORB_Core *p); // A spawned thread needs to inherit some properties/objects from // the spawning thread in order to serve requests. Return 0 if @@ -202,7 +206,7 @@ public: int add_to_collocation_table (void); // Added this ORB into collocation table. - TAO_POA *get_collocated_poa (const ACE_INET_Addr &addr); + TAO_Object_Adapter *get_collocated_object_adapter (const ACE_INET_Addr &addr); // See if we have a collocated address, if yes, return the POA // associated with the address. @@ -524,6 +528,9 @@ public: virtual TAO_POA *get_root_poa (void); // Return a root poa to be utilized. + virtual TAO_Object_Adapter *object_adapter (void); + // Return a object adapter to be utilized. + virtual ACE_Allocator *get_allocator (void); // Return a pointer to an ACE_Allocator used for allocating memory // within the ORB. @@ -587,6 +594,9 @@ public: TAO_Default_Reactor r_; // The Reactor. + TAO_Object_Adapter object_adapter_; + // Object Adapter. + ACE_Thread_Manager tm_; // The Thread Manager diff --git a/TAO/tao/ORB_Core.i b/TAO/tao/ORB_Core.i index 9b8515265f9..f22fccd68bd 100644 --- a/TAO/tao/ORB_Core.i +++ b/TAO/tao/ORB_Core.i @@ -14,12 +14,18 @@ TAO_ORB_Core::reactor (ACE_Reactor *r) return old_reactor; } -ACE_INLINE ACE_Reactor* +ACE_INLINE ACE_Reactor * TAO_ORB_Core::reactor (void) { return TAO_OC_RETRIEVE (reactor); } +ACE_INLINE TAO_Object_Adapter * +TAO_ORB_Core::object_adapter (void) +{ + return this->resource_factory ()->object_adapter (); +} + ACE_INLINE ACE_Thread_Manager * TAO_ORB_Core::thr_mgr (ACE_Thread_Manager *tm) { diff --git a/TAO/tao/Object_Adapter.cpp b/TAO/tao/Object_Adapter.cpp new file mode 100644 index 00000000000..55be416a0cd --- /dev/null +++ b/TAO/tao/Object_Adapter.cpp @@ -0,0 +1,873 @@ +// $Id$ + +#include "tao/Object_Adapter.h" +#include "tao/POA.h" +#include "tao/ORB.h" +#include "tao/ORB_Core.h" +#include "tao/Server_Request.h" +#include "ace/Auto_Ptr.h" + +#if !defined (__ACE_INLINE__) +# include "tao/Object_Adapter.i" +#endif /* __ACE_INLINE__ */ + +//////////////////////////////////////////////////////////////////////////////// + +/* static */ +size_t TAO_Object_Adapter::transient_poa_name_size_ (0); + +void +TAO_Object_Adapter::set_transient_poa_name_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters) +{ + if (TAO_Object_Adapter::transient_poa_name_size_ == 0) + { + switch (creation_parameters.poa_lookup_strategy_for_transient_id_policy_) + { + case TAO_LINEAR: + + TAO_Object_Adapter::transient_poa_name_size_ = sizeof (CORBA::ULong); + break; + + case TAO_DYNAMIC_HASH: + + TAO_Object_Adapter::transient_poa_name_size_ = sizeof (CORBA::ULong); + break; + + case TAO_ACTIVE_DEMUX: + default: + + TAO_Object_Adapter::transient_poa_name_size_ = ACE_Active_Map_Manager_Key::size (); + break; + } + } +} + +TAO_Object_Adapter::TAO_Object_Adapter (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters, + TAO_ORB_Core &orb_core) + : hint_strategy_ (0), + persistent_poa_name_map_ (0), + transient_poa_map_ (0), + orb_core_ (orb_core), + lock_ (orb_core.server_factory ()->create_poa_lock ()) +{ + TAO_Object_Adapter::set_transient_poa_name_size (creation_parameters); + + Hint_Strategy *hint_strategy = 0; + if (creation_parameters.use_active_hint_in_poa_names_) + { + ACE_NEW (hint_strategy, + Active_Hint_Strategy (creation_parameters.poa_map_size_)); + } + else + { + ACE_NEW (hint_strategy, + No_Hint_Strategy); + } + // Give ownership to the auto pointer. + auto_ptr<Hint_Strategy> new_hint_strategy (hint_strategy); + + new_hint_strategy->object_adapter (this); + + persistent_poa_name_map *ppnm; + switch (creation_parameters.poa_lookup_strategy_for_persistent_id_policy_) + { + case TAO_LINEAR: + + ACE_NEW (ppnm, + persistent_poa_name_linear_map (creation_parameters.poa_map_size_)); + break; + + case TAO_DYNAMIC_HASH: + default: + + ACE_NEW (ppnm, + persistent_poa_name_hash_map (creation_parameters.poa_map_size_)); + break; + } + // Give ownership to the auto pointer. + auto_ptr<persistent_poa_name_map> new_persistent_poa_name_map (ppnm); + + transient_poa_map *tpm = 0; + switch (creation_parameters.poa_lookup_strategy_for_transient_id_policy_) + { + case TAO_LINEAR: + + ACE_NEW (tpm, + transient_poa_linear_map (creation_parameters.poa_map_size_)); + break; + + case TAO_DYNAMIC_HASH: + + ACE_NEW (tpm, + transient_poa_hash_map (creation_parameters.poa_map_size_)); + break; + + case TAO_ACTIVE_DEMUX: + default: + + ACE_NEW (tpm, + transient_poa_active_map (creation_parameters.poa_map_size_)); + break; + } + // Give ownership to the auto pointer. + auto_ptr<transient_poa_map> new_transient_poa_map (tpm); + + this->hint_strategy_ = new_hint_strategy.release (); + this->persistent_poa_name_map_ = new_persistent_poa_name_map.release (); + this->transient_poa_map_ = new_transient_poa_map.release (); +} + +TAO_Object_Adapter::~TAO_Object_Adapter (void) +{ + delete this->hint_strategy_; + delete this->persistent_poa_name_map_; + delete this->transient_poa_map_; + delete this->lock_; +} + +/* static */ +CORBA::ULong +TAO_Object_Adapter::transient_poa_name_size () +{ + return TAO_Object_Adapter::transient_poa_name_size_; +} + +int +TAO_Object_Adapter::locate_servant (const TAO_ObjectKey &key, + CORBA::Environment &ACE_TRY_ENV) +{ + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), -1, ACE_TRY_ENV); + + return this->locate_servant_i (key, + ACE_TRY_ENV); +} + +int +TAO_Object_Adapter::locate_servant_i (const TAO_ObjectKey &key, + CORBA::Environment &ACE_TRY_ENV) +{ + PortableServer::ObjectId id; + TAO_POA *poa = 0; + + this->locate_poa (key, + id, + poa, + ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + PortableServer::Servant servant = 0; + TAO_POA::LOCATION_RESULT result = poa->locate_servant_i (id, + servant, + ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + switch (result) + { + case TAO_POA::FOUND: + // Optimistic attitude + case TAO_POA::DEFAULT_SERVANT: + case TAO_POA::SERVANT_MANAGER: + return 0; + + case TAO_POA::NOT_FOUND: + return -1; + } + + return -1; +} + +PortableServer::Servant +TAO_Object_Adapter::find_servant (const TAO_ObjectKey &key, + CORBA::Environment &ACE_TRY_ENV) +{ + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); + + return this->find_servant_i (key, + ACE_TRY_ENV); +} + +PortableServer::Servant +TAO_Object_Adapter::find_servant_i (const TAO_ObjectKey &key, + CORBA::Environment &ACE_TRY_ENV) +{ + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); + + PortableServer::ObjectId id; + TAO_POA *poa = 0; + + this->locate_poa (key, + id, + poa, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + PortableServer::Servant servant = 0; + TAO_POA::LOCATION_RESULT result = poa->locate_servant_i (id, + servant, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + switch (result) + { + case TAO_POA::FOUND: + return servant; + + case TAO_POA::DEFAULT_SERVANT: + case TAO_POA::SERVANT_MANAGER: + case TAO_POA::NOT_FOUND: + return 0; + } + + return 0; +} + +void +TAO_Object_Adapter::dispatch_servant (const TAO_ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA::Environment &ACE_TRY_ENV) +{ + // ACE_FUNCTION_TIMEPROBE (TAO_POA_DISPATCH_SERVANT_START); + + // Lock access to the POA for the duration of this transaction + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); + + this->dispatch_servant_i (key, + req, + context, + ACE_TRY_ENV); +} + +void +TAO_Object_Adapter::dispatch_servant_i (const TAO_ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA_Environment &ACE_TRY_ENV) +{ + PortableServer::ObjectId id; + TAO_POA *poa = 0; + + this->locate_poa (key, + id, + poa, + ACE_TRY_ENV); + ACE_CHECK; + + // Setup for POA Current + const char *operation = req.operation (); + TAO_POA_Current current_context (poa, + key, + id, + 0, + operation, + this->orb_core_); + + PortableServer::Servant servant = poa->locate_servant_i (operation, + id, + ¤t_context, + ACE_TRY_ENV); + ACE_CHECK; + + // Now that we know the servant. + current_context.servant (servant); + + { + // ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_DISPATCH_START); + + // Upcall + servant->_dispatch (req, + context, + ACE_TRY_ENV); + ACE_CHECK; + } +} + +void +TAO_Object_Adapter::locate_poa (const TAO_ObjectKey &key, + PortableServer::ObjectId &id, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + TAO_Object_Adapter::poa_name poa_system_name; + CORBA::Boolean persistent = 0; + CORBA::Boolean system_id = 0; + TAO_Temporary_Creation_Time poa_creation_time; + + int result = TAO_POA::parse_key (key, + poa_system_name, + id, + persistent, + system_id, + poa_creation_time); + if (result != 0) + { + ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)); + } + + result = this->find_poa (poa_system_name, + persistent, + poa_creation_time, + poa, + ACE_TRY_ENV); + + if (result != 0) + { + ACE_THROW (CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO)); + } +} + +int +TAO_Object_Adapter::find_poa (const poa_name &system_name, + CORBA::Boolean activate_it, + const TAO_Temporary_Creation_Time &poa_creation_time, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + if (activate_it) + { + return this->find_persistent_poa (system_name, + poa, + ACE_TRY_ENV); + } + else + { + return this->find_transient_poa (system_name, + poa_creation_time, + poa); + } +} + +int +TAO_Object_Adapter::find_transient_poa (const poa_name &system_name, + const TAO_Temporary_Creation_Time &poa_creation_time, + TAO_POA *&poa) +{ + int result = this->transient_poa_map_->find (system_name, + poa); + + if (result == 0) + { + if (poa->creation_time () != poa_creation_time) + { + result = -1; + } + } + + return result; +} + +int +TAO_Object_Adapter::find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + return this->hint_strategy_->find_persistent_poa (system_name, + poa, + ACE_TRY_ENV); +} + +int +TAO_Object_Adapter::bind_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name) +{ + if (poa->persistent ()) + { + return this->bind_persistent_poa (folded_name, + poa, + system_name); + } + else + { + return this->bind_transient_poa (poa, + system_name); + } +} + +int +TAO_Object_Adapter::bind_transient_poa (TAO_POA *poa, + poa_name_out system_name) +{ + poa_name name; + int result = this->transient_poa_map_->bind_create_key (poa, + name); + + if (result == 0) + { + ACE_NEW_RETURN (system_name, + poa_name (name), + -1); + } + + return result; +} + +int +TAO_Object_Adapter::bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name) +{ + return this->hint_strategy_->bind_persistent_poa (folded_name, + poa, + system_name); +} + +int +TAO_Object_Adapter::unbind_poa (TAO_POA *poa, + const poa_name &folded_name, + const poa_name &system_name) +{ + if (poa->persistent ()) + { + return this->unbind_persistent_poa (folded_name, + system_name); + } + else + { + return this->unbind_transient_poa (system_name); + } +} + +int +TAO_Object_Adapter::unbind_transient_poa (const poa_name &system_name) +{ + return this->transient_poa_map_->unbind (system_name); +} + +int +TAO_Object_Adapter::unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name) +{ + return this->hint_strategy_->unbind_persistent_poa (folded_name, + system_name); +} + +int +TAO_Object_Adapter::activate_poa (const poa_name &folded_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + int result = -1; + +#if !defined (TAO_HAS_MINIMUM_CORBA) + + iteratable_poa_name ipn (folded_name); + iteratable_poa_name::iterator iterator = ipn.begin (); + iteratable_poa_name::iterator end = ipn.end (); + + TAO_POA *parent = this->orb_core_.root_poa (); + if (parent->name () != *iterator) + { + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO), + -1); + } + else + { + ++iterator; + } + + for (; + iterator != end; + ++iterator) + { + TAO_POA *current = parent->find_POA_i (*iterator, + 1, + ACE_TRY_ENV); + ACE_CHECK_RETURN (-1); + + parent = current; + } + + poa = parent; + result = 0; + +#endif /* TAO_HAS_MINIMUM_CORBA */ + + return result; +} + +ACE_Lock & +TAO_Object_Adapter::lock (void) +{ + return *this->lock_; +} + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Object_Adapter::Hint_Strategy::~Hint_Strategy (void) +{ +} + +void +TAO_Object_Adapter::Hint_Strategy::object_adapter (TAO_Object_Adapter *oa) +{ + this->object_adapter_ = oa; +} + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Object_Adapter::Active_Hint_Strategy::Active_Hint_Strategy (CORBA::ULong map_size) + : persistent_poa_system_map_ (map_size) +{ +} + +TAO_Object_Adapter::Active_Hint_Strategy::~Active_Hint_Strategy (void) +{ +} + +int +TAO_Object_Adapter::Active_Hint_Strategy::find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + poa_name folded_name; + int result = this->persistent_poa_system_map_.recover_key (system_name, + folded_name); + + if (result == 0) + { + result = this->persistent_poa_system_map_.find (system_name, + poa); + if (result != 0 || + folded_name != poa->folded_name ()) + { + result = this->object_adapter_->persistent_poa_name_map_->find (folded_name, + poa); + if (result != 0) + { + result = this->object_adapter_->activate_poa (folded_name, + poa, + ACE_TRY_ENV); + } + } + } + + return result; +} + +int +TAO_Object_Adapter::Active_Hint_Strategy::bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name) +{ + poa_name name = folded_name; + int result = this->persistent_poa_system_map_.bind_modify_key (poa, + name); + + if (result == 0) + { + result = this->object_adapter_->persistent_poa_name_map_->bind (folded_name, + poa); + + if (result != 0) + { + this->persistent_poa_system_map_.unbind (name); + } + else + { + ACE_NEW_RETURN (system_name, + poa_name (name), + -1); + } + } + + return result; +} + +int +TAO_Object_Adapter::Active_Hint_Strategy::unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name) +{ + int result = this->persistent_poa_system_map_.unbind (system_name); + + if (result == 0) + { + result = this->object_adapter_->persistent_poa_name_map_->unbind (folded_name); + } + + return result; +} + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Object_Adapter::No_Hint_Strategy::~No_Hint_Strategy (void) +{ +} + +int +TAO_Object_Adapter::No_Hint_Strategy::find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) +{ + int result = this->object_adapter_->persistent_poa_name_map_->find (system_name, + poa); + if (result != 0) + { + result = this->object_adapter_->activate_poa (system_name, + poa, + ACE_TRY_ENV); + } + + return result; +} + +int +TAO_Object_Adapter::No_Hint_Strategy::bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name) +{ + int result = this->object_adapter_->persistent_poa_name_map_->bind (folded_name, + poa); + if (result == 0) + { + ACE_NEW_RETURN (system_name, + poa_name (folded_name), + -1); + } + + return result; +} + +int +TAO_Object_Adapter::No_Hint_Strategy::unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name) +{ + ACE_UNUSED_ARG (system_name); + + return this->object_adapter_->persistent_poa_name_map_->unbind (folded_name); +} + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Object_Adapter::poa_name_iterator::poa_name_iterator (int begin, + CORBA::ULong size, + const CORBA::Octet *folded_buffer) + : size_ (size), + folded_buffer_ (folded_buffer), + last_separator_ (~0) +{ + if (begin) + { + this->position_ = ~0; + this->operator++ (); + } + else + { + this->position_ = this->size_; + } +} + +int +TAO_Object_Adapter::poa_name_iterator::operator== (const poa_name_iterator &rhs) const +{ + return this->position_ == rhs.position_; +} + +int +TAO_Object_Adapter::poa_name_iterator::operator!= (const poa_name_iterator &rhs) const +{ + return !this->operator== (rhs); +} + +ACE_CString +TAO_Object_Adapter::poa_name_iterator::operator* () const +{ + CORBA::ULong start_at = + this->last_separator_ + + TAO_POA::name_separator_length (); + + CORBA::ULong how_many = + this->position_ - + this->last_separator_ - + TAO_POA::name_separator_length (); + + return ACE_CString (ACE_static_cast (const char *, + &this->folded_buffer_[start_at]), + how_many); +} + +TAO_Object_Adapter::poa_name_iterator & +TAO_Object_Adapter::poa_name_iterator::operator++ (void) +{ + this->last_separator_ = this->position_; + + while (1) + { + ++this->position_; + if (this->position_ < this->size_) + { + if (this->folded_buffer_[this->position_] == TAO_POA::name_separator ()) + { + break; + } + } + else + { + break; + } + } + + return *this; +} + +//////////////////////////////////////////////////////////////////////////////// + +TAO_Object_Adapter::iteratable_poa_name::iteratable_poa_name (const poa_name &folded_name) + : folded_name_ (folded_name) +{ +} + +TAO_Object_Adapter::iteratable_poa_name::iterator +TAO_Object_Adapter::iteratable_poa_name::begin (void) const +{ + return iterator (1, + this->folded_name_.length (), + this->folded_name_.get_buffer ()); +} + +TAO_Object_Adapter::iteratable_poa_name::iterator +TAO_Object_Adapter::iteratable_poa_name::end (void) const +{ + return iterator (0, + this->folded_name_.length (), + this->folded_name_.get_buffer ()); +} + +//////////////////////////////////////////////////////////////////////////////// + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class auto_ptr<TAO_Object_Adapter::Hint_Strategy>; +template class auto_ptr<TAO_Object_Adapter::persistent_poa_name_map>; +template class auto_ptr<TAO_Object_Adapter::transient_poa_map>; + +template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy>; +template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::persistent_poa_name_map>; +template class ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map>; + +// Common typedefs. +typedef TAO_Object_Adapter::poa_name key; +typedef TAO_POA *value; + +typedef ACE_Pair<key, value> expanded_value; +typedef ACE_Reference_Pair<const key, value> value_type; +typedef ACE_Equal_To<key> compare_keys; +typedef TAO_ObjectId_Hash hash_key; +typedef ACE_Noop_Key_Generator<key> noop_key_generator; + +// Common +template class ACE_Reference_Pair<const key, value>; + +// Map and iterator classes. +template class ACE_Map<key, value>; +template class ACE_Iterator<value_type>; +template class ACE_Reverse_Iterator<value_type>; + +// Iterator base classes. +template class ACE_Iterator_Impl<value_type>; +template class ACE_Reverse_Iterator_Impl<value_type>; + +// Active Map Manager related. +template class ACE_Pair<key, value>; +template class ACE_Active_Map_Manager_Adapter<key, value, TAO_Ignore_Original_Key_Adapter>; +template class ACE_Active_Map_Manager_Adapter<key, value, TAO_Preserve_Original_Key_Adapter>; +template class ACE_Active_Map_Manager_Iterator_Adapter<value_type, expanded_value>; +template class ACE_Active_Map_Manager_Reverse_Iterator_Adapter<value_type, expanded_value>; +template class ACE_Active_Map_Manager<expanded_value>; +template class ACE_Map_Manager<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>; +template class ACE_Map_Iterator_Base<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>; +template class ACE_Map_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>; +template class ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex>; +template class ACE_Map_Entry<ACE_Active_Map_Manager_Key, expanded_value>; + +// Hash Map Manager related. +template class ACE_Hash_Map_Manager_Ex_Adapter<key, value, hash_key, compare_keys, TAO_Incremental_Key_Generator>; +template class ACE_Hash_Map_Manager_Ex_Iterator_Adapter<value_type, key, value, hash_key, compare_keys>; +template class ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<value_type, key, value, hash_key, compare_keys>; +template class ACE_Hash_Map_Manager_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex>; +template class ACE_Hash_Map_Entry<key, value>; +template class ACE_Equal_To<key>; + +// Map Manager related. +template class ACE_Map_Manager_Iterator_Adapter<value_type, key, value>; +template class ACE_Map_Manager_Reverse_Iterator_Adapter<value_type, key, value>; +template class ACE_Map_Manager_Adapter<key, value, TAO_Incremental_Key_Generator>; +template class ACE_Map_Manager<key, value, ACE_Null_Mutex>; +template class ACE_Map_Iterator_Base<key, value, ACE_Null_Mutex>; +template class ACE_Map_Iterator<key, value, ACE_Null_Mutex>; +template class ACE_Map_Reverse_Iterator<key, value, ACE_Null_Mutex>; +template class ACE_Map_Entry<key, value>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate auto_ptr<TAO_Object_Adapter::Hint_Strategy> +#pragma instantiate auto_ptr<TAO_Object_Adapter::persistent_poa_name_map> +#pragma instantiate auto_ptr<TAO_Object_Adapter::transient_poa_map> + +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::Hint_Strategy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::persistent_poa_name_map> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Object_Adapter::transient_poa_map> + +// Common typedefs. +typedef TAO_Object_Adapter::poa_name key; +typedef TAO_POA *value; + +typedef ACE_Pair<key, value> expanded_value; +typedef ACE_Reference_Pair<const key, value> value_type; +typedef ACE_Equal_To<key> compare_keys; +typedef TAO_ObjectId_Hash hash_key; +typedef ACE_Noop_Key_Generator<key> noop_key_generator; + +// Common +#pragma instantiate ACE_Reference_Pair<const key, value> + +// Map and iterator classes. +#pragma instantiate ACE_Map<key, value> +#pragma instantiate ACE_Iterator<value_type> +#pragma instantiate ACE_Reverse_Iterator<value_type> + +// Iterator base classes. +#pragma instantiate ACE_Iterator_Impl<value_type> +#pragma instantiate ACE_Reverse_Iterator_Impl<value_type> + +// Active Map Manager related. +#pragma instantiate ACE_Pair<key, value> +#pragma instantiate ACE_Active_Map_Manager_Adapter<key, value, TAO_Ignore_Original_Key_Adapter> +#pragma instantiate ACE_Active_Map_Manager_Adapter<key, value, TAO_Preserve_Original_Key_Adapter> +#pragma instantiate ACE_Active_Map_Manager_Iterator_Adapter<value_type, expanded_value> +#pragma instantiate ACE_Active_Map_Manager_Reverse_Iterator_Adapter<value_type, expanded_value> +#pragma instantiate ACE_Active_Map_Manager<expanded_value> +#pragma instantiate ACE_Map_Manager<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator_Base<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Reverse_Iterator<ACE_Active_Map_Manager_Key, expanded_value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry<ACE_Active_Map_Manager_Key, expanded_value> + +// Hash Map Manager related. +#pragma instantiate ACE_Hash_Map_Manager_Ex_Adapter<key, value, hash_key, compare_keys, TAO_Incremental_Key_Generator> +#pragma instantiate ACE_Hash_Map_Manager_Ex_Iterator_Adapter<value_type, key, value, hash_key, compare_keys> +#pragma instantiate ACE_Hash_Map_Manager_Ex_Reverse_Iterator_Adapter<value_type, key, value, hash_key, compare_keys> +#pragma instantiate ACE_Hash_Map_Manager_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<key, value, hash_key, compare_keys, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Entry<key, value> +#pragma instantiate ACE_Equal_To<key> + +// Map Manager related. +#pragma instantiate ACE_Map_Manager_Iterator_Adapter<value_type, key, value> +#pragma instantiate ACE_Map_Manager_Reverse_Iterator_Adapter<value_type, key, value> +#pragma instantiate ACE_Map_Manager_Adapter<key, value, TAO_Incremental_Key_Generator> +#pragma instantiate ACE_Map_Manager<key, value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator_Base<key, value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Iterator<key, value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Reverse_Iterator<key, value, ACE_Null_Mutex> +#pragma instantiate ACE_Map_Entry<key, value> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/Object_Adapter.h b/TAO/tao/Object_Adapter.h new file mode 100644 index 00000000000..95cebbfcb58 --- /dev/null +++ b/TAO/tao/Object_Adapter.h @@ -0,0 +1,332 @@ +/* -*- C++ -*- */ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// Object_Adapter.h +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + +#ifndef TAO_OBJECT_ADAPTER_H +#define TAO_OBJECT_ADAPTER_H + +#include "tao/Key_Adapters.h" +#include "tao/Server_Strategy_Factory.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +//////////////////////////////////////////////////////////////////////////////// + +// Forward declaration +class TAO_POA; +class TAO_Temporary_Creation_Time; + +class TAO_Object_Adapter +{ + // = TITLE + // Defines the Object Adapter abstraction. + // + // = DESCRIPTION + // This class will be used as a facade for the POAs in a server +public: + + typedef PortableServer::ObjectId poa_name; + typedef PortableServer::ObjectId_var poa_name_var; + typedef PortableServer::ObjectId_out poa_name_out; + + TAO_Object_Adapter (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters, + TAO_ORB_Core &orb_core); + // Constructor. + + ~TAO_Object_Adapter (void); + // Destructor. + + void dispatch_servant (const TAO_ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA_Environment &ACE_TRY_ENV); + + int locate_servant (const TAO_ObjectKey &key, + CORBA_Environment &ACE_TRY_ENV); + + PortableServer::Servant find_servant (const TAO_ObjectKey &key, + CORBA_Environment &ACE_TRY_ENV); + + int find_poa (const poa_name &system_name, + CORBA::Boolean activate_it, + const TAO_Temporary_Creation_Time &poa_creation_time, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + int bind_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name); + + int unbind_poa (TAO_POA *poa, + const poa_name &folded_name, + const poa_name &system_name); + + int activate_poa (const poa_name &folded_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + ACE_Lock &lock (void); + + static CORBA::ULong transient_poa_name_size (void); + +protected: + + int locate_servant_i (const TAO_ObjectKey &key, + CORBA_Environment &ACE_TRY_ENV); + + PortableServer::Servant find_servant_i (const TAO_ObjectKey &key, + CORBA_Environment &ACE_TRY_ENV); + + void dispatch_servant_i (const TAO_ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA_Environment &ACE_TRY_ENV); + + void locate_poa (const TAO_ObjectKey &key, + PortableServer::ObjectId &id, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + int find_transient_poa (const poa_name &system_name, + const TAO_Temporary_Creation_Time &poa_creation_time, + TAO_POA *&poa); + + int find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + int bind_transient_poa (TAO_POA *poa, + poa_name_out system_name); + + int bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name); + + int unbind_transient_poa (const poa_name &system_name); + + int unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name); + + class Hint_Strategy + { + // = TITLE + // Base class for POA active hint strategy. + // + // = DESCRIPTION + // This class also provides for common structures used by all + // the derived classes. + public: + + virtual ~Hint_Strategy (void); + + virtual int find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV) = 0; + + virtual int bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name) = 0; + + virtual int unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name) = 0; + + void object_adapter (TAO_Object_Adapter *oa); + + protected: + + TAO_Object_Adapter *object_adapter_; + }; + + class Active_Hint_Strategy : public Hint_Strategy + { + // = TITLE + // This class uses active demux hint for POA active hint + // strategy. + // + // = DESCRIPTION + // This class will append an active hint to the POA name, + // making the POA lookups fast and predictable. + public: + + Active_Hint_Strategy (CORBA::ULong map_size); + + virtual ~Active_Hint_Strategy (void); + + virtual int find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + virtual int bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name); + + virtual int unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name); + + protected: + + typedef ACE_Active_Map_Manager_Adapter< + poa_name, + TAO_POA *, + TAO_Preserve_Original_Key_Adapter> persistent_poa_system_map; + + persistent_poa_system_map persistent_poa_system_map_; + }; + + class No_Hint_Strategy : public Hint_Strategy + { + // = TITLE + // This class doesn't use any hints for POA active hint + // strategy. + // + // = DESCRIPTION + // This class will simply use the POA names as is. And since + // no hint is added, the IORs will be smaller. + public: + + virtual ~No_Hint_Strategy (void); + + virtual int find_persistent_poa (const poa_name &system_name, + TAO_POA *&poa, + CORBA_Environment &ACE_TRY_ENV); + + virtual int bind_persistent_poa (const poa_name &folded_name, + TAO_POA *poa, + poa_name_out system_name); + + virtual int unbind_persistent_poa (const poa_name &folded_name, + const poa_name &system_name); + + }; + + Hint_Strategy *hint_strategy_; + + typedef ACE_Map< + poa_name, + TAO_POA *> transient_poa_map; + // Base class of the id map. + + typedef ACE_Hash_Map_Manager_Ex_Adapter< + poa_name, + TAO_POA *, + TAO_ObjectId_Hash, + ACE_Equal_To<poa_name>, + TAO_Incremental_Key_Generator> transient_poa_hash_map; + // Id hash map. + + typedef ACE_Map_Manager_Adapter< + poa_name, + TAO_POA *, + TAO_Incremental_Key_Generator> transient_poa_linear_map; + // Id linear map. + + typedef ACE_Active_Map_Manager_Adapter< + poa_name, + TAO_POA *, + TAO_Ignore_Original_Key_Adapter> transient_poa_active_map; + // Id active map. + + typedef ACE_Map< + poa_name, + TAO_POA *> persistent_poa_name_map; + // Base class of the name map. + + typedef ACE_Hash_Map_Manager_Ex_Adapter< + poa_name, + TAO_POA *, + TAO_ObjectId_Hash, + ACE_Equal_To<PortableServer::ObjectId>, + ACE_Noop_Key_Generator<poa_name> > persistent_poa_name_hash_map; + // Id hash map. + + typedef ACE_Map_Manager_Adapter< + poa_name, + TAO_POA *, + ACE_Noop_Key_Generator<poa_name> > persistent_poa_name_linear_map; + // Id linear map. + +public: + + persistent_poa_name_map *persistent_poa_name_map_; + transient_poa_map *transient_poa_map_; + +protected: + + static size_t transient_poa_name_size_; + + static void set_transient_poa_name_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters); + + TAO_ORB_Core &orb_core_; + + ACE_Lock *lock_; + + class poa_name_iterator + { + // = TITLE + // Iterator for a folded poa name. + public: + + poa_name_iterator (int begin, + CORBA::ULong size, + const CORBA::Octet *folded_buffer); + // Constructor. + + int operator== (const poa_name_iterator &rhs) const; + int operator!= (const poa_name_iterator &rhs) const; + // Comparison operators. + + ACE_CString operator* () const; + // Dereference operator. + + poa_name_iterator &operator++ (void); + // Prefix advance. + + protected: + + CORBA::ULong size_; + CORBA::ULong position_; + const CORBA::Octet *folded_buffer_; + CORBA::ULong last_separator_; + }; + + class iteratable_poa_name + { + // = TITLE + // This class allows iteration over a folded poa name. + public: + + typedef poa_name_iterator iterator; + + iteratable_poa_name (const poa_name &folded_name); + + iterator begin (void) const; + iterator end (void) const; + + protected: + + const poa_name &folded_name_; + }; + +}; + +//////////////////////////////////////////////////////////////////////////////// + +#if defined (__ACE_INLINE__) +# include "tao/Object_Adapter.i" +#endif /* __ACE_INLINE__ */ + +#endif /* TAO_OBJECT_ADAPTER_H */ diff --git a/TAO/tao/Object_Adapter.i b/TAO/tao/Object_Adapter.i new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/tao/Object_Adapter.i @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/tao/Object_KeyC.cpp b/TAO/tao/Object_KeyC.cpp index 82fbce47233..2730a72180f 100644 --- a/TAO/tao/Object_KeyC.cpp +++ b/TAO/tao/Object_KeyC.cpp @@ -65,3 +65,10 @@ operator== (const TAO_ObjectKey &lhs, return 1; } + +int +operator!= (const TAO_ObjectKey &lhs, + const TAO_ObjectKey &rhs) +{ + return !(lhs == rhs); +} diff --git a/TAO/tao/Object_KeyC.h b/TAO/tao/Object_KeyC.h index 71fc828e181..40812a64469 100644 --- a/TAO/tao/Object_KeyC.h +++ b/TAO/tao/Object_KeyC.h @@ -24,7 +24,7 @@ class TAO_Export TAO_ObjectKey : public TAO_Unbounded_Sequence<CORBA::Octet> // = DESCRIPTION // The object is basically a sequence of octets, but we derive // from it to create a unique type; this is useful for - // overloading. + // overloading. // public: #if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8 @@ -92,6 +92,9 @@ private: extern TAO_Export int operator== (const TAO_ObjectKey &l, const TAO_ObjectKey &r); +extern TAO_Export int operator!= (const TAO_ObjectKey &l, + const TAO_ObjectKey &r); + #if defined (__ACE_INLINE__) #include "tao/Object_KeyC.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/POA.cpp b/TAO/tao/POA.cpp index f7ac0f20338..487986f5d77 100644 --- a/TAO/tao/POA.cpp +++ b/TAO/tao/POA.cpp @@ -5,9 +5,9 @@ #include "tao/POA.h" #include "tao/ORB_Core.h" -#include "tao/Server_Request.h" #include "tao/Server_Strategy_Factory.h" #include "tao/Environment.h" +#include "tao/Exception.h" // Forwarding Servant class #include "tao/Forwarding_Servant.h" @@ -102,59 +102,65 @@ TAO_Thread_Policy::TAO_Thread_Policy (const TAO_Thread_Policy &rhs) } PortableServer::ThreadPolicyValue -TAO_Thread_Policy::value (CORBA::Environment &env) +TAO_Thread_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Thread_Policy::copy (CORBA::Environment &env) +TAO_Thread_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Thread_Policy> new_policy (new TAO_Thread_Policy (*this)); + TAO_Thread_Policy *thread_policy_copy = 0; + ACE_NEW_THROW_EX (thread_policy_copy, + TAO_Thread_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Thread_Policy> new_thread_policy (thread_policy_copy); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + CORBA::Policy_var result = new_thread_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_thread_policy.release (); + return result._retn (); } void -TAO_Thread_Policy::destroy (CORBA::Environment &env) +TAO_Thread_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Thread_Policy::policy_type (CORBA::Environment &env) +TAO_Thread_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::THREAD_POLICY_ID; } PortableServer::POA_ptr -TAO_Thread_Policy::_default_POA (CORBA::Environment &env) +TAO_Thread_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -175,58 +181,65 @@ TAO_Lifespan_Policy::TAO_Lifespan_Policy (const TAO_Lifespan_Policy &rhs) } PortableServer::LifespanPolicyValue -TAO_Lifespan_Policy::value (CORBA::Environment &env) +TAO_Lifespan_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Lifespan_Policy::copy (CORBA::Environment &env) +TAO_Lifespan_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Lifespan_Policy> new_policy (new TAO_Lifespan_Policy (*this)); + TAO_Lifespan_Policy *lifespan_policy_copy = 0; + ACE_NEW_THROW_EX (lifespan_policy_copy, + TAO_Lifespan_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Lifespan_Policy> new_lifespan_policy (lifespan_policy_copy); + + CORBA::Policy_var result = new_lifespan_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_lifespan_policy.release (); + return result._retn (); } void -TAO_Lifespan_Policy::destroy (CORBA::Environment &env) +TAO_Lifespan_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; + + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Lifespan_Policy::policy_type (CORBA::Environment &env) +TAO_Lifespan_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::LIFESPAN_POLICY_ID; } PortableServer::POA_ptr -TAO_Lifespan_Policy::_default_POA (CORBA::Environment &env) +TAO_Lifespan_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -245,58 +258,65 @@ TAO_Id_Uniqueness_Policy::TAO_Id_Uniqueness_Policy (const TAO_Id_Uniqueness_Poli } PortableServer::IdUniquenessPolicyValue -TAO_Id_Uniqueness_Policy::value (CORBA::Environment &env) +TAO_Id_Uniqueness_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Id_Uniqueness_Policy::copy (CORBA::Environment &env) +TAO_Id_Uniqueness_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Id_Uniqueness_Policy> new_policy (new TAO_Id_Uniqueness_Policy (*this)); + TAO_Id_Uniqueness_Policy *id_uniqueness_policy_copy = 0; + ACE_NEW_THROW_EX (id_uniqueness_policy_copy, + TAO_Id_Uniqueness_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Id_Uniqueness_Policy> new_id_uniqueness_policy (id_uniqueness_policy_copy); + + CORBA::Policy_var result = new_id_uniqueness_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_id_uniqueness_policy.release (); + return result._retn (); } void -TAO_Id_Uniqueness_Policy::destroy (CORBA::Environment &env) +TAO_Id_Uniqueness_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Id_Uniqueness_Policy::policy_type (CORBA::Environment &env) +TAO_Id_Uniqueness_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::ID_UNIQUENESS_POLICY_ID; } PortableServer::POA_ptr -TAO_Id_Uniqueness_Policy::_default_POA (CORBA::Environment &env) +TAO_Id_Uniqueness_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -315,58 +335,65 @@ TAO_Id_Assignment_Policy::TAO_Id_Assignment_Policy (const TAO_Id_Assignment_Poli } PortableServer::IdAssignmentPolicyValue -TAO_Id_Assignment_Policy::value (CORBA::Environment &env) +TAO_Id_Assignment_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Id_Assignment_Policy::copy (CORBA::Environment &env) +TAO_Id_Assignment_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Id_Assignment_Policy> new_policy (new TAO_Id_Assignment_Policy (*this)); + TAO_Id_Assignment_Policy *id_assignment_policy_copy = 0; + ACE_NEW_THROW_EX (id_assignment_policy_copy, + TAO_Id_Assignment_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Id_Assignment_Policy> new_id_assignment_policy (id_assignment_policy_copy); + + CORBA::Policy_var result = new_id_assignment_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_id_assignment_policy.release (); + return result._retn (); } void -TAO_Id_Assignment_Policy::destroy (CORBA::Environment &env) +TAO_Id_Assignment_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; + + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Id_Assignment_Policy::policy_type (CORBA::Environment &env) +TAO_Id_Assignment_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::ID_ASSIGNMENT_POLICY_ID; } PortableServer::POA_ptr -TAO_Id_Assignment_Policy::_default_POA (CORBA::Environment &env) +TAO_Id_Assignment_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -387,58 +414,65 @@ TAO_Implicit_Activation_Policy::TAO_Implicit_Activation_Policy (const TAO_Implic } PortableServer::ImplicitActivationPolicyValue -TAO_Implicit_Activation_Policy::value (CORBA::Environment &env) +TAO_Implicit_Activation_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Implicit_Activation_Policy::copy (CORBA::Environment &env) +TAO_Implicit_Activation_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Implicit_Activation_Policy> new_policy (new TAO_Implicit_Activation_Policy (*this)); + TAO_Implicit_Activation_Policy *implicit_activation_policy_copy = 0; + ACE_NEW_THROW_EX (implicit_activation_policy_copy, + TAO_Implicit_Activation_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Implicit_Activation_Policy> new_implicit_activation_policy (implicit_activation_policy_copy); + + CORBA::Policy_var result = new_implicit_activation_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_implicit_activation_policy.release (); + return result._retn (); } void -TAO_Implicit_Activation_Policy::destroy (CORBA::Environment &env) +TAO_Implicit_Activation_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Implicit_Activation_Policy::policy_type (CORBA::Environment &env) +TAO_Implicit_Activation_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::IMPLICIT_ACTIVATION_POLICY_ID; } PortableServer::POA_ptr -TAO_Implicit_Activation_Policy::_default_POA (CORBA::Environment &env) +TAO_Implicit_Activation_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -457,58 +491,65 @@ TAO_Servant_Retention_Policy::TAO_Servant_Retention_Policy (const TAO_Servant_Re } PortableServer::ServantRetentionPolicyValue -TAO_Servant_Retention_Policy::value (CORBA::Environment &env) +TAO_Servant_Retention_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Servant_Retention_Policy::copy (CORBA::Environment &env) +TAO_Servant_Retention_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Servant_Retention_Policy> new_policy (new TAO_Servant_Retention_Policy (*this)); + TAO_Servant_Retention_Policy *servant_retention_policy_copy = 0; + ACE_NEW_THROW_EX (servant_retention_policy_copy, + TAO_Servant_Retention_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Servant_Retention_Policy> new_servant_retention_policy (servant_retention_policy_copy); + + CORBA::Policy_var result = new_servant_retention_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_servant_retention_policy.release (); + return result._retn (); } void -TAO_Servant_Retention_Policy::destroy (CORBA::Environment &env) +TAO_Servant_Retention_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; + + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Servant_Retention_Policy::policy_type (CORBA::Environment &env) +TAO_Servant_Retention_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::SERVANT_RETENTION_POLICY_ID; } PortableServer::POA_ptr -TAO_Servant_Retention_Policy::_default_POA (CORBA::Environment &env) +TAO_Servant_Retention_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -527,58 +568,65 @@ TAO_Request_Processing_Policy::TAO_Request_Processing_Policy (const TAO_Request_ } PortableServer::RequestProcessingPolicyValue -TAO_Request_Processing_Policy::value (CORBA::Environment &env) +TAO_Request_Processing_Policy::value (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return this->value_; } CORBA::Policy_ptr -TAO_Request_Processing_Policy::copy (CORBA::Environment &env) +TAO_Request_Processing_Policy::copy (CORBA::Environment &ACE_TRY_ENV) { - auto_ptr<TAO_Request_Processing_Policy> new_policy (new TAO_Request_Processing_Policy (*this)); + TAO_Request_Processing_Policy *request_processing_policy_copy = 0; + ACE_NEW_THROW_EX (request_processing_policy_copy, + TAO_Request_Processing_Policy (*this), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); - CORBA::Policy_var result = new_policy->_this (env); - if (env.exception () != 0) - return CORBA::Policy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation object - new_policy.release (); - return result._retn (); - } + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Request_Processing_Policy> new_request_processing_policy (request_processing_policy_copy); + + CORBA::Policy_var result = new_request_processing_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Policy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_request_processing_policy.release (); + return result._retn (); } void -TAO_Request_Processing_Policy::destroy (CORBA::Environment &env) +TAO_Request_Processing_Policy::destroy (CORBA::Environment &ACE_TRY_ENV) { // Remove self from POA // // Note that there is no real error checking here as we can't do // much about errors here anyway // - PortableServer::POA_var poa = this->_default_POA (env); - if (env.exception () == 0) - { - PortableServer::ObjectId_var id = poa->servant_to_id (this, env); - if (env.exception () == 0) - poa->deactivate_object (id.in (), env); - } + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; - // Commit suicide: must have been dynamically allocated + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; + + // Commit suicide: must have been dynamically allocated. delete this; } CORBA::PolicyType -TAO_Request_Processing_Policy::policy_type (CORBA::Environment &env) +TAO_Request_Processing_Policy::policy_type (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); - return 0; + ACE_UNUSED_ARG (ACE_TRY_ENV); + return PortableServer::REQUEST_PROCESSING_POLICY_ID; } PortableServer::POA_ptr -TAO_Request_Processing_Policy::_default_POA (CORBA::Environment &env) +TAO_Request_Processing_Policy::_default_POA (CORBA::Environment &ACE_TRY_ENV) { return PortableServer::POA::_duplicate (this->poa_.in ()); } @@ -598,20 +646,20 @@ TAO_POA_Policies::TAO_POA_Policies (void) void TAO_POA_Policies::parse_policies (const CORBA::PolicyList &policies, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { for (CORBA::ULong i = 0; - i < policies.length () && env.exception () == 0; + i < policies.length (); i++) { - this->parse_policy (policies[i], env); + this->parse_policy (policies[i], + ACE_TRY_ENV); + ACE_CHECK; } if (this->validity_check () == -1) { - CORBA::Exception *exception = new PortableServer::POA::InvalidPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::InvalidPolicy ()); } } @@ -646,112 +694,119 @@ TAO_POA_Policies::validity_check (void) void TAO_POA_Policies::parse_policy (const CORBA::Policy_ptr policy, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { #if !defined (TAO_HAS_MINIMUM_CORBA) PortableServer::ThreadPolicy_var thread - = PortableServer::ThreadPolicy::_narrow (policy, env); + = PortableServer::ThreadPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (thread.in ())) { - this->thread_ = thread->value (env); + this->thread_ = thread->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } #endif /* TAO_HAS_MINIMUM_CORBA */ PortableServer::LifespanPolicy_var lifespan - = PortableServer::LifespanPolicy::_narrow (policy, env); + = PortableServer::LifespanPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (lifespan.in ())) { - this->lifespan_ = lifespan->value (env); + this->lifespan_ = lifespan->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } PortableServer::IdUniquenessPolicy_var id_uniqueness - = PortableServer::IdUniquenessPolicy::_narrow (policy, env); + = PortableServer::IdUniquenessPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (id_uniqueness.in ())) { - this->id_uniqueness_ = id_uniqueness->value (env); + this->id_uniqueness_ = id_uniqueness->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } PortableServer::IdAssignmentPolicy_var id_assignment - = PortableServer::IdAssignmentPolicy::_narrow (policy, env); + = PortableServer::IdAssignmentPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (id_assignment.in ())) { - this->id_assignment_ = id_assignment->value (env); + this->id_assignment_ = id_assignment->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } #if !defined (TAO_HAS_MINIMUM_CORBA) PortableServer::ImplicitActivationPolicy_var implicit_activation - = PortableServer::ImplicitActivationPolicy::_narrow (policy, env); + = PortableServer::ImplicitActivationPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (implicit_activation.in ())) { - this->implicit_activation_ = implicit_activation->value (env); + this->implicit_activation_ = implicit_activation->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } PortableServer::ServantRetentionPolicy_var servant_retention - = PortableServer::ServantRetentionPolicy::_narrow (policy, env); + = PortableServer::ServantRetentionPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (servant_retention.in ())) { - this->servant_retention_ = servant_retention->value (env); + this->servant_retention_ = servant_retention->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } PortableServer::RequestProcessingPolicy_var request_processing - = PortableServer::RequestProcessingPolicy::_narrow (policy, env); + = PortableServer::RequestProcessingPolicy::_narrow (policy, + ACE_TRY_ENV); + ACE_CHECK; + if (!CORBA::is_nil (request_processing.in ())) { - this->request_processing_ = request_processing->value (env); + this->request_processing_ = request_processing->value (ACE_TRY_ENV); + ACE_CHECK; + return; } - else - { - env.clear (); - } #endif /* TAO_HAS_MINIMUM_CORBA */ - CORBA::Exception *exception = new PortableServer::POA::InvalidPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::InvalidPolicy ()); } -TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, +TAO_POA::TAO_POA (const TAO_POA::String &name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - CORBA::Environment &env) - : name_ (adapter_name), + ACE_Lock &lock, + TAO_ORB_Core &orb_core, + CORBA::Environment &ACE_TRY_ENV) + : name_ (name), poa_manager_ (poa_manager), policies_ (policies), parent_ (parent), @@ -767,66 +822,81 @@ TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, #endif /* TAO_HAS_MINIMUM_CORBA */ children_ (), - lock_ (0), + lock_ (lock), closing_down_ (0), persistent_ (policies.lifespan () == PortableServer::PERSISTENT), system_id_ (policies.id_assignment () == PortableServer::SYSTEM_ID), - creation_time_ (ACE_OS::gettimeofday ()) -{ - // Create a lock for ourselves - this->create_internal_lock (); - - // Set the complete name of this POA - this->set_complete_name (); - - // Register self with manager - this->poa_manager_.register_poa (this, env); + creation_time_ (ACE_OS::gettimeofday ()), + orb_core_ (orb_core) +{ + // Set the folded name of this POA. + this->set_folded_name (); + + // Create the active object map. + TAO_Active_Object_Map *active_object_map = 0; + ACE_NEW_THROW_EX (active_object_map, + TAO_Active_Object_Map (!this->system_id (), + this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID, + this->persistent (), + this->orb_core_.server_factory ()->active_object_map_creation_parameters (), + ACE_TRY_ENV), + CORBA::NO_MEMORY ()); + + // Give ownership of the new map to the auto pointer. Note, that it + // is important for the auto pointer to take ownership before + // checking for exception since we may need to delete the new map. + auto_ptr<TAO_Active_Object_Map> new_active_object_map (active_object_map); + + // Check for exception in construction of the active object map. + ACE_CHECK; + + // Register self with manager. + int result = this->poa_manager_.register_poa (this); + if (result != 0) + { + ACE_THROW (CORBA::OBJ_ADAPTER ()); + } - // Create the active object map - this->create_active_object_map (); -} + // Add self to Object Adapter class. + result = this->orb_core_.object_adapter ()->bind_poa (this->folded_name_, + this, + this->system_name_.out ()); + if (result != 0) + { + // Remove from POA Manager in case of errors. No checks of + // further errors... + this->poa_manager_.remove_poa (this); -void -TAO_POA::create_active_object_map (void) -{ - ACE_NEW (this->active_object_map_, - TAO_Active_Object_Map (!this->system_id (), - this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID, - this->policies ().lifespan () == PortableServer::PERSISTENT, - TAO_ORB_Core_instance ()->server_factory ()->active_object_map_creation_parameters ())); -} + ACE_THROW (CORBA::OBJ_ADAPTER ()); + } -void -TAO_POA::create_internal_lock (void) -{ - // Ask the server factory to create the lock. svc.conf will be - // consulted. If the user did not specify any preference in - // svc.conf, THREAD_LOCK will be the default. - this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_poa_lock (); + // Finally everything is fine. Make sure to take ownership away + // from the auto pointer. + this->active_object_map_ = new_active_object_map.release (); } TAO_POA::~TAO_POA (void) { - // Delete the active object map + // Delete the active object map. delete this->active_object_map_; - // Delete the dynamically allocated lock - delete this->lock_; - - // Remove POA from the POAManager - // // Note: Errors are ignored here since there is nothing we can do - // about them - // - CORBA::Environment env; - this->poa_manager_.remove_poa (this, env); + // about them. + + // Remove POA from the POAManager. + this->poa_manager_.remove_poa (this); + + // Remove POA from the Object Adapter. + this->orb_core_.object_adapter ()->unbind_poa (this, + this->folded_name_, + this->system_name_.in ()); } PortableServer::POA_ptr TAO_POA::create_POA (const char *adapter_name, PortableServer::POAManager_ptr poa_manager, const CORBA::PolicyList &policies, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // If any of the policy objects specified are not valid for the ORB // implementation, if conflicting policy objects are specified, or @@ -835,27 +905,34 @@ TAO_POA::create_POA (const char *adapter_name, // InvalidPolicy exception is raised containing the index in the // policies parameter value of the first offending policy object. TAO_POA_Policies tao_policies; - tao_policies.parse_policies (policies, env); - if (env.exception () != 0) - return PortableServer::POA::_nil (); + tao_policies.parse_policies (policies, + ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); // If the poa_manager parameter is null, a new POAManager object is // created and associated with the new POA. Otherwise, the specified // POAManager object is associated with the new POA. The POAManager // object can be obtained using the attribute name the_POAManager. + + auto_ptr<TAO_POA_Manager> new_poa_manager_impl; TAO_POA_Manager *poa_manager_impl = 0; if (CORBA::is_nil (poa_manager)) { - poa_manager_impl = this->poa_manager_.clone (); + ACE_NEW_THROW_EX (poa_manager_impl, + TAO_POA_Manager (this->orb_core_.object_adapter ()->lock ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + + // Give ownership to auto pointer. + new_poa_manager_impl = auto_ptr<TAO_POA_Manager> (poa_manager_impl); } else { PortableServer::Servant servant = poa_manager->_servant (); if (servant == 0) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return PortableServer::POA::_nil (); + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + PortableServer::POA::_nil ()); } void *ptr = servant->_downcast (servant->_interface_repository_id ()); @@ -863,249 +940,188 @@ TAO_POA::create_POA (const char *adapter_name, poa_manager_impl = ACE_dynamic_cast (TAO_POA_Manager *, mgr); } - TAO_POA *result = this->create_POA (adapter_name, - *poa_manager_impl, - tao_policies, - env); - if (env.exception () != 0) - return PortableServer::POA::_nil (); + TAO_POA *poa = this->create_POA (adapter_name, + *poa_manager_impl, + tao_policies, + ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + + // Give ownership of the new poa to the auto pointer. + auto_ptr<TAO_POA> new_poa (poa); + + PortableServer::POA_var result = new_poa->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + + // Finally everything is fine. Make sure to take ownership away + // from the auto pointers. + new_poa.release (); + new_poa_manager_impl.release (); - return result->_this (env); + return result._retn (); } TAO_POA * TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // If this is the leaf POA name - if (this->leaf_poa_name (adapter_name, env)) - { - // This operaton creates a new POA as a child of the target POA. The - // specified name identifies the new POA with respect to other POAs - // with the same parent POA. If the target POA already has a child - // POA with the specified name, the AdapterAlreadyExists exception - // is raised. - int result = this->children_.find (adapter_name); + // This operaton creates a new POA as a child of the target POA. The + // specified name identifies the new POA with respect to other POAs + // with the same parent POA. If the target POA already has a child + // POA with the specified name, the AdapterAlreadyExists exception + // is raised. + int result = this->children_.find (adapter_name); - // Child was found - if (result != -1) - { - CORBA::Exception *exception = new PortableServer::POA::AdapterAlreadyExists; - env.exception (exception); - return 0; - } + // Child was found + if (result != -1) + { + ACE_THROW_RETURN (PortableServer::POA::AdapterAlreadyExists (), + 0); + } - // - // Child was not found - // - - // The specified policy objects are associated with the POA and used - // to control its behavior. The policy objects are effectively - // copied before this operation returns, so the application is free - // to destroy them while the POA is in use. Policies are not - // inherited from the parent POA. - auto_ptr<TAO_POA> new_poa (this->clone (adapter_name, - poa_manager, - policies, - this, - env)); - - if (env.exception () != 0) - return 0; - - // Add to children map - if (this->children_.bind (adapter_name, new_poa.get ()) != 0) - { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; - } + // + // Child was not found + // - // Note: Creating a POA using a POA manager that is in the active - // state can lead to race conditions if the POA supports preexisting - // objects, because the new POA may receive a request before its - // adapter activator, servant manager, or default servant have been - // initialized. These problems do not occur if the POA is created by - // an adapter activator registered with a parent of the new POA, - // because requests are queued until the adapter activator - // returns. To avoid these problems when a POA must be explicitly - // initialized, the application can initialize the POA by invoking - // find_POA with a TRUE activate parameter. - - // Everything is fine - // Don't let the auto_ptr delete the implementation - return new_poa.release (); - } - // Not the leaf POA name - else + // The specified policy objects are associated with the POA and used + // to control its behavior. The policy objects are effectively + // copied before this operation returns, so the application is free + // to destroy them while the POA is in use. Policies are not + // inherited from the parent POA. + TAO_POA *poa = 0; + ACE_NEW_THROW_EX (poa, + TAO_POA (adapter_name, + poa_manager, + policies, + this, + this->orb_core_.object_adapter ()->lock (), + this->orb_core_, + ACE_TRY_ENV), + CORBA::NO_MEMORY ()); + + // Give ownership of the new map to the auto pointer. Note, that it + // is important for the auto pointer to take ownership before + // checking for exception since we may need to delete the new map. + auto_ptr<TAO_POA> new_poa (poa); + + // Check for exception in construction of the POA. + ACE_CHECK_RETURN (0); + + // Add to children map + result = this->children_.bind (adapter_name, + new_poa.get ()); + if (result != 0) { - // Find the topmost name - TAO_POA::String topmost_poa_name; - TAO_POA::String tail_poa_name; - this->parse_poa_name (adapter_name, - topmost_poa_name, - tail_poa_name, - env); + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); + } - if (env.exception () != 0) - return 0; + // Note: Creating a POA using a POA manager that is in the active + // state can lead to race conditions if the POA supports preexisting + // objects, because the new POA may receive a request before its + // adapter activator, servant manager, or default servant have been + // initialized. These problems do not occur if the POA is created by + // an adapter activator registered with a parent of the new POA, + // because requests are queued until the adapter activator + // returns. To avoid these problems when a POA must be explicitly + // initialized, the application can initialize the POA by invoking + // find_POA with a TRUE activate parameter. - // If we are the topmost poa, let's create the tail - if (topmost_poa_name == this->name_) - { - return this->create_POA_i (tail_poa_name, - poa_manager, - policies, - env); - } + // Everything is fine. Don't let the auto_ptr delete the + // implementation. + return new_poa.release (); +} - // - // We are not the topmost POA - // +PortableServer::POA_ptr +TAO_POA::find_POA (const char *adapter_name, + CORBA::Boolean activate_it, + CORBA::Environment &ACE_TRY_ENV) +{ + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); - // Try to find the topmost child - TAO_POA *child_poa = 0; - int result = this->children_.find (topmost_poa_name, child_poa); + TAO_POA *child = this->find_POA_i (adapter_name, + activate_it, + ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); - // Child was not found or the topmost is us - if (result != 0) - { - child_poa = this->create_POA_i (topmost_poa_name, - poa_manager, - policies, - env); - if (env.exception () != 0) - return 0; - } + // Give ownership of the new poa to the auto pointer. + auto_ptr<TAO_POA> new_child (child); - // At this point, the intermediate child POA was either found or - // created - return child_poa->create_POA (tail_poa_name, - poa_manager, - policies, - env); - } + PortableServer::POA_var result = new_child->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + + // Finally everything is fine. Make sure to take ownership away + // from the auto pointer. + new_child.release (); + + return result._retn (); } TAO_POA * -TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, - CORBA::Boolean activate_it, - CORBA::Environment &env) +TAO_POA::find_POA_i (const ACE_CString &child_name, + CORBA::Boolean activate_it, + CORBA::Environment &ACE_TRY_ENV) { - // If this is the leaf POA name - if (this->leaf_poa_name (adapter_name, env)) - { - // If the target POA is the parent of a child POA with the - // specified name (relative to the target POA), that child POA - // is returned. - TAO_POA *child_poa = 0; - int result = this->children_.find (adapter_name, child_poa); - - // Child was found - if (result != -1) - return child_poa; + TAO_POA *child; + int result = this->children_.find (child_name, + child); #if !defined (TAO_HAS_MINIMUM_CORBA) - // - // Child was not found - // - - // If a child POA with the specified name does not exist and the - // value of the activate_it parameter is TRUE, the target POA's - // AdapterActivator, if one exists, is invoked, and, if it - // successfully activates the child POA, that child POA is - // returned. - if (activate_it && !CORBA::is_nil (this->adapter_activator_.in ())) + if (result != 0) + { + if (activate_it) { - PortableServer::POA_var self = this->_this (env); - // Check for exceptions - if (env.exception () != 0) - return 0; - - ACE_CString null_terminated_adapter_name (adapter_name); - - CORBA::Boolean success = - this->adapter_activator_->unknown_adapter (self.in (), - null_terminated_adapter_name.c_str (), - env); - // Check for exceptions - if (env.exception () != 0) - return 0; - - // On success - if (success) + if (!CORBA::is_nil (this->adapter_activator_.in ())) { - // Search the children table again - result = this->children_.find (adapter_name, child_poa); - - // Child was found - if (result != -1) - return child_poa; + PortableServer::POA_var self = this->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + CORBA::Boolean success = + this->adapter_activator_->unknown_adapter (self.in (), + child_name.c_str (), + ACE_TRY_ENV); + if (success) + { + result = this->children_.find (child_name, + child); + } + else + { + result = -1; + } + } + else + { + result = -1; } } + else + { + result = -1; + } + } #endif /* TAO_HAS_MINIMUM_CORBA */ - // Otherwise, the AdapterNonExistent exception is raised. - CORBA::Exception *exception = new PortableServer::POA::AdapterNonExistent; - env.exception (exception); - return 0; + if (result == 0) + { + return child; } - // Not the leaf POA name else { - // Find the topmost name - TAO_POA::String topmost_poa_name; - TAO_POA::String tail_poa_name; - this->parse_poa_name (adapter_name, - topmost_poa_name, - tail_poa_name, - env); - - if (env.exception () != 0) - return 0; - - // If we are the topmost poa, let's create the tail - if (topmost_poa_name == this->name_) - { - return this->find_POA_i (tail_poa_name, - activate_it, - env); - } - - // - // We are not the topmost POA - // - - // Try to find the topmost child - TAO_POA *child_poa; - int result = this->children_.find (topmost_poa_name, child_poa); - - // Child was not found - if (result != 0) - { - child_poa = this->find_POA_i_optimized (topmost_poa_name, - activate_it, - env); - if (env.exception () != 0) - return 0; - } - - // At this point, the intermediate child POA was either found or - // created - return child_poa->find_POA (tail_poa_name, - activate_it, - env); + // Otherwise, the AdapterNonExistent exception is raised. + ACE_THROW_RETURN (PortableServer::POA::AdapterNonExistent (), + 0); } } void TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { this->closing_down_ = 1; @@ -1117,26 +1133,26 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, // Remove POA from the parent if (this->parent_ != 0) - this->parent_->delete_child (this->name_, env); - - if (env.exception () != 0) - return; + { + int result = this->parent_->delete_child (this->name_); + if (result != 0) + { + ACE_THROW (CORBA::OBJ_ADAPTER ()); + } + } // Remove all children POAs for (CHILDREN::iterator iterator = this->children_.begin (); - iterator != this->children_.end () - && env.exception () == 0; + iterator != this->children_.end (); ++iterator) { TAO_POA *child_poa = (*iterator).int_id_; - child_poa->destroy (etherealize_objects, - wait_for_completion, - env); + child_poa->destroy_i (etherealize_objects, + wait_for_completion, + ACE_TRY_ENV); + ACE_CHECK; } - if (env.exception () != 0) - return; - // When a POA is destroyed, any requests that have started execution // continue to completion. Any requests that have not started // execution are processed as if they were newly arrived, that is, @@ -1162,9 +1178,8 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, this->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER && !CORBA::is_nil (this->servant_activator_.in ())) { - PortableServer::POA_var self = this->_this (env); - if (env.exception () != 0) - return; + PortableServer::POA_var self = this->_this (ACE_TRY_ENV); + ACE_CHECK; while (1) { @@ -1190,9 +1205,7 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, // Errors. else if (result != 0) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return; + ACE_THROW (CORBA::OBJ_ADAPTER ()); } // Successful unbind. else @@ -1203,7 +1216,8 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, servant, 1, remaining_activations, - env); + ACE_TRY_ENV); + ACE_CHECK; } } } @@ -1219,52 +1233,41 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, // destroying the POAs. ACE_UNUSED_ARG (wait_for_completion); + + // Commit suicide + delete this; } -void -TAO_POA::delete_child (const TAO_POA::String &child, - CORBA::Environment &env) +int +TAO_POA::delete_child (const TAO_POA::String &child) { + int result = 0; + // If we are not closing down, we must remove this child from our // collection. if (!this->closing_down_) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - - this->delete_child_i (child, - env); + result = this->children_.unbind (child); } // If we are closing down, we are currently iterating over our // children and there is not need to remove this child from our // collection. -} -void -TAO_POA::delete_child_i (const TAO_POA::String &child, - CORBA::Environment &env) -{ - if (this->children_.unbind (child) != 0) - { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return; - } + return result; } #if !defined (TAO_HAS_MINIMUM_CORBA) PortableServer::ServantManager_ptr -TAO_POA::get_servant_manager_i (CORBA::Environment &env) +TAO_POA::get_servant_manager_i (CORBA::Environment &ACE_TRY_ENV) { // This operation requires the USE_SERVANT_MANAGER policy; if not // present, the WrongPolicy exception is raised. if (this->policies ().request_processing () != PortableServer::USE_SERVANT_MANAGER) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return PortableServer::ServantManager::_nil (); + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + PortableServer::ServantManager::_nil ()); } // This operation returns the servant manager associated with the @@ -1278,51 +1281,50 @@ TAO_POA::get_servant_manager_i (CORBA::Environment &env) void TAO_POA::set_servant_manager_i (PortableServer::ServantManager_ptr imgr, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the USE_SERVANT_MANAGER policy; if not // present, the WrongPolicy exception is raised. if (this->policies ().request_processing () != PortableServer::USE_SERVANT_MANAGER) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } // This operation sets the default servant manager associated with // the POA. if (this->policies ().servant_retention () == PortableServer::RETAIN) { - this->servant_activator_ = PortableServer::ServantActivator::_narrow (imgr, env); + this->servant_activator_ = PortableServer::ServantActivator::_narrow (imgr, + ACE_TRY_ENV); + ACE_CHECK; + if (CORBA::is_nil (this->servant_activator_.in ())) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } } else { - this->servant_locator_ = PortableServer::ServantLocator::_narrow (imgr, env); + this->servant_locator_ = PortableServer::ServantLocator::_narrow (imgr, + ACE_TRY_ENV); + ACE_CHECK; + if (CORBA::is_nil (this->servant_locator_.in ())) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } } } PortableServer::Servant -TAO_POA::get_servant_i (CORBA::Environment &env) +TAO_POA::get_servant_i (CORBA::Environment &ACE_TRY_ENV) { // This operation requires the USE_DEFAULT_SERVANT policy; if not // present, the WrongPolicy exception is raised. if (this->policies ().request_processing () != PortableServer::USE_DEFAULT_SERVANT) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // This operation returns the default servant associated with the @@ -1335,23 +1337,20 @@ TAO_POA::get_servant_i (CORBA::Environment &env) // If no servant has been associated with the POA, the NoServant // exception is raised. { - CORBA::Exception *exception = new PortableServer::POA::NoServant; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::NoServant (), + 0); } } void TAO_POA::set_servant_i (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the USE_DEFAULT_SERVANT policy; if not // present, the WrongPolicy exception is raised. if (this->policies ().request_processing () != PortableServer::USE_DEFAULT_SERVANT) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } // This operation registers the specified servant with the POA as @@ -1364,16 +1363,15 @@ TAO_POA::set_servant_i (PortableServer::Servant servant, PortableServer::ObjectId * TAO_POA::activate_object_i (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the SYSTEM_ID and RETAIN policy; if not // present, the WrongPolicy exception is raised. if (!(this->policies ().id_assignment () == PortableServer::SYSTEM_ID && this->policies ().servant_retention () == PortableServer::RETAIN)) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // If the POA has the UNIQUE_ID policy and the specified servant is @@ -1382,9 +1380,8 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && this->active_object_map ().is_servant_in_map (servant)) { - CORBA::Exception *exception = new PortableServer::POA::ServantAlreadyActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ServantAlreadyActive (), + 0); } // Otherwise, the activate_object operation generates an Object Id @@ -1394,9 +1391,8 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, if (this->active_object_map ().bind_using_system_id_returning_user_id (servant, user_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } // Everything is finally ok @@ -1406,15 +1402,13 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, void TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN policy; if not present, the // WrongPolicy exception is raised. if (this->policies ().servant_retention () != PortableServer::RETAIN) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } // If the POA has the SYSTEM_ID policy and it detects that the @@ -1429,9 +1423,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, if (this->policies ().id_assignment () == PortableServer::SYSTEM_ID && !this->is_poa_generated_id (id)) { - CORBA::Exception *exception = new CORBA::BAD_PARAM (CORBA::COMPLETED_NO); - env.exception (exception); - return; + ACE_THROW (CORBA::BAD_PARAM ()); } // If the CORBA object denoted by the Object Id value is already @@ -1439,9 +1431,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, // Object Map), the ObjectAlreadyActive exception is raised. if (this->active_object_map ().is_user_id_in_map (id)) { - CORBA::Exception *exception = new PortableServer::POA::ObjectAlreadyActive; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::ObjectAlreadyActive ()); } // If the POA has the UNIQUE_ID policy and the servant is already in @@ -1450,9 +1440,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && this->active_object_map ().is_servant_in_map (servant)) { - CORBA::Exception *exception = new PortableServer::POA::ServantAlreadyActive; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::ServantAlreadyActive ()); } // Otherwise, the activate_object_with_id operation enters an @@ -1460,9 +1448,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, // servant in the Active Object Map. if (this->active_object_map ().bind_using_user_id (servant, id) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return; + ACE_THROW (CORBA::OBJ_ADAPTER ()); } // Everything is finally ok @@ -1470,15 +1456,13 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, void TAO_POA::deactivate_object_i (const PortableServer::ObjectId &id, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN policy; if not present, the // WrongPolicy exception is raised. if (this->policies ().servant_retention () != PortableServer::RETAIN) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::WrongPolicy ()); } // This operation causes the association of the Object Id specified @@ -1490,9 +1474,7 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId &id, // Id, the operation raises an ObjectNotActive exception. if (result != 0) { - CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; - env.exception (exception); - return; + ACE_THROW (PortableServer::POA::ObjectNotActive ()); } #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -1511,9 +1493,8 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId &id, // active with any Id. if (!CORBA::is_nil (this->servant_activator_.in ())) { - PortableServer::POA_var self = this->_this (env); - if (env.exception () != 0) - return; + PortableServer::POA_var self = this->_this (ACE_TRY_ENV); + ACE_CHECK; // Place holders.... PortableServer::Servant servant = 0; @@ -1527,7 +1508,8 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId &id, servant, 0, remaining_activations, - env); + ACE_TRY_ENV); + ACE_CHECK; } } @@ -1537,15 +1519,14 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId &id, CORBA::Object_ptr TAO_POA::create_reference_i (const char *intf, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the SYSTEM_ID policy; if not present, the // WrongPolicy exception is raised. if (this->policies ().id_assignment () != PortableServer::SYSTEM_ID) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return CORBA::Object::_nil (); + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + CORBA::Object::_nil ()); } // This operation creates an object reference that encapsulates a @@ -1560,22 +1541,23 @@ TAO_POA::create_reference_i (const char *intf, if (this->active_object_map ().bind_using_system_id_returning_system_id (0, system_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + CORBA::Object::_nil ()); } // Create object key. TAO_ObjectKey_var key = this->create_object_key (system_id.in ()); // Ask the ORB to create you a reference - return TAO_ORB_Core_instance ()->orb ()->key_to_object (key.in (), intf, env); + return this->orb_core_.orb ()->key_to_object (key.in (), + intf, + ACE_TRY_ENV); } CORBA::Object_ptr TAO_POA::create_reference_with_id_i (const PortableServer::ObjectId &user_id, const char *intf, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // If the POA has the SYSTEM_ID policy and it detects that the // Object Id value was not generated by the system or for this POA, @@ -1589,9 +1571,8 @@ TAO_POA::create_reference_with_id_i (const PortableServer::ObjectId &user_id, if (this->policies ().id_assignment () == PortableServer::SYSTEM_ID && !this->is_poa_generated_id (user_id)) { - CORBA::Exception *exception = new CORBA::BAD_PARAM (CORBA::COMPLETED_NO); - env.exception (exception); - return CORBA::Object::_nil (); + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CORBA::Object::_nil ()); } // This operation creates an object reference that encapsulates the @@ -1605,21 +1586,22 @@ TAO_POA::create_reference_with_id_i (const PortableServer::ObjectId &user_id, if (this->active_object_map ().find_system_id_using_user_id (user_id, system_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + CORBA::Object::_nil ()); } // Create object key. TAO_ObjectKey_var key = this->create_object_key (system_id.in ()); // Ask the ORB to create you a reference - return TAO_ORB_Core_instance ()->orb ()->key_to_object (key.in (), intf, env); + return this->orb_core_.orb ()->key_to_object (key.in (), + intf, + ACE_TRY_ENV); } PortableServer::ObjectId * TAO_POA::servant_to_id_i (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN and either the UNIQUE_ID or // IMPLICIT_ACTIVATION policies; if not present, the WrongPolicy @@ -1628,9 +1610,8 @@ TAO_POA::servant_to_id_i (PortableServer::Servant servant, && (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID || this->policies ().implicit_activation () == PortableServer::IMPLICIT_ACTIVATION))) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // This operation has three possible behaviors. @@ -1659,9 +1640,8 @@ TAO_POA::servant_to_id_i (PortableServer::Servant servant, if (this->active_object_map ().bind_using_system_id_returning_user_id (servant, user_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } // Everything is finally ok @@ -1669,14 +1649,13 @@ TAO_POA::servant_to_id_i (PortableServer::Servant servant, } // Otherwise, the ServantNotActive exception is raised. - CORBA::Exception *exception = new PortableServer::POA::ServantNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ServantNotActive (), + 0); } PortableServer::ObjectId * TAO_POA::servant_to_system_id_i (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN and either the UNIQUE_ID or // IMPLICIT_ACTIVATION policies; if not present, the WrongPolicy @@ -1685,9 +1664,8 @@ TAO_POA::servant_to_system_id_i (PortableServer::Servant servant, && (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID || this->policies ().implicit_activation () == PortableServer::IMPLICIT_ACTIVATION))) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // This operation has three possible behaviors. @@ -1716,9 +1694,8 @@ TAO_POA::servant_to_system_id_i (PortableServer::Servant servant, if (this->active_object_map ().bind_using_system_id_returning_system_id (servant, system_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } // Everything is finally ok @@ -1726,14 +1703,13 @@ TAO_POA::servant_to_system_id_i (PortableServer::Servant servant, } // Otherwise, the ServantNotActive exception is raised. - CORBA::Exception *exception = new PortableServer::POA::ServantNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ServantNotActive (), + 0); } CORBA::Object_ptr TAO_POA::servant_to_reference (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // Note: The allocation of an Object Id value and installation in // the Active Object Map caused by implicit activation may actually @@ -1742,23 +1718,21 @@ TAO_POA::servant_to_reference (PortableServer::Servant servant, // produced that will behave appropriately (that is, yield a // consistent Object Id value when asked politely). PortableServer::ObjectId_var id = this->servant_to_system_id (servant, - env); - - if (env.exception () != 0) - return CORBA::Object::_nil (); + ACE_TRY_ENV); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); // Create object key. TAO_ObjectKey_var key = this->create_object_key (id.in ()); // Ask the ORB to create you a reference - return TAO_ORB_Core_instance ()->orb ()->key_to_object (key.in (), - servant->_interface_repository_id (), - env); + return this->orb_core_.orb ()->key_to_object (key.in (), + servant->_interface_repository_id (), + ACE_TRY_ENV); } PortableServer::Servant TAO_POA::reference_to_servant (CORBA::Object_ptr reference, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN policy or the // USE_DEFAULT_SERVANT policy. If neither policy is present, the @@ -1766,9 +1740,8 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, if (!(this->policies ().servant_retention () == PortableServer::RETAIN || this->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT)) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // If the POA has the RETAIN policy and the specified object is @@ -1776,36 +1749,36 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, // servant associated with that object in the Active Object Map. if (this->policies ().servant_retention () == PortableServer::RETAIN) { - TAO_ObjectKey_var key = reference->_key (env); + TAO_ObjectKey_var key = reference->_key (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); // If the object reference was not created by this POA, the // WrongAdapter exception is raised. PortableServer::ObjectId id; - TAO_POA::String poa_name; + TAO_Object_Adapter::poa_name poa_system_name; CORBA::Boolean persistent = 0; CORBA::Boolean system_id = 0; TAO_Temporary_Creation_Time poa_creation_time; int result = this->parse_key (key.in (), - poa_name, + poa_system_name, id, persistent, system_id, poa_creation_time); if (result != 0 - || poa_name != this->complete_name () + || poa_system_name != this->system_name () || persistent != this->persistent () || system_id != this->system_id () || !this->persistent () && poa_creation_time != this->creation_time_) { - CORBA::Exception *exception = new PortableServer::POA::WrongAdapter; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongAdapter (), + 0); } - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); // This operation returns the active servant associated with the // specified system Object Id value. If the Object Id value is @@ -1819,9 +1792,8 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, else // Otherwise, the ObjectNotActive exception is raised. { - CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ObjectNotActive (), + 0); } } @@ -1832,8 +1804,8 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, // returns the default servant. if (this->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) { - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); if (this->default_servant_ != 0) { @@ -1842,9 +1814,8 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, else // Otherwise, the ObjectNotActive exception is raised. { - CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ObjectNotActive (), + 0); } } @@ -1856,7 +1827,7 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, PortableServer::ObjectId * TAO_POA::reference_to_id (CORBA::Object_ptr reference, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // The WrongPolicy exception is declared to allow future extensions. @@ -1867,32 +1838,33 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, // POA on which the operation is being performed. If the object // reference was not created by this POA, the WrongAdapter exception // is raised. - TAO_ObjectKey_var key = reference->_key (env); + TAO_ObjectKey_var key = reference->_key (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + PortableServer::ObjectId id; - TAO_POA::String poa_name; + TAO_Object_Adapter::poa_name poa_system_name; CORBA::Boolean persistent = 0; CORBA::Boolean system_id = 0; TAO_Temporary_Creation_Time poa_creation_time; int result = this->parse_key (key.in (), - poa_name, + poa_system_name, id, persistent, system_id, poa_creation_time); if (result != 0 || - poa_name != this->complete_name () || + poa_system_name != this->system_name () || persistent != this->persistent () || system_id != this->system_id () || !this->persistent () && poa_creation_time != this->creation_time_) { - CORBA::Exception *exception = new PortableServer::POA::WrongAdapter; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongAdapter (), + 0); } - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); // The object denoted by the reference does not have to be active // for this operation to succeed. @@ -1900,9 +1872,8 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, if (this->active_object_map ().find_user_id_using_system_id (id, user_id) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } return user_id._retn (); @@ -1910,15 +1881,14 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, PortableServer::Servant TAO_POA::id_to_servant_i (const PortableServer::ObjectId &id, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN policy; if not present, the // WrongPolicy exception is raised. if (this->policies ().servant_retention () != PortableServer::RETAIN) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + 0); } // This operation returns the active servant associated with the @@ -1932,23 +1902,21 @@ TAO_POA::id_to_servant_i (const PortableServer::ObjectId &id, else // Otherwise, the ObjectNotActive exception is raised. { - CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ObjectNotActive (), + 0); } } CORBA::Object_ptr TAO_POA::id_to_reference_i (const PortableServer::ObjectId &id, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // This operation requires the RETAIN policy; if not present, the // WrongPolicy exception is raised. if (this->policies ().servant_retention () != PortableServer::RETAIN) { - CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::WrongPolicy (), + CORBA::Object::_nil ()); } // If an object with the specified Object Id value is currently @@ -1964,17 +1932,16 @@ TAO_POA::id_to_reference_i (const PortableServer::ObjectId &id, TAO_ObjectKey_var key = this->create_object_key (system_id.in ()); // Ask the ORB to create you a reference - return TAO_ORB_Core_instance ()->orb ()->key_to_object (key.in (), - servant->_interface_repository_id (), - env); + return this->orb_core_.orb ()->key_to_object (key.in (), + servant->_interface_repository_id (), + ACE_TRY_ENV); } else // If the Object Id value is not active in the POA, an // ObjectNotActive exception is raised. { - CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::POA::ObjectNotActive (), + CORBA::Object::_nil ()); } } @@ -1983,139 +1950,48 @@ TAO_POA::id_to_reference_i (const PortableServer::ObjectId &id, void TAO_POA::forward_object_i (const PortableServer::ObjectId &oid, CORBA::Object_ptr forward_to, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // First, deactivate the object - this->deactivate_object_i (oid, env); - - // If failure - if (env.exception () != 0) - return; - - // If success, create a forwarding servant - TAO_Forwarding_Servant *forwarding_servant - = new TAO_Forwarding_Servant (forward_to, - forward_to->_interface_repository_id ()); - - // Register the forwarding servant with the same object Id + this->deactivate_object_i (oid, + ACE_TRY_ENV); + ACE_CHECK; + + // Create a forwarding servant + TAO_Forwarding_Servant *forwarding_servant = 0; + ACE_NEW_THROW_EX (forwarding_servant, + TAO_Forwarding_Servant (forward_to, + forward_to->_interface_repository_id ()), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + // Give ownership to the auto pointer. + auto_ptr<TAO_Forwarding_Servant> new_forwarding_servant (forwarding_servant); + + // Register the forwarding servant with the same object Id. this->activate_object_with_id_i (oid, forwarding_servant, - env); -} - -#endif /* TAO_HAS_MINIMUM_CORBA */ - -TAO_POA * -TAO_POA::locate_poa_i (const TAO_ObjectKey &key, - PortableServer::ObjectId &id, - CORBA::Environment &env) -{ - ACE_FUNCTION_TIMEPROBE (TAO_POA_LOCATE_POA_I_START); - - TAO_POA::String poa_name; - CORBA::Boolean persistent = 0; - CORBA::Boolean system_id = 0; - TAO_Temporary_Creation_Time poa_creation_time; - - int result = this->parse_key (key, - poa_name, - id, - persistent, - system_id, - poa_creation_time); - if (result != 0) - { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; - } - - TAO_POA *poa = this->find_POA_i (poa_name, - persistent, - env); - if (env.exception () != 0) - return 0; - - // Make sure it is not an "old" objectId - if (!poa->persistent () && - poa->creation_time () != poa_creation_time) - { - CORBA::Exception *exception = new CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; - } + ACE_TRY_ENV); + ACE_CHECK; - return poa; + // Finally everything is fine. Make sure to take ownership away + // from the auto pointer. + new_forwarding_servant.release (); } -int -TAO_POA::locate_servant (const TAO_ObjectKey &key, - CORBA::Environment &env) -{ - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), -1, env); - - PortableServer::Servant servant = 0; - TAO_POA::LOCATION_RESULT result = this->locate_servant_i (key, servant, env); - - switch (result) - { - case TAO_POA::FOUND: - // Optimistic attitude - case TAO_POA::DEFAULT_SERVANT: - case TAO_POA::SERVANT_MANAGER: - return 0; - - case TAO_POA::NOT_FOUND: - return -1; - } - - return -1; -} - -PortableServer::Servant -TAO_POA::find_servant (const TAO_ObjectKey &key, - CORBA::Environment &env) -{ - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - - PortableServer::Servant servant = 0; - TAO_POA::LOCATION_RESULT result = this->locate_servant_i (key, servant, env); - - switch (result) - { - case TAO_POA::FOUND: - return servant; - - case TAO_POA::DEFAULT_SERVANT: - case TAO_POA::SERVANT_MANAGER: - case TAO_POA::NOT_FOUND: - return 0; - } - - return 0; -} +#endif /* TAO_HAS_MINIMUM_CORBA */ TAO_POA::LOCATION_RESULT -TAO_POA::locate_servant_i (const TAO_ObjectKey &key, +TAO_POA::locate_servant_i (const PortableServer::ObjectId &system_id, PortableServer::Servant &servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::ObjectId id; - - TAO_POA *poa = this->locate_poa_i (key, - id, - env); - if (env.exception () != 0) - return TAO_POA::NOT_FOUND; - // If the POA has the RETAIN policy, the POA looks in the Active // Object Map to find if there is a servant associated with the // Object Id value from the request. If such a servant exists, // return TAO_POA::FOUND. - if (poa->policies ().servant_retention () == PortableServer::RETAIN && - poa->active_object_map ().find_servant_using_system_id (id, servant) != -1) + if (this->policies ().servant_retention () == PortableServer::RETAIN && + this->active_object_map ().find_servant_using_system_id (system_id, servant) != -1) // Success return TAO_POA::FOUND; @@ -2125,7 +2001,7 @@ TAO_POA::locate_servant_i (const TAO_ObjectKey &key, // If the USE_ACTIVE_OBJECT_MAP_ONLY policy is in effect, the POA raises // the OBJECT_NOT_EXIST system exception. - if (poa->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) + if (this->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) return TAO_POA::NOT_FOUND; #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -2134,9 +2010,9 @@ TAO_POA::locate_servant_i (const TAO_ObjectKey &key, // has been associated with the POA, return // TAO_POA::DEFAULT_SERVANT. If no servant has been associated with // the POA, return TAO_POA::NOT_FOUND. - if (poa->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) + if (this->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) { - if (poa->default_servant_ == 0) + if (this->default_servant_ == 0) return TAO_POA::NOT_FOUND; else // Success @@ -2147,10 +2023,10 @@ TAO_POA::locate_servant_i (const TAO_ObjectKey &key, // has been associated with the POA, return // TAO_POA::SERVANT_MANAGER. If no servant manager has been // associated with the POA, return TAO_POA::NOT_FOUND. - if (poa->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) + if (this->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) { - if (CORBA::is_nil (poa->servant_activator_.in ()) && - CORBA::is_nil (poa->servant_locator_.in ())) + if (CORBA::is_nil (this->servant_activator_.in ()) && + CORBA::is_nil (this->servant_locator_.in ())) return TAO_POA::NOT_FOUND; else // Success @@ -2164,33 +2040,25 @@ TAO_POA::locate_servant_i (const TAO_ObjectKey &key, } PortableServer::Servant -TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, - const char *operation, - PortableServer::ObjectId &system_id, - TAO_POA *&poa_impl, - TAO_ORB_Core *orb_core, - CORBA::Environment &env) +TAO_POA::locate_servant_i (const char *operation, + const PortableServer::ObjectId &system_id, + TAO_POA_Current *poa_current, + CORBA::Environment &ACE_TRY_ENV) { - ACE_FUNCTION_TIMEPROBE (TAO_POA_LOCATE_POA_AND_SERVANT_I_START); - - poa_impl = this->locate_poa_i (key, - system_id, - env); - if (env.exception () != 0) - return 0; + // ACE_FUNCTION_TIMEPROBE (TAO_POA_LOCATE_POA_AND_SERVANT_I_START); // If the POA has the RETAIN policy, the POA looks in the Active // Object Map to find if there is a servant associated with the // Object Id value from the request. If such a servant exists, the // POA invokes the appropriate method on the servant. - if (poa_impl->policies ().servant_retention () == PortableServer::RETAIN) + if (this->policies ().servant_retention () == PortableServer::RETAIN) { PortableServer::Servant servant = 0; { ACE_FUNCTION_TIMEPROBE (TAO_POA_FIND_SERVANT_START); - if (poa_impl->active_object_map ().find_servant_using_system_id (system_id, servant) != -1) + if (this->active_object_map ().find_servant_using_system_id (system_id, servant) != -1) // Success return servant; } @@ -2202,11 +2070,10 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, // If the USE_ACTIVE_OBJECT_MAP_ONLY policy is in effect, the POA raises // the OBJECT_NOT_EXIST system exception. - if (poa_impl->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) + if (this->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) { - CORBA::Exception *exception = new CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), + 0); } #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -2216,18 +2083,17 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, // appropriate method on that servant. If no servant has been // associated with the POA, the POA raises the OBJ_ADAPTER system // exception. - if (poa_impl->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) + if (this->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) { - if (poa_impl->default_servant_ == 0) + if (this->default_servant_ == 0) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } else { // Success - return poa_impl->default_servant_; + return this->default_servant_; } } @@ -2249,39 +2115,38 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, // ForwardRequest exception. This exception includes an object // reference. // - if (poa_impl->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) + if (this->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) { - if (CORBA::is_nil (poa_impl->servant_activator_.in ()) && - CORBA::is_nil (poa_impl->servant_locator_.in ())) + if (CORBA::is_nil (this->servant_activator_.in ()) && + CORBA::is_nil (this->servant_locator_.in ())) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } - PortableServer::POA_var poa = poa_impl->_this (env); - if (env.exception () != 0) - return 0; + PortableServer::POA_var poa = this->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (0); PortableServer::ObjectId_var user_id; if (this->active_object_map ().find_user_id_using_system_id (system_id, user_id.out ()) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } - if (poa_impl->policies ().servant_retention () == PortableServer::RETAIN) + if (this->policies ().servant_retention () == PortableServer::RETAIN) { // @@ // Invocations of incarnate on the servant manager are serialized. // Invocations of etherealize on the servant manager are serialized. // Invocations of incarnate and etherealize on the servant manager are mutually exclusive. - PortableServer::Servant servant = poa_impl->servant_activator_->incarnate (user_id.in (), - poa.in (), - env); - if (env.exception () != 0 || servant == 0) + PortableServer::Servant servant = this->servant_activator_->incarnate (user_id.in (), + poa.in (), + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + if (servant == 0) return 0; // If the incarnate operation returns a servant that is @@ -2290,12 +2155,11 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, // the POA policy and is considered to be in error. The POA // will raise an OBJ_ADAPTER system exception for the // request. - if (poa_impl->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && - poa_impl->active_object_map ().is_servant_in_map (servant)) + if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && + this->active_object_map ().is_servant_in_map (servant)) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } // The POA enters the returned Servant value into the Active @@ -2306,9 +2170,8 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, user_id.in (), system_id) == -1) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } // Success @@ -2328,16 +2191,17 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, // process the request, and postinvoke the object. // PortableServer::ServantLocator::Cookie cookie; - PortableServer::Servant servant = poa_impl->servant_locator_->preinvoke (user_id.in (), - poa.in (), - operation, - cookie, - env); - if (env.exception () != 0 || servant == 0) + PortableServer::Servant servant = this->servant_locator_->preinvoke (user_id.in (), + poa.in (), + operation, + cookie, + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); + + if (servant == 0) return 0; // Remember the cookie - TAO_POA_Current *poa_current = orb_core->poa_current (); poa_current->locator_cookie (cookie); // Success @@ -2348,143 +2212,14 @@ TAO_POA::locate_poa_and_servant_i (const TAO_ObjectKey &key, #endif /* TAO_HAS_MINIMUM_CORBA */ // Failure - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; -} - -void -TAO_POA::dispatch_servant (const TAO_ObjectKey &key, - CORBA::ServerRequest &req, - void *context, - TAO_ORB_Core *orb_core, - CORBA::Environment &env) -{ - ACE_FUNCTION_TIMEPROBE (TAO_POA_DISPATCH_SERVANT_START); - - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD (ACE_Lock, monitor, this->lock (), env); - - this->dispatch_servant_i (key, req, context, orb_core, env); -} - -void -TAO_POA::dispatch_servant_i (const TAO_ObjectKey &key, - CORBA::ServerRequest &req, - void *context, - TAO_ORB_Core *orb_core, - CORBA::Environment &env) -{ - PortableServer::ObjectId id; - TAO_POA *poa = 0; - const char *operation = req.operation (); - - // @@ Lots on non-exception safe code here!! - - // Setup for POA Current - TAO_POA_Current current_context; - - // @@ This call changes the state, but if an exception is raised the - // context will not be reset, you need a helper class that can do - // that in the destructor, what about using the TAO_POA_Current - // class itself? - - // Set the current context and remember the old one - TAO_POA_Current *previous_context = orb_core->poa_current (¤t_context); - - PortableServer::Servant servant = this->locate_poa_and_servant_i (key, - operation, - id, - poa, - orb_core, - env); - - // @@ We should use the TRY macros here, notice that you detect the - // exception but you do not attempt to fix the problems above - if (env.exception () != 0 || servant == 0) - return; - - // @@ Yet another place where you change the state without a class - // whose destructor will return things to normal.... - - // Setup for upcall - poa->pre_invoke (key, - id, - servant, - ¤t_context, - env); - - { - ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_DISPATCH_START); - - // Upcall - servant->_dispatch (req, - context, - env); - } - - // @@ This shoul be done by a destructor.... - - // Cleanup from upcall - poa->post_invoke (servant, - operation, - ¤t_context, - env); - - // @@ this should also be done by a destructor.... - - // Reset old context - orb_core->poa_current (previous_context); - -} - -void -TAO_POA::pre_invoke (const TAO_ObjectKey &key, - const PortableServer::ObjectId &id, - PortableServer::Servant servant, - TAO_POA_Current *poa_current, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - - poa_current->POA_impl (this); - poa_current->object_key (key); - poa_current->object_id (id); - poa_current->servant (servant); -} - -void -TAO_POA::post_invoke (PortableServer::Servant servant, - const char *operation, - TAO_POA_Current *poa_current, - CORBA::Environment &env) -{ - -#if !defined (TAO_HAS_MINIMUM_CORBA) - - PortableServer::ServantLocator::Cookie cookie = poa_current->locator_cookie (); - - if (cookie != 0) - { - PortableServer::POA_var poa = poa_current->get_POA (env); - - this->servant_locator_->postinvoke (poa_current->object_id (), - poa.in (), - operation, - cookie, - servant, - env); - } - -#endif /* TAO_HAS_MINIMUM_CORBA */ - - // poa_current->clear (); - + ACE_THROW_RETURN (CORBA::OBJ_ADAPTER (), + 0); } +/* static */ int TAO_POA::parse_key (const TAO_ObjectKey &key, - TAO_POA::String &poa_name, + TAO_Object_Adapter::poa_name &poa_system_name, PortableServer::ObjectId &id, CORBA::Boolean &persistent, CORBA::Boolean &system_id, @@ -2492,18 +2227,19 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, { ACE_FUNCTION_TIMEPROBE (TAO_POA_PARSE_KEY_START); - int starting_at = 0; + CORBA::ULong starting_at = 0; + const CORBA::Octet *key_data = key.get_buffer (); #if !defined (TAO_NO_IOR_TABLE) // Skip the TAO Object Key Prefix. - starting_at = TAO_OBJECTKEY_PREFIX_SIZE; + starting_at += TAO_OBJECTKEY_PREFIX_SIZE; #endif // Check the system id indicator - char system_id_key_type = key[starting_at]; - if (system_id_key_type == this->system_id_key_char ()) + char system_id_key_type = key_data[starting_at]; + if (system_id_key_type == TAO_POA::system_id_key_char ()) system_id = 1; - else if (system_id_key_type == this->user_id_key_char ()) + else if (system_id_key_type == TAO_POA::user_id_key_char ()) system_id = 0; else // Incorrect key @@ -2512,25 +2248,16 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, // Skip past the system id indicator starting_at += TAO_POA::system_id_key_type_length (); - // Try to find the last separator - int last_token_position = 0; - if (system_id) - // The minus one is because we want <last_token_position> to point - // to the separator - last_token_position = key.length () - this->active_object_map ().system_id_size () - 1; - else - last_token_position = this->rfind (key, TAO_POA::name_separator ()); - - // If not found, the name is not correct - if (last_token_position == TAO_POA::String::npos) - return -1; + // Assume persistent key when the POA_NO_TIMESTAMP is enabled. + persistent = 1; #if !defined (POA_NO_TIMESTAMP) + // Check the persistence indicator - char persistent_key_type = key[starting_at]; - if (persistent_key_type == this->persistent_key_char ()) + char persistent_key_type = key_data[starting_at]; + if (persistent_key_type == TAO_POA::persistent_key_char ()) persistent = 1; - else if (persistent_key_type == this->transient_key_char ()) + else if (persistent_key_type == TAO_POA::transient_key_char ()) persistent = 0; else // Incorrect key @@ -2542,7 +2269,7 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, if (!persistent) { // Take the creation time for the timestamp - poa_creation_time.creation_time (&key[starting_at]); + poa_creation_time.creation_time (key_data + starting_at); // Skip past the timestamp starting_at += TAO_Creation_Time::creation_time_length (); @@ -2550,22 +2277,37 @@ TAO_POA::parse_key (const TAO_ObjectKey &key, #endif /* POA_NO_TIMESTAMP */ - // Take the substring from <starting_at> to last_token_position for - // the POA name - int how_many = last_token_position - starting_at; - poa_name.set ((const char *) &key[starting_at], - how_many, - 0); + CORBA::ULong poa_name_size = 0; + if (!persistent) + { + poa_name_size = TAO_Object_Adapter::transient_poa_name_size (); + } + else if (system_id) + { + poa_name_size = key.length () - starting_at - TAO_Active_Object_Map::system_id_size (); + } + else + { + ACE_OS::memcpy (&poa_name_size, + key_data + starting_at, + sizeof (poa_name_size)); + ACE_NTOHL (poa_name_size); + starting_at += sizeof (poa_name_size); + } + + poa_system_name.replace (poa_name_size, + poa_name_size, + (CORBA::Octet *) key_data + starting_at, + 0); - // Take the substring from (last_token_position + separator_length) - // to length for the objectId - starting_at = last_token_position + TAO_POA::name_separator_length (); - how_many = key.length () - starting_at; + starting_at += poa_name_size; + + CORBA::ULong id_size = key.length () - starting_at; // Reset the Id - id.replace (how_many, - how_many, - (CORBA::Octet *) &key[starting_at], + id.replace (id_size, + id_size, + (CORBA::Octet *) key_data + starting_at, 0); // Success @@ -2576,11 +2318,15 @@ TAO_ObjectKey * TAO_POA::create_object_key (const PortableServer::ObjectId &id) { #if !defined (POA_NO_TIMESTAMP) - int creation_time_length = 0; - if (!this->persistent ()) - creation_time_length = TAO_Creation_Time::creation_time_length (); + CORBA::ULong creation_time_length = 0; + if (!this->persistent_) + { + creation_time_length = TAO_Creation_Time::creation_time_length (); + } #endif /* POA_NO_TIMESTAMP */ + CORBA::ULong poa_name_length = this->system_name_->length (); + // Calculate the space required for the key int buffer_size = #if !defined (TAO_NO_IOR_TABLE) @@ -2591,21 +2337,25 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) this->persistent_key_type_length () + creation_time_length + #endif /* POA_NO_TIMESTAMP */ - this->complete_name_.length () + - TAO_POA::name_separator_length () + + poa_name_length + id.length (); - // Keeps track of where the next infomation goes; start at 0 byte - int starting_at = 0; + if (this->persistent_ && + !this->system_id_) + { + buffer_size += sizeof (poa_name_length); + } // Create the buffer for the key CORBA::Octet *buffer = TAO_ObjectKey::allocbuf (buffer_size); -#if !defined (TAO_NO_IOR_TABLE) + // Keeps track of where the next infomation goes; start at 0 byte + CORBA::ULong starting_at = 0; +#if !defined (TAO_NO_IOR_TABLE) ACE_OS::memcpy (&buffer[starting_at], - &objectkey_prefix[0], - TAO_OBJECTKEY_PREFIX_SIZE); + &objectkey_prefix[0], + TAO_OBJECTKEY_PREFIX_SIZE); starting_at += TAO_OBJECTKEY_PREFIX_SIZE; #endif @@ -2627,17 +2377,24 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) creation_time_length); starting_at += creation_time_length; } + #endif /* POA_NO_TIMESTAMP */ + if (this->persistent_ && + !this->system_id_) + { + ACE_HTONL (poa_name_length); + ACE_OS::memcpy (&buffer[starting_at], + &poa_name_length, + sizeof (poa_name_length)); + starting_at += sizeof (poa_name_length); + } + // Put the POA name into the buffer ACE_OS::memcpy (&buffer[starting_at], - this->complete_name_.c_str (), - this->complete_name_.length ()); - starting_at += this->complete_name_.length (); - - // Add the name separator - buffer[starting_at] = (CORBA::Octet) TAO_POA::name_separator (); - starting_at += TAO_POA::name_separator_length (); + this->system_name_->get_buffer (), + this->system_name_->length ()); + starting_at += this->system_name_->length (); // Then copy the ID into the key ACE_OS::memcpy (&buffer[starting_at], @@ -2646,10 +2403,15 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) // Create the key, giving the ownership of the buffer to the // sequence. - return new TAO_ObjectKey (buffer_size, - buffer_size, - buffer, - 1); + TAO_ObjectKey *key = 0; + ACE_NEW_RETURN (key, + TAO_ObjectKey (buffer_size, + buffer_size, + buffer, + 1), + 0); + + return key; } int @@ -2676,81 +2438,36 @@ TAO_POA::is_poa_generated_id (const PortableServer::ObjectId &id) #endif /* POA_NAME_IN_POA_GENERATED_ID */ } -int -TAO_POA::is_poa_generated_key (const TAO_ObjectKey &key) -{ - // Grab the buffer - const char *key_buffer = (const char *) key.get_buffer (); - - // Check to see if the complete POA name is the first part of the - // key - return - this->complete_name_.length () < key.length () && - ACE_OS::strncmp (key_buffer, - this->complete_name_.c_str (), - this->complete_name_.length ()) == 0; -} - -int -TAO_POA::leaf_poa_name (const TAO_POA::String &adapter_name, - CORBA::Environment &env) -{ - // This method does not throw any exceptions - ACE_UNUSED_ARG (env); - - // Try to find the name separator - if (adapter_name.find (TAO_POA::name_separator ()) == TAO_POA::String::npos) - // If not found, the name was a leaf - return 1; - else - // If found, the name was not a leaf - return 0; -} - void -TAO_POA::parse_poa_name (const TAO_POA::String &adapter_name, - TAO_POA::String &topmost_poa_name, - TAO_POA::String &tail_poa_name, - CORBA::Environment &env) +TAO_POA::set_folded_name (void) { - // Try to find the name separator - int token_position = adapter_name.find (TAO_POA::name_separator ()); + CORBA::ULong length = 0; + CORBA::ULong parent_length = 0; - // If not found, the name was a leaf, throw exception - if (token_position == TAO_POA::String::npos) + if (this->parent_ != 0) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return; + parent_length = this->parent_->folded_name ().length (); + length += parent_length; } - else - { - // If found, take the substring from 0 to token_position - int starting_at = 0; - int how_many = token_position - starting_at; - topmost_poa_name.set (&adapter_name[starting_at], - how_many, - 0); - // Take the substring from (token_position + separator_length) - // to length - starting_at = token_position + TAO_POA::name_separator_length (); - how_many = adapter_name.length () - starting_at; - tail_poa_name.set (&adapter_name[starting_at], - how_many, - 0); - } -} + length += this->name_.length (); + length += TAO_POA::name_separator_length (); + + this->folded_name_.length (length); + CORBA::Octet *folded_name_buffer = this->folded_name_.get_buffer (); -void -TAO_POA::set_complete_name (void) -{ if (this->parent_ != 0) { - this->complete_name_ += this->parent_->complete_name (); - this->complete_name_ += TAO_POA::name_separator (); + ACE_OS::memcpy (folded_name_buffer, + this->parent_->folded_name ().get_buffer (), + parent_length); } - this->complete_name_ += this->name_; + + ACE_OS::memcpy (&folded_name_buffer[parent_length], + this->name_.c_str (), + this->name_.length ()); + + folded_name_buffer[length - TAO_POA::name_separator_length ()] = TAO_POA::name_separator (); } PortableServer::ObjectId * @@ -2770,10 +2487,15 @@ TAO_POA::string_to_ObjectId (const char *string) ACE_OS::memcpy (buffer, string, buffer_size); // Create and return a new ID - return new PortableServer::ObjectId (buffer_size, - buffer_size, - buffer, - 1); + PortableServer::ObjectId *id = 0; + ACE_NEW_RETURN (id, + PortableServer::ObjectId (buffer_size, + buffer_size, + buffer, + 1), + 0); + + return id; } PortableServer::ObjectId * @@ -2787,10 +2509,15 @@ TAO_POA::string_to_ObjectId (const char *string, ACE_OS::memcpy (buffer, string, size); // Create and return a new ID - return new PortableServer::ObjectId (size, - size, - buffer, - 1); + PortableServer::ObjectId *id = 0; + ACE_NEW_RETURN (id, + PortableServer::ObjectId (size, + size, + buffer, + 1), + 0); + + return id; } PortableServer::ObjectId * @@ -2812,10 +2539,15 @@ TAO_POA::wstring_to_ObjectId (const CORBA::WChar *string) ACE_OS::memcpy (buffer, string, buffer_size); // Create a new ID - return new PortableServer::ObjectId (buffer_size, - buffer_size, - buffer, - 1); + PortableServer::ObjectId *id = 0; + ACE_NEW_RETURN (id, + PortableServer::ObjectId (buffer_size, + buffer_size, + buffer, + 1), + 0); + + return id; } CORBA::String @@ -2854,160 +2586,188 @@ TAO_POA::ObjectId_to_wstring (const PortableServer::ObjectId &id) PortableServer::ThreadPolicy_ptr TAO_POA::create_thread_policy (PortableServer::ThreadPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::ThreadPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ThreadPolicy::_nil ()); - auto_ptr<TAO_Thread_Policy> new_policy (new TAO_Thread_Policy (value, rootPOA.in ())); - PortableServer::ThreadPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::ThreadPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Thread_Policy *thread_policy = 0; + ACE_NEW_THROW_EX (thread_policy, + TAO_Thread_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::ThreadPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Thread_Policy> new_thread_policy (thread_policy); + + PortableServer::ThreadPolicy_var result = new_thread_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ThreadPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_thread_policy.release (); + return result._retn (); } #endif /* TAO_HAS_MINIMUM_CORBA */ PortableServer::LifespanPolicy_ptr TAO_POA::create_lifespan_policy (PortableServer::LifespanPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::LifespanPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::LifespanPolicy::_nil ()); - auto_ptr<TAO_Lifespan_Policy> new_policy (new TAO_Lifespan_Policy (value, rootPOA.in ())); - PortableServer::LifespanPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::LifespanPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Lifespan_Policy *lifespan_policy = 0; + ACE_NEW_THROW_EX (lifespan_policy, + TAO_Lifespan_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::LifespanPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Lifespan_Policy> new_lifespan_policy (lifespan_policy); + + PortableServer::LifespanPolicy_var result = new_lifespan_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::LifespanPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_lifespan_policy.release (); + return result._retn (); } PortableServer::IdUniquenessPolicy_ptr TAO_POA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::IdUniquenessPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::IdUniquenessPolicy::_nil ()); - auto_ptr<TAO_Id_Uniqueness_Policy> new_policy (new TAO_Id_Uniqueness_Policy (value, rootPOA.in ())); - PortableServer::IdUniquenessPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::IdUniquenessPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Id_Uniqueness_Policy *id_uniqueness_policy = 0; + ACE_NEW_THROW_EX (id_uniqueness_policy, + TAO_Id_Uniqueness_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::IdUniquenessPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Id_Uniqueness_Policy> new_id_uniqueness_policy (id_uniqueness_policy); + + PortableServer::IdUniquenessPolicy_var result = new_id_uniqueness_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::IdUniquenessPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_id_uniqueness_policy.release (); + return result._retn (); } PortableServer::IdAssignmentPolicy_ptr TAO_POA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::IdAssignmentPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::IdAssignmentPolicy::_nil ()); - auto_ptr<TAO_Id_Assignment_Policy> new_policy (new TAO_Id_Assignment_Policy (value, rootPOA.in ())); - PortableServer::IdAssignmentPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::IdAssignmentPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Id_Assignment_Policy *id_assignment_policy = 0; + ACE_NEW_THROW_EX (id_assignment_policy, + TAO_Id_Assignment_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::IdAssignmentPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Id_Assignment_Policy> new_id_assignment_policy (id_assignment_policy); + + PortableServer::IdAssignmentPolicy_var result = new_id_assignment_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::IdAssignmentPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_id_assignment_policy.release (); + return result._retn (); } #if !defined (TAO_HAS_MINIMUM_CORBA) PortableServer::ImplicitActivationPolicy_ptr TAO_POA::create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::ImplicitActivationPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ImplicitActivationPolicy::_nil ()); - auto_ptr<TAO_Implicit_Activation_Policy> new_policy (new TAO_Implicit_Activation_Policy (value, rootPOA.in ())); - PortableServer::ImplicitActivationPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::ImplicitActivationPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Implicit_Activation_Policy *implicit_activation_policy = 0; + ACE_NEW_THROW_EX (implicit_activation_policy, + TAO_Implicit_Activation_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::ImplicitActivationPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Implicit_Activation_Policy> new_implicit_activation_policy (implicit_activation_policy); + + PortableServer::ImplicitActivationPolicy_var result = new_implicit_activation_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ImplicitActivationPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_implicit_activation_policy.release (); + return result._retn (); } PortableServer::ServantRetentionPolicy_ptr TAO_POA::create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::ServantRetentionPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ServantRetentionPolicy::_nil ()); - auto_ptr<TAO_Servant_Retention_Policy> new_policy (new TAO_Servant_Retention_Policy (value, rootPOA.in ())); - PortableServer::ServantRetentionPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::ServantRetentionPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Servant_Retention_Policy *servant_retention_policy = 0; + ACE_NEW_THROW_EX (servant_retention_policy, + TAO_Servant_Retention_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::ServantRetentionPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Servant_Retention_Policy> new_servant_retention_policy (servant_retention_policy); + + PortableServer::ServantRetentionPolicy_var result = new_servant_retention_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::ServantRetentionPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_servant_retention_policy.release (); + return result._retn (); } PortableServer::RequestProcessingPolicy_ptr TAO_POA::create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - PortableServer::POA_var rootPOA = TAO_ORB_Core_instance ()->root_poa_reference (env); - // Check for exceptions - if (env.exception () != 0) - return PortableServer::RequestProcessingPolicy::_nil (); + PortableServer::POA_var rootPOA = this->orb_core_.root_poa_reference (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::RequestProcessingPolicy::_nil ()); - auto_ptr<TAO_Request_Processing_Policy> new_policy (new TAO_Request_Processing_Policy (value, rootPOA.in ())); - PortableServer::RequestProcessingPolicy_var result = new_policy->_this (env); - if (env.exception () != 0) - return PortableServer::RequestProcessingPolicy::_nil (); - else - { - // Make sure that the auto_ptr does not delete the - // implementation - new_policy.release (); - return result._retn (); - } + TAO_Request_Processing_Policy *request_processing_policy = 0; + ACE_NEW_THROW_EX (request_processing_policy, + TAO_Request_Processing_Policy (value, + rootPOA.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (PortableServer::RequestProcessingPolicy::_nil ()); + + // Give ownership of the copy to the auto pointer. + auto_ptr<TAO_Request_Processing_Policy> new_request_processing_policy (request_processing_policy); + + PortableServer::RequestProcessingPolicy_var result = new_request_processing_policy->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::RequestProcessingPolicy::_nil ()); + + // Make sure that the auto_ptr does not delete the implementation + // object. + new_request_processing_policy.release (); + return result._retn (); } #endif /* TAO_HAS_MINIMUM_CORBA */ @@ -3096,7 +2856,7 @@ TAO_POA::decode_string_to_sequence (TAO_Unbounded_Sequence<CORBA::Octet> &seq, CORBA::Boolean TAO_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, const char *name, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // Default policies CORBA::PolicyList default_policies; @@ -3105,34 +2865,30 @@ TAO_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, PortableServer::POA_var child = parent->create_POA (name, PortableServer::POAManager::_nil (), default_policies, - env); + ACE_TRY_ENV); + ACE_CHECK_RETURN (0); - if (env.exception () != 0) - return 0; - else + ACE_TRY { - PortableServer::AdapterActivator_var activator = this->_this (env); - if (env.exception () != 0) - { - child->destroy (0, - 0, - env); - return 0; - } - - child->the_activator (activator.in (), env); + PortableServer::AdapterActivator_var activator = this->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; - if (env.exception () != 0) - { - child->destroy (0, - 0, - env); - return 0; - } + child->the_activator (activator.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + child->destroy (1, + 1, + ACE_TRY_ENV); - // Finally everything is fine - return 1; + return 0; } + ACE_ENDTRY; + ACE_CHECK_RETURN (0); + + // Finally everything is fine + return 1; } #endif /* TAO_HAS_MINIMUM_CORBA */ @@ -3148,14 +2904,19 @@ TAO_POA_Current::TAO_POA_Current (void) #endif /* TAO_HAS_MINIMUM_CORBA */ - servant_ (0) + servant_ (0), + operation_ (0), + orb_core_ (0), + previous_current_ (0) { } TAO_POA_Current::TAO_POA_Current (TAO_POA *impl, const TAO_ObjectKey &key, const PortableServer::ObjectId &id, - PortableServer::Servant servant) + PortableServer::Servant servant, + const char *operation, + TAO_ORB_Core &orb_core) : poa_impl_ (impl), object_id_ (&id), object_key_ (&key), @@ -3166,44 +2927,78 @@ TAO_POA_Current::TAO_POA_Current (TAO_POA *impl, #endif /* TAO_HAS_MINIMUM_CORBA */ - servant_ (servant) -{} + servant_ (servant), + operation_ (operation), + orb_core_ (&orb_core), + previous_current_ (0) +{ + // Set the current context and remember the old one. + this->previous_current_ = this->orb_core_->poa_current (this); +} TAO_POA_Current::~TAO_POA_Current (void) { +#if !defined (TAO_HAS_MINIMUM_CORBA) + + if (this->cookie_ != 0) + { + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + PortableServer::POA_var poa = this->get_POA (ACE_TRY_ENV); + ACE_TRY_CHECK; + + this->poa_impl_->servant_locator_->postinvoke (this->object_id (), + poa.in (), + this->operation_, + this->cookie_, + this->servant_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore errors from servant locator .... + } + ACE_ENDTRY; + } + +#endif /* TAO_HAS_MINIMUM_CORBA */ + + // Reset the old context. + this->orb_core_->poa_current (this->previous_current_); } PortableServer::POA_ptr -TAO_POA_Current::get_POA (CORBA::Environment &env) +TAO_POA_Current::get_POA (CORBA::Environment &ACE_TRY_ENV) { if (!this->context_is_valid ()) { - CORBA::Exception *exception = new PortableServer::Current::NoContext; - env.exception (exception); - return PortableServer::POA::_nil (); + ACE_THROW_RETURN (PortableServer::Current::NoContext (), + PortableServer::POA::_nil ()); } - PortableServer::POA_var result = this->poa_impl_->_this (env); - if (env.exception () != 0) - return PortableServer::POA::_nil (); - else - return result._retn (); + PortableServer::POA_var result = this->poa_impl_->_this (ACE_TRY_ENV); + ACE_CHECK_RETURN (PortableServer::POA::_nil ()); + + return result._retn (); } PortableServer::ObjectId * -TAO_POA_Current::get_object_id (CORBA::Environment &env) +TAO_POA_Current::get_object_id (CORBA::Environment &ACE_TRY_ENV) { if (!this->context_is_valid ()) { - CORBA::Exception *exception = new PortableServer::Current::NoContext; - env.exception (exception); - return 0; + ACE_THROW_RETURN (PortableServer::Current::NoContext (), + 0); } // Create a new one and pass it back return new PortableServer::ObjectId (*this->object_id_); } + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Auto_Basic_Ptr<TAO_Id_Assignment_Policy>; template class ACE_Auto_Basic_Ptr<TAO_Id_Uniqueness_Policy>; @@ -3216,10 +3011,14 @@ template class ACE_Auto_Basic_Ptr<TAO_Implicit_Activation_Policy>; template class ACE_Auto_Basic_Ptr<TAO_Servant_Retention_Policy>; template class ACE_Auto_Basic_Ptr<TAO_Request_Processing_Policy>; +template class ACE_Auto_Basic_Ptr<TAO_Forwarding_Servant>; + #endif /* TAO_HAS_MINIMUM_CORBA */ //template class ACE_Auto_Basic_Ptr<TAO_Active_Object_Map_Iterator_Impl>; template class ACE_Auto_Basic_Ptr<TAO_POA>; +template class ACE_Auto_Basic_Ptr<TAO_Active_Object_Map>; +template class ACE_Auto_Basic_Ptr<TAO_POA_Manager>; template class ACE_Lock_Adapter<ACE_Null_Mutex>; #if defined (ACE_HAS_THREADS) template class ACE_Lock_Adapter<ACE_Recursive_Thread_Mutex>; @@ -3253,10 +3052,14 @@ template class auto_ptr<TAO_Implicit_Activation_Policy>; template class auto_ptr<TAO_Servant_Retention_Policy>; template class auto_ptr<TAO_Request_Processing_Policy>; +template class auto_ptr<TAO_Forwarding_Servant>; + #endif /* TAO_HAS_MINIMUM_CORBA */ //template class auto_ptr<TAO_Active_Object_Map_Iterator_Impl>; template class auto_ptr<TAO_POA>; +template class auto_ptr<TAO_Active_Object_Map>; +template class auto_ptr<TAO_POA_Manager>; template class ACE_Node<TAO_POA *>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) #pragma instantiate ACE_Auto_Basic_Ptr<TAO_Id_Assignment_Policy> @@ -3270,10 +3073,14 @@ template class ACE_Node<TAO_POA *>; #pragma instantiate ACE_Auto_Basic_Ptr<TAO_Servant_Retention_Policy> #pragma instantiate ACE_Auto_Basic_Ptr<TAO_Request_Processing_Policy> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Forwarding_Servant> + #endif /* TAO_HAS_MINIMUM_CORBA */ //#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Active_Object_Map_Iterator_Impl> #pragma instantiate ACE_Auto_Basic_Ptr<TAO_POA> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_Active_Object_Map> +#pragma instantiate ACE_Auto_Basic_Ptr<TAO_POA_Manager> #pragma instantiate ACE_Lock_Adapter<ACE_Null_Mutex> #if defined (ACE_HAS_THREADS) #pragma instantiate ACE_Lock_Adapter<ACE_Recursive_Thread_Mutex> @@ -3307,9 +3114,13 @@ template class ACE_Node<TAO_POA *>; #pragma instantiate auto_ptr<TAO_Servant_Retention_Policy> #pragma instantiate auto_ptr<TAO_Request_Processing_Policy> +#pragma instantiate auto_ptr<TAO_Forwarding_Servant> + #endif /* TAO_HAS_MINIMUM_CORBA */ //#pragma instantiate auto_ptr<TAO_Active_Object_Map_Iterator_Impl> #pragma instantiate auto_ptr<TAO_POA> +#pragma instantiate auto_ptr<TAO_Active_Object_Map> +#pragma instantiate auto_ptr<TAO_POA_Manager> #pragma instantiate ACE_Node<TAO_POA *> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/POA.h b/TAO/tao/POA.h index 5ef636d9175..ce39d4c44a1 100644 --- a/TAO/tao/POA.h +++ b/TAO/tao/POA.h @@ -54,6 +54,9 @@ // POA Manager #include "tao/POAManager.h" +// Object Adapter +#include "tao/Object_Adapter.h" + class TAO_POA; #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -66,15 +69,15 @@ public: TAO_Thread_Policy (const TAO_Thread_Policy &new_policy); - virtual PortableServer::ThreadPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ThreadPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::ThreadPolicyValue value_; @@ -92,15 +95,15 @@ public: TAO_Lifespan_Policy (const TAO_Lifespan_Policy &rhs); - virtual PortableServer::LifespanPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::LifespanPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::LifespanPolicyValue value_; @@ -116,15 +119,15 @@ public: TAO_Id_Uniqueness_Policy (const TAO_Id_Uniqueness_Policy &rhs); - virtual PortableServer::IdUniquenessPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::IdUniquenessPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::IdUniquenessPolicyValue value_; @@ -140,15 +143,15 @@ public: TAO_Id_Assignment_Policy (const TAO_Id_Assignment_Policy &rhs); - virtual PortableServer::IdAssignmentPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::IdAssignmentPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::IdAssignmentPolicyValue value_; @@ -166,15 +169,15 @@ public: TAO_Implicit_Activation_Policy (const TAO_Implicit_Activation_Policy &rhs); - virtual PortableServer::ImplicitActivationPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ImplicitActivationPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::ImplicitActivationPolicyValue value_; @@ -190,15 +193,15 @@ public: TAO_Servant_Retention_Policy (const TAO_Servant_Retention_Policy &rhs); - virtual PortableServer::ServantRetentionPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ServantRetentionPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::ServantRetentionPolicyValue value_; @@ -214,15 +217,15 @@ public: TAO_Request_Processing_Policy (const TAO_Request_Processing_Policy &rhs); - virtual PortableServer::RequestProcessingPolicyValue value (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::RequestProcessingPolicyValue value (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::Policy_ptr copy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::Policy_ptr copy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual void destroy (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void destroy (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual CORBA::PolicyType policy_type (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::PolicyType policy_type (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr _default_POA (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); protected: PortableServer::RequestProcessingPolicyValue value_; @@ -264,12 +267,12 @@ public: virtual void request_processing (PortableServer::RequestProcessingPolicyValue value); virtual void parse_policies (const CORBA::PolicyList &policies, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); protected: virtual void parse_policy (const CORBA::Policy_ptr policy, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual int validity_check (void); @@ -302,7 +305,7 @@ public: virtual const void *creation_time (void) const; - static int creation_time_length (void); + static CORBA::ULong creation_time_length (void); int operator== (const TAO_Creation_Time &rhs) const; @@ -349,121 +352,117 @@ class TAO_Export TAO_POA : public POA_PortableServer::POA { public: - enum - { - TAO_OBJECTKEY_PREFIX_SIZE = 4 - }; - - static CORBA::Octet objectkey_prefix [TAO_OBJECTKEY_PREFIX_SIZE]; - + friend class TAO_Object_Adapter; + friend class TAO_POA_Current; + typedef ACE_CString String; virtual PortableServer::POA_ptr create_POA (const char *adapter_name, PortableServer::POAManager_ptr poa_manager, const CORBA::PolicyList &policies, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::POA_ptr find_POA (const char *adapter_name, CORBA::Boolean activate_it, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void destroy (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #if !defined (TAO_HAS_MINIMUM_CORBA) virtual PortableServer::ThreadPolicy_ptr create_thread_policy (PortableServer::ThreadPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #endif /* TAO_HAS_MINIMUM_CORBA */ virtual PortableServer::LifespanPolicy_ptr create_lifespan_policy (PortableServer::LifespanPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::IdUniquenessPolicy_ptr create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::IdAssignmentPolicy_ptr create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #if !defined (TAO_HAS_MINIMUM_CORBA) virtual PortableServer::ImplicitActivationPolicy_ptr create_implicit_activation_policy (PortableServer::ImplicitActivationPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::ServantRetentionPolicy_ptr create_servant_retention_policy (PortableServer::ServantRetentionPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::RequestProcessingPolicy_ptr create_request_processing_policy (PortableServer::RequestProcessingPolicyValue value, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #endif /* TAO_HAS_MINIMUM_CORBA */ - virtual CORBA::String the_name (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual CORBA::String the_name (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POA_ptr the_parent (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr the_parent (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::POAManager_ptr the_POAManager (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POAManager_ptr the_POAManager (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #if !defined (TAO_HAS_MINIMUM_CORBA) - virtual PortableServer::AdapterActivator_ptr the_activator (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::AdapterActivator_ptr the_activator (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void the_activator (PortableServer::AdapterActivator_ptr adapter_activator, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::ServantManager_ptr get_servant_manager (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ServantManager_ptr get_servant_manager (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void set_servant_manager (PortableServer::ServantManager_ptr imgr, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual PortableServer::Servant get_servant (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::Servant get_servant (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void set_servant (PortableServer::Servant servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #endif /* TAO_HAS_MINIMUM_CORBA */ virtual PortableServer::ObjectId *activate_object (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void activate_object_with_id (const PortableServer::ObjectId &id, PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void deactivate_object (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual CORBA::Object_ptr create_reference (const char *intf, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual CORBA::Object_ptr create_reference_with_id (const PortableServer::ObjectId &oid, const char *intf, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::ObjectId *servant_to_id (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual CORBA::Object_ptr servant_to_reference (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::Servant reference_to_servant (CORBA::Object_ptr reference, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::ObjectId *reference_to_id (CORBA::Object_ptr reference, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual PortableServer::Servant id_to_servant (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual CORBA::Object_ptr id_to_reference (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #if !defined (TAO_HAS_MINIMUM_CORBA) virtual void forward_object (const PortableServer::ObjectId &oid, CORBA::Object_ptr forward_to, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); #endif /* TAO_HAS_MINIMUM_CORBA */ @@ -484,118 +483,103 @@ public: static PortableServer::ObjectId *wstring_to_ObjectId (const CORBA::WChar *id); - TAO_POA (const String &adapter_name, + TAO_POA (const String &name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual TAO_POA *clone (const String &adapter_name, - TAO_POA_Manager &poa_manager, - const TAO_POA_Policies &policies, - TAO_POA *parent, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + ACE_Lock &lock, + TAO_ORB_Core &orb_core, + CORBA_Environment &ACE_TRY_ENV); virtual ~TAO_POA (void); - virtual void dispatch_servant (const TAO_ObjectKey &key, - CORBA::ServerRequest &req, - void *context, - TAO_ORB_Core *orb_core, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual int locate_servant (const TAO_ObjectKey &key, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + static char name_separator (void); - virtual PortableServer::Servant find_servant (const TAO_ObjectKey &key, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + static CORBA::ULong name_separator_length (void); - static char name_separator (void); + enum + { + TAO_OBJECTKEY_PREFIX_SIZE = 4 + }; - static char id_separator (void); + static CORBA::Octet objectkey_prefix[TAO_OBJECTKEY_PREFIX_SIZE]; - static CORBA::ULong name_separator_length (void); + const TAO_Object_Adapter::poa_name &folded_name (void) const; - static CORBA::ULong id_separator_length (void); + const TAO_Object_Adapter::poa_name &system_name (void) const; protected: + const ACE_CString &name (void) const; + virtual TAO_POA *create_POA (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual TAO_POA *create_POA_i (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); - virtual TAO_POA *find_POA (const String &adapter_name, - CORBA::Boolean activate_it, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual TAO_POA *find_POA_i (const String &adapter_name, + virtual TAO_POA *find_POA_i (const ACE_CString &child_name, CORBA::Boolean activate_it, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual TAO_POA *find_POA_i_optimized (const String &adapter_name, - CORBA::Boolean activate_it, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA::Environment &ACE_TRY_ENV); virtual void destroy_i (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); #if !defined (TAO_HAS_MINIMUM_CORBA) - virtual PortableServer::ServantManager_ptr get_servant_manager_i (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ServantManager_ptr get_servant_manager_i (CORBA_Environment &ACE_TRY_ENV); virtual void set_servant_manager_i (PortableServer::ServantManager_ptr imgr, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); - virtual PortableServer::Servant get_servant_i (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::Servant get_servant_i (CORBA_Environment &ACE_TRY_ENV); virtual void set_servant_i (PortableServer::Servant servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); #endif /* TAO_HAS_MINIMUM_CORBA */ virtual PortableServer::ObjectId *activate_object_i (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual void activate_object_with_id_i (const PortableServer::ObjectId &id, PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual void deactivate_object_i (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual CORBA::Object_ptr create_reference_i (const char *intf, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual CORBA::Object_ptr create_reference_with_id_i (const PortableServer::ObjectId &oid, const char *intf, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual PortableServer::ObjectId *servant_to_id_i (PortableServer::Servant servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual PortableServer::ObjectId *servant_to_system_id (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual PortableServer::ObjectId *servant_to_system_id_i (PortableServer::Servant p_servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual PortableServer::Servant id_to_servant_i (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); virtual CORBA::Object_ptr id_to_reference_i (const PortableServer::ObjectId &oid, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); #if !defined (TAO_HAS_MINIMUM_CORBA) virtual void forward_object_i (const PortableServer::ObjectId &oid, CORBA::Object_ptr forward_to, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); #endif /* TAO_HAS_MINIMUM_CORBA */ @@ -605,40 +589,20 @@ protected: virtual TAO_Active_Object_Map &active_object_map (void) const; - virtual void delete_child (const String &child, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual void delete_child_i (const String &child, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual String complete_name (void); + virtual int delete_child (const String &child); - virtual void set_complete_name (void); - - virtual int leaf_poa_name (const String &adapter_name, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual void parse_poa_name (const TAO_POA::String &adapter_name, - TAO_POA::String &topmost_poa_name, - TAO_POA::String &tail_poa_name, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual void set_folded_name (void); virtual TAO_ObjectKey *create_object_key (const PortableServer::ObjectId &id); virtual int is_poa_generated_id (const PortableServer::ObjectId &id); - virtual int is_poa_generated_key (const TAO_ObjectKey &key); - - virtual int parse_key (const TAO_ObjectKey &key, - String &poa_name, - PortableServer::ObjectId &id, - CORBA::Boolean &persistent, - CORBA::Boolean &system_id, - TAO_Temporary_Creation_Time &poa_creation_time); - - virtual int rfind (const TAO_ObjectKey &key, - char c, - int pos = TAO_POA::String::npos) const; + static int parse_key (const TAO_ObjectKey &key, + TAO_Object_Adapter::poa_name &poa_system_name, + PortableServer::ObjectId &id, + CORBA::Boolean &persistent, + CORBA::Boolean &system_id, + TAO_Temporary_Creation_Time &poa_creation_time); // Should really be protected, but some compilers complain public: @@ -651,37 +615,14 @@ public: }; protected: - virtual LOCATION_RESULT locate_servant_i (const TAO_ObjectKey &key, + virtual LOCATION_RESULT locate_servant_i (const PortableServer::ObjectId &id, PortableServer::Servant &servant, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual PortableServer::Servant locate_poa_and_servant_i (const TAO_ObjectKey &key, - const char *operation, - PortableServer::ObjectId &id, - TAO_POA *&poa_impl, - TAO_ORB_Core *orb_core, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual TAO_POA *locate_poa_i (const TAO_ObjectKey &key, - PortableServer::ObjectId &id, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual void dispatch_servant_i (const TAO_ObjectKey &key, - CORBA::ServerRequest &req, - void *context, - TAO_ORB_Core *orb_core, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual void pre_invoke (const TAO_ObjectKey &key, - const PortableServer::ObjectId &id, - PortableServer::Servant servant, - TAO_POA_Current *poa_current, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); - - virtual void post_invoke (PortableServer::Servant servant, - const char *operation, - TAO_POA_Current *poa_current, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); + + virtual PortableServer::Servant locate_servant_i (const char *operation, + const PortableServer::ObjectId &id, + TAO_POA_Current *poa_current, + CORBA_Environment &ACE_TRY_ENV); virtual const TAO_Creation_Time &creation_time (void); @@ -705,13 +646,11 @@ protected: static CORBA::ULong system_id_key_type_length (void); - virtual void create_internal_lock (void); - - virtual void create_active_object_map (void); - String name_; - String complete_name_; + TAO_Object_Adapter::poa_name folded_name_; + + TAO_Object_Adapter::poa_name_var system_name_; TAO_POA_Manager &poa_manager_; @@ -740,7 +679,7 @@ protected: CHILDREN children_; - ACE_Lock *lock_; + ACE_Lock &lock_; int closing_down_; @@ -749,6 +688,8 @@ protected: int system_id_; TAO_Creation_Time creation_time_; + + TAO_ORB_Core &orb_core_; }; #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -759,7 +700,7 @@ public: virtual CORBA::Boolean unknown_adapter (PortableServer::POA_ptr parent, const char *name, - CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + CORBA_Environment &ACE_TRY_ENV); }; #endif /* TAO_HAS_MINIMUM_CORBA */ @@ -788,11 +729,11 @@ class TAO_Export TAO_POA_Current : public POA_PortableServer::Current public: // = Specification-mandated methods - virtual PortableServer::POA_ptr get_POA (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::POA_ptr get_POA (CORBA_Environment &ACE_TRY_ENV); // Return pointer to the invoking POA. Raises the // <CORBA::NoContext> exception. - virtual PortableServer::ObjectId *get_object_id (CORBA_Environment &TAO_IN_ENV = CORBA::default_environment ()); + virtual PortableServer::ObjectId *get_object_id (CORBA_Environment &ACE_TRY_ENV); // Return pointer to the object id through which this was invoked. // This may be necessary in cases where a <Servant> is serving under // the guise of multiple object ids. This has _out semantics Raises @@ -852,7 +793,9 @@ public: TAO_POA_Current (TAO_POA *impl, const TAO_ObjectKey &key, const PortableServer::ObjectId &id, - PortableServer::Servant servant); + PortableServer::Servant servant, + const char *operation, + TAO_ORB_Core &orb_core); // Convenience constructor combining construction & initialization. virtual ~TAO_POA_Current (void); @@ -878,6 +821,15 @@ protected: PortableServer::Servant servant_; // The servant for the current upcall. + const char *operation_; + // Operation name for this current. + + TAO_ORB_Core *orb_core_; + // ORB Core for this current. + + TAO_POA_Current *previous_current_; + // Current previous from <this>. + // = Hidden because we don't allow these TAO_POA_Current (const TAO_POA_Current &); void operator= (const TAO_POA_Current &); diff --git a/TAO/tao/POA.i b/TAO/tao/POA.i index fb949a31870..4f42aa89252 100644 --- a/TAO/tao/POA.i +++ b/TAO/tao/POA.i @@ -92,7 +92,7 @@ TAO_POA_Policies::request_processing (PortableServer::RequestProcessingPolicyVal this->request_processing_ = value; } -ACE_INLINE int +ACE_INLINE CORBA::ULong TAO_Creation_Time::creation_time_length (void) { return 2 * sizeof (CORBA::ULong); @@ -202,107 +202,38 @@ TAO_Temporary_Creation_Time::creation_time (const void *creation_time) this->time_stamp_ = (void *) creation_time; } -ACE_INLINE TAO_POA * -TAO_POA::clone (const TAO_POA::String &adapter_name, - TAO_POA_Manager &poa_manager, - const TAO_POA_Policies &policies, - TAO_POA *parent, - CORBA::Environment &env) -{ - return new TAO_POA (adapter_name, - poa_manager, - policies, - parent, - env); -} - ACE_INLINE ACE_Lock & TAO_POA::lock (void) { - return *this->lock_; + return this->lock_; } ACE_INLINE TAO_POA * TAO_POA::create_POA (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); return this->create_POA_i (adapter_name, poa_manager, policies, - env); -} - -ACE_INLINE TAO_POA * -TAO_POA::find_POA (const TAO_POA::String &adapter_name, - CORBA::Boolean activate_it, - CORBA::Environment &env) -{ - // Check if we are the POA the user is looking for - if (adapter_name == this->name_) - return this; - - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - - return this->find_POA_i_optimized (adapter_name, - activate_it, - env); - -} - -ACE_INLINE PortableServer::POA_ptr -TAO_POA::find_POA (const char *adapter_name, - CORBA::Boolean activate_it, - CORBA::Environment &env) -{ - // Don't copy string - TAO_POA::String name (adapter_name, 0, 0); - - TAO_POA *result = this->find_POA (name, - activate_it, - env); - - if (env.exception () != 0) - return PortableServer::POA::_nil (); - - return result->_this (env); -} - -ACE_INLINE TAO_POA * -TAO_POA::find_POA_i (const TAO_POA::String &adapter_name, - CORBA::Boolean activate_it, - CORBA::Environment &env) -{ - // Check if we are the POA the user is looking for - if (adapter_name == this->name_) - return this; - - return this->find_POA_i_optimized (adapter_name, - activate_it, - env); + ACE_TRY_ENV); } ACE_INLINE void TAO_POA::destroy (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); - this->destroy_i (etherealize_objects, - wait_for_completion, - env); - } - - // Commit suicide - delete this; + this->destroy_i (etherealize_objects, + wait_for_completion, + ACE_TRY_ENV); } ACE_INLINE TAO_POA_Policies & @@ -320,149 +251,149 @@ TAO_POA::active_object_map (void) const #if !defined (TAO_HAS_MINIMUM_CORBA) ACE_INLINE PortableServer::ServantManager_ptr -TAO_POA::get_servant_manager (CORBA::Environment &env) +TAO_POA::get_servant_manager (CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), PortableServer::ServantManager::_nil (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), PortableServer::ServantManager::_nil (), ACE_TRY_ENV); - return this->get_servant_manager_i (env); + return this->get_servant_manager_i (ACE_TRY_ENV); } ACE_INLINE void TAO_POA::set_servant_manager (PortableServer::ServantManager_ptr imgr, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->set_servant_manager_i (imgr, - env); + ACE_TRY_ENV); } ACE_INLINE PortableServer::Servant -TAO_POA::get_servant (CORBA::Environment &env) +TAO_POA::get_servant (CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); - return this->get_servant_i (env); + return this->get_servant_i (ACE_TRY_ENV); } ACE_INLINE void TAO_POA::set_servant (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->set_servant_i (servant, - env); + ACE_TRY_ENV); } #endif /* TAO_HAS_MINIMUM_CORBA */ ACE_INLINE PortableServer::ObjectId * TAO_POA::activate_object (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); return this->activate_object_i (servant, - env); + ACE_TRY_ENV); } ACE_INLINE void TAO_POA::activate_object_with_id (const PortableServer::ObjectId &id, PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->activate_object_with_id_i (id, servant, - env); + ACE_TRY_ENV); } ACE_INLINE void TAO_POA::deactivate_object (const PortableServer::ObjectId &oid, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->deactivate_object_i (oid, - env); + ACE_TRY_ENV); } ACE_INLINE CORBA::Object_ptr TAO_POA::create_reference (const char *intf, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), CORBA::Object::_nil (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), CORBA::Object::_nil (), ACE_TRY_ENV); return this->create_reference_i (intf, - env); + ACE_TRY_ENV); } ACE_INLINE CORBA::Object_ptr TAO_POA::create_reference_with_id (const PortableServer::ObjectId &id, const char *intf, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), CORBA::Object::_nil (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), CORBA::Object::_nil (), ACE_TRY_ENV); return this->create_reference_with_id_i (id, intf, - env); + ACE_TRY_ENV); } ACE_INLINE PortableServer::ObjectId * TAO_POA::servant_to_id (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { // If we had upgradeable locks, this would initially be a read lock // - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); return this->servant_to_id_i (servant, - env); + ACE_TRY_ENV); } ACE_INLINE PortableServer::ObjectId * TAO_POA::servant_to_system_id (PortableServer::Servant servant, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); return this->servant_to_system_id_i (servant, - env); + ACE_TRY_ENV); } ACE_INLINE PortableServer::Servant TAO_POA::id_to_servant (const PortableServer::ObjectId &oid, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); return this->id_to_servant_i (oid, - env); + ACE_TRY_ENV); } ACE_INLINE CORBA::Object_ptr TAO_POA::id_to_reference (const PortableServer::ObjectId &oid, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, ACE_TRY_ENV); - return this->id_to_reference_i (oid, env); + return this->id_to_reference_i (oid, ACE_TRY_ENV); } #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -470,48 +401,50 @@ TAO_POA::id_to_reference (const PortableServer::ObjectId &oid, ACE_INLINE void TAO_POA::forward_object (const PortableServer::ObjectId &oid, CORBA::Object_ptr forward_to, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - // Lock access to the POA for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->forward_object_i (oid, forward_to, - env); + ACE_TRY_ENV); } #endif /* TAO_HAS_MINIMUM_CORBA */ ACE_INLINE PortableServer::POA_ptr -TAO_POA::the_parent (CORBA::Environment &env) +TAO_POA::the_parent (CORBA::Environment &ACE_TRY_ENV) { if (this->parent_ != 0) - return this->parent_->_this (env); + return this->parent_->_this (ACE_TRY_ENV); else return PortableServer::POA::_nil (); } ACE_INLINE PortableServer::POAManager_ptr -TAO_POA::the_POAManager (CORBA::Environment &env) +TAO_POA::the_POAManager (CORBA::Environment &ACE_TRY_ENV) { - return this->poa_manager_._this (env); + return this->poa_manager_._this (ACE_TRY_ENV); } #if !defined (TAO_HAS_MINIMUM_CORBA) ACE_INLINE PortableServer::AdapterActivator_ptr -TAO_POA::the_activator (CORBA::Environment &env) +TAO_POA::the_activator (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), PortableServer::AdapterActivator::_nil (), ACE_TRY_ENV); return PortableServer::AdapterActivator::_duplicate (this->adapter_activator_.in ()); } ACE_INLINE void TAO_POA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator, - CORBA::Environment &env) + CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + // Lock access for the duration of this transaction. + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->adapter_activator_ = PortableServer::AdapterActivator::_duplicate (adapter_activator); } @@ -537,30 +470,36 @@ TAO_POA::persistent (void) return this->persistent_; } +ACE_INLINE const ACE_CString & +TAO_POA::name (void) const +{ + return this->name_; +} + ACE_INLINE CORBA::String -TAO_POA::the_name (CORBA::Environment &env) +TAO_POA::the_name (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (ACE_TRY_ENV); return CORBA::string_dup (this->name_.c_str ()); } -ACE_INLINE TAO_POA::String -TAO_POA::complete_name (void) +ACE_INLINE const TAO_Object_Adapter::poa_name & +TAO_POA::folded_name (void) const { - return this->complete_name_; + return this->folded_name_; } -ACE_INLINE char -TAO_POA::name_separator (void) +ACE_INLINE const TAO_Object_Adapter::poa_name & +TAO_POA::system_name (void) const { - return '/'; + return this->system_name_.in (); } ACE_INLINE char -TAO_POA::id_separator (void) +TAO_POA::name_separator (void) { - return ':'; + return '\0'; } ACE_INLINE CORBA::ULong @@ -569,12 +508,6 @@ TAO_POA::name_separator_length (void) return sizeof (char); } -ACE_INLINE CORBA::ULong -TAO_POA::id_separator_length (void) -{ - return sizeof (char); -} - ACE_INLINE char TAO_POA::persistent_key_char (void) { @@ -629,27 +562,11 @@ TAO_POA::system_id_key_type_length (void) return sizeof (char); } -ACE_INLINE int -TAO_POA::rfind (const TAO_ObjectKey &key, - char c, - int pos) const -{ - if (pos == ACE_CString::npos) - pos = key.length (); - - for (int i = pos - 1; i >= 0; i--) - if (key[i] == c) - return i; - - return TAO_POA::String::npos; -} - ACE_INLINE void TAO_POA_Current::clear (void) { this->poa_impl_ = 0; this->object_id_ = 0; - this->servant_ = 0; this->object_key_ = 0; #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -658,6 +575,9 @@ TAO_POA_Current::clear (void) #endif /* TAO_HAS_MINIMUM_CORBA */ + this->orb_core_ = 0; + this->previous_current_ = 0; + this->servant_ = 0; } ACE_INLINE int diff --git a/TAO/tao/POAC.h b/TAO/tao/POAC.h index f2851425a6a..48c6c2e1095 100644 --- a/TAO/tao/POAC.h +++ b/TAO/tao/POAC.h @@ -233,6 +233,14 @@ TAO_NAMESPACE PortableServer{ #endif /* end #if !defined */ + const CORBA::PolicyType THREAD_POLICY_ID = 16; + const CORBA::PolicyType LIFESPAN_POLICY_ID = 17; + const CORBA::PolicyType ID_UNIQUENESS_POLICY_ID = 18; + const CORBA::PolicyType ID_ASSIGNMENT_POLICY_ID = 19; + const CORBA::PolicyType IMPLICIT_ACTIVATION_POLICY_ID = 20; + const CORBA::PolicyType SERVANT_RETENTION_POLICY_ID = 21; + const CORBA::PolicyType REQUEST_PROCESSING_POLICY_ID = 22; + enum ThreadPolicyValue { ORB_CTRL_MODEL, diff --git a/TAO/tao/POAManager.cpp b/TAO/tao/POAManager.cpp index 20b2ccd595d..b5180a7843a 100644 --- a/TAO/tao/POAManager.cpp +++ b/TAO/tao/POAManager.cpp @@ -9,18 +9,15 @@ # include "tao/POAManager.i" #endif /* ! __ACE_INLINE__ */ -TAO_POA_Manager::TAO_POA_Manager (void) +TAO_POA_Manager::TAO_POA_Manager (ACE_Lock &lock) : state_ (PortableServer::POAManager::HOLDING), - closing_down_ (0), - lock_ (0), + lock_ (lock), poa_collection_ () { - this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_poa_mgr_lock (); } TAO_POA_Manager::~TAO_POA_Manager (void) { - delete this->lock_; } void @@ -32,9 +29,13 @@ TAO_POA_Manager::activate_i (CORBA::Environment &ACE_TRY_ENV) // enables the associated POAs to process requests. if (this->state_ == PortableServer::POAManager::INACTIVE) - ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + { + ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + } else - this->state_ = PortableServer::POAManager::ACTIVE; + { + this->state_ = PortableServer::POAManager::ACTIVE; + } } #if !defined (TAO_HAS_MINIMUM_CORBA) @@ -52,9 +53,13 @@ TAO_POA_Manager::hold_requests_i (CORBA::Boolean wait_for_completion, // state. if (this->state_ == PortableServer::POAManager::INACTIVE) - ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + { + ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + } else - this->state_ = PortableServer::POAManager::HOLDING; + { + this->state_ = PortableServer::POAManager::HOLDING; + } // If the wait_for_completion parameter is FALSE, this operation // returns immediately after changing the state. If the parameter is @@ -81,9 +86,13 @@ TAO_POA_Manager::discard_requests_i (CORBA::Boolean wait_for_completion, // client. if (this->state_ == PortableServer::POAManager::INACTIVE) - ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + { + ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + } else - this->state_ = PortableServer::POAManager::DISCARDING; + { + this->state_ = PortableServer::POAManager::DISCARDING; + } // If the wait_for_completion parameter is FALSE, this operation // returns immediately after changing the state. If the parameter is @@ -101,8 +110,6 @@ TAO_POA_Manager::deactivate_i (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, CORBA::Environment &ACE_TRY_ENV) { - this->closing_down_ = 1; - // This operation changes the state of the POA manager to // inactive. If issued while the POA manager is in the inactive // state, the AdapterInactive exception is raised. Entering the @@ -110,9 +117,13 @@ TAO_POA_Manager::deactivate_i (CORBA::Boolean etherealize_objects, // have not begun to be executed as well as any new requests. if (this->state_ == PortableServer::POAManager::INACTIVE) - ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + { + ACE_THROW (PortableServer::POAManager::AdapterInactive ()); + } else - this->state_ = PortableServer::POAManager::INACTIVE; + { + this->state_ = PortableServer::POAManager::INACTIVE; + } // After changing the state, if the etherealize_objects parameter is: // @@ -133,10 +144,12 @@ TAO_POA_Manager::deactivate_i (CORBA::Boolean etherealize_objects, poa->destroy (etherealize_objects, wait_for_completion, ACE_TRY_ENV); -// poa->etherealize_servants (etherealize_objects, -// wait_for_completion, -// ACE_TRY_ENV); ACE_CHECK; + + // poa->etherealize_servants (etherealize_objects, + // wait_for_completion, + // ACE_TRY_ENV); + // ACE_CHECK; } // If the wait_for_completion parameter is FALSE, this operation @@ -158,69 +171,28 @@ TAO_POA_Manager::deactivate_i (CORBA::Boolean etherealize_objects, #endif /* TAO_HAS_MINIMUM_CORBA */ -PortableServer::POAManager::State -TAO_POA_Manager::get_state (CORBA::Environment &ACE_TRY_ENV) +int +TAO_POA_Manager::remove_poa (TAO_POA *poa) { - // Lock access to the POAManager for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), this->state_, ACE_TRY_ENV); - - return this->state_; -} + int result = this->poa_collection_.remove (poa); -void -TAO_POA_Manager::remove_poa (TAO_POA *poa, - CORBA::Environment &ACE_TRY_ENV) -{ - // If we are not closing down, we must remove this poa from our - // collection. - if (!this->closing_down_) + if (result == 0) { - // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); - - this->remove_poa_i (poa, - ACE_TRY_ENV); + if (this->poa_collection_.is_empty ()) + { + // @@ This may cause segfault if another thread gets a hold + // at this POAManager but gets blocked on register POA + // waiting for remove_poa to complete. I think we need to + // use the client side mapping to refcount this. + delete this; + } } - // If we are closing down, we are currently iterating over our poa - // collection and there is not need to remove this poa from our - // collection. - - // @@ This may cause segfault if another thread gets a hold at this - // POAManager but gets blocked on register POA waiting for - // remove_poa to complete. I think we need to use the client side mapping - // to refcount this. - if (this->poa_collection_.is_empty ()) - this->destroy (); -} - -void -TAO_POA_Manager::remove_poa_i (TAO_POA *poa, - CORBA::Environment &ACE_TRY_ENV) -{ - int result = this->poa_collection_.remove (poa); - - if (result != 0) - ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)); -} - -void -TAO_POA_Manager::register_poa (TAO_POA *poa, - CORBA::Environment &ACE_TRY_ENV) -{ - // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); - - this->register_poa_i (poa, - ACE_TRY_ENV); + return result; } -void -TAO_POA_Manager::register_poa_i (TAO_POA *poa, - CORBA::Environment &ACE_TRY_ENV) +int +TAO_POA_Manager::register_poa (TAO_POA *poa) { - int result = this->poa_collection_.insert (poa); - - if (result != 0) - ACE_THROW (CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)); + return this->poa_collection_.insert (poa); } diff --git a/TAO/tao/POAManager.h b/TAO/tao/POAManager.h index 60a5c0b7bd6..428cfce6051 100644 --- a/TAO/tao/POAManager.h +++ b/TAO/tao/POAManager.h @@ -50,14 +50,12 @@ public: #endif /* TAO_HAS_MINIMUM_CORBA */ - TAO_POA_Manager (void); + virtual PortableServer::POAManager::State get_state (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - virtual TAO_POA_Manager *clone (void); + TAO_POA_Manager (ACE_Lock &lock); virtual ~TAO_POA_Manager (void); - virtual PortableServer::POAManager::State get_state (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - protected: virtual void activate_i (CORBA_Environment &ACE_TRY_ENV); @@ -74,29 +72,19 @@ protected: CORBA::Boolean wait_for_completion, CORBA_Environment &ACE_TRY_ENV); + virtual PortableServer::POAManager::State get_state_i (); + #endif /* TAO_HAS_MINIMUM_CORBA */ virtual ACE_Lock &lock (void); - virtual void remove_poa (TAO_POA *poa, - CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); + virtual int remove_poa (TAO_POA *poa); - virtual void remove_poa_i (TAO_POA *poa, - CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - - virtual void register_poa (TAO_POA *poa, - CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - - virtual void register_poa_i (TAO_POA *poa, - CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); - - virtual void destroy (void); + virtual int register_poa (TAO_POA *poa); PortableServer::POAManager::State state_; - int closing_down_; - - ACE_Lock *lock_; + ACE_Lock &lock_; typedef ACE_Unbounded_Set<TAO_POA *> POA_COLLECTION; diff --git a/TAO/tao/POAManager.i b/TAO/tao/POAManager.i index b5f31b2ffda..43cd7d77d3a 100644 --- a/TAO/tao/POAManager.i +++ b/TAO/tao/POAManager.i @@ -5,14 +5,14 @@ ACE_INLINE ACE_Lock & TAO_POA_Manager::lock (void) { - return *this->lock_; + return this->lock_; } ACE_INLINE void TAO_POA_Manager::activate (CORBA_Environment &ACE_TRY_ENV) { // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->activate_i (ACE_TRY_ENV); } @@ -24,7 +24,7 @@ TAO_POA_Manager::hold_requests (CORBA::Boolean wait_for_completion, CORBA_Environment &ACE_TRY_ENV) { // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->hold_requests_i (wait_for_completion, ACE_TRY_ENV); } @@ -34,7 +34,7 @@ TAO_POA_Manager::discard_requests (CORBA::Boolean wait_for_completion, CORBA_Environment &ACE_TRY_ENV) { // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->discard_requests_i (wait_for_completion, ACE_TRY_ENV); } @@ -45,23 +45,26 @@ TAO_POA_Manager::deactivate (CORBA::Boolean etherealize_objects, CORBA_Environment &ACE_TRY_ENV) { // Lock access to the POAManager for the duration of this transaction - TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); + TAO_POA_GUARD (ACE_Lock, monitor, this->lock (), ACE_TRY_ENV); this->deactivate_i (etherealize_objects, wait_for_completion, ACE_TRY_ENV); } -#endif /* TAO_HAS_MINIMUM_CORBA */ - -ACE_INLINE TAO_POA_Manager * -TAO_POA_Manager::clone (void) +ACE_INLINE PortableServer::POAManager::State +TAO_POA_Manager::get_state_i (void) { - return new TAO_POA_Manager; + return this->state_; } -ACE_INLINE void -TAO_POA_Manager::destroy (void) +ACE_INLINE PortableServer::POAManager::State +TAO_POA_Manager::get_state (CORBA::Environment &ACE_TRY_ENV) { - delete this; + // Lock access to the POAManager for the duration of this transaction + TAO_POA_GUARD_RETURN (ACE_Lock, monitor, this->lock (), this->state_, ACE_TRY_ENV); + + return this->get_state_i (); } + +#endif /* TAO_HAS_MINIMUM_CORBA */ diff --git a/TAO/tao/Servant_Base.h b/TAO/tao/Servant_Base.h index ae01eed0892..3cf2fe0d367 100644 --- a/TAO/tao/Servant_Base.h +++ b/TAO/tao/Servant_Base.h @@ -32,6 +32,7 @@ class TAO_Export TAO_ServantBase // class. public: friend class TAO_POA; + friend class TAO_Object_Adapter; friend class CORBA_Object; virtual ~TAO_ServantBase (void); diff --git a/TAO/tao/Server_Strategy_Factory.cpp b/TAO/tao/Server_Strategy_Factory.cpp index 44543c36c4d..766cc35bfb6 100644 --- a/TAO/tao/Server_Strategy_Factory.cpp +++ b/TAO/tao/Server_Strategy_Factory.cpp @@ -50,12 +50,6 @@ TAO_Server_Strategy_Factory::create_poa_lock (void) } ACE_Lock * -TAO_Server_Strategy_Factory::create_poa_mgr_lock (void) -{ - return 0; -} - -ACE_Lock * TAO_Server_Strategy_Factory::create_servant_lock (void) { return 0; @@ -91,7 +85,11 @@ TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters::Active_Objec object_lookup_strategy_for_system_id_policy_ (TAO_ACTIVE_DEMUX), reverse_object_lookup_strategy_for_unique_id_policy_ (TAO_DYNAMIC_HASH), use_active_hint_in_ids_ (1), - allow_reactivation_of_system_ids_ (1) + allow_reactivation_of_system_ids_ (1), + poa_map_size_ (TAO_DEFAULT_SERVER_POA_MAP_SIZE), + poa_lookup_strategy_for_transient_id_policy_ (TAO_ACTIVE_DEMUX), + poa_lookup_strategy_for_persistent_id_policy_ (TAO_DYNAMIC_HASH), + use_active_hint_in_poa_names_ (1) { } diff --git a/TAO/tao/Server_Strategy_Factory.h b/TAO/tao/Server_Strategy_Factory.h index e4bcdd61371..8d96cf643c6 100644 --- a/TAO/tao/Server_Strategy_Factory.h +++ b/TAO/tao/Server_Strategy_Factory.h @@ -39,7 +39,7 @@ public: Active_Object_Map_Creation_Parameters (void); // Constructor. - u_long active_object_map_size_; + CORBA::ULong active_object_map_size_; // Default size of object lookup table. TAO_Demux_Strategy object_lookup_strategy_for_user_id_policy_; @@ -62,6 +62,14 @@ public: // Flag to indicate whether reactivations of servants was required // (under the system id policy). If not, certain resources may // not be required. + + CORBA::ULong poa_map_size_; + + TAO_Demux_Strategy poa_lookup_strategy_for_transient_id_policy_; + + TAO_Demux_Strategy poa_lookup_strategy_for_persistent_id_policy_; + + int use_active_hint_in_poa_names_; }; // = Initialization and termination methods. @@ -104,9 +112,6 @@ public: virtual ACE_Lock *create_poa_lock (void); // Return a new lock for use in locking the POA. - virtual ACE_Lock *create_poa_mgr_lock (void); - // Return a new lock for use in locking the POA Manager. - virtual ACE_Lock *create_servant_lock (void); // Return a new lock for use in locking the servant. diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp index 1f20cd3ceb2..c05ba37b01c 100644 --- a/TAO/tao/TAO.dsp +++ b/TAO/tao/TAO.dsp @@ -20,13 +20,12 @@ CFG=TAO - Win32 Debug !MESSAGE
!MESSAGE "TAO - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "TAO - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "TAO - Win32 Alpha Release" (based on\
- "Win32 (ALPHA) Dynamic-Link Library")
-!MESSAGE "TAO - Win32 Alpha Debug" (based on\
- "Win32 (ALPHA) Dynamic-Link Library")
+!MESSAGE "TAO - Win32 Alpha Release" (based on "Win32 (ALPHA) Dynamic-Link Library")
+!MESSAGE "TAO - Win32 Alpha Debug" (based on "Win32 (ALPHA) Dynamic-Link Library")
!MESSAGE
# Begin Project
+# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
@@ -105,13 +104,13 @@ LINK32=link.exe # PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
CPP=cl.exe
# ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /I "..\..\\ /I" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "TAO_BUILD_DLL" /FD ..\\ /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /Gt0 /W3 /GX /O2 /I "..\..\\ /I" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "TAO_BUILD_DLL" /FD ..\\ /c
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL"
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
@@ -136,13 +135,13 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
-MTL=midl.exe
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
CPP=cl.exe
# ADD BASE CPP /nologo /Gt0 /W3 /GX /Zi /Od /Gy /I "..\..\\ /I" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "TAO_BUILD_DLL" /FD /MTd ..\\ /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /Gt0 /W3 /GX /Zi /Od /Gy /I "..\..\\ /I" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "TAO_BUILD_DLL" /FD /MDd ..\\ /c
+MTL=midl.exe
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL"
RSC=rc.exe
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
@@ -15855,6 +15854,21 @@ SOURCE=.\IOR_LookupTable.cpp # End Source File
# Begin Source File
+SOURCE=.\Key_Adapters.cpp
+
+!IF "$(CFG)" == "TAO - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Alpha Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\Managed_Types.cpp
!IF "$(CFG)" == "TAO - Win32 Release"
@@ -18010,6 +18024,21 @@ NODEP_CPP_OBJEC=\ # End Source File
# Begin Source File
+SOURCE=.\Object_Adapter.cpp
+
+!IF "$(CFG)" == "TAO - Win32 Release"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Alpha Release"
+
+!ELSEIF "$(CFG)" == "TAO - Win32 Alpha Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
SOURCE=.\Object_KeyC.cpp
!IF "$(CFG)" == "TAO - Win32 Release"
diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp index 18499cee77c..84222790362 100644 --- a/TAO/tao/default_server.cpp +++ b/TAO/tao/default_server.cpp @@ -66,31 +66,6 @@ TAO_Default_Server_Strategy_Factory::create_poa_lock (void) break; } - return the_lock;// Just to make sure we return something -} - -ACE_Lock * -TAO_Default_Server_Strategy_Factory::create_poa_mgr_lock (void) -{ - ACE_Lock *the_lock = 0; - - switch (this->poa_mgr_lock_type_) - { - case TAO_THREAD_LOCK: -#if defined (ACE_HAS_THREADS) - ACE_NEW_RETURN (the_lock, - ACE_Lock_Adapter<ACE_Thread_Mutex> (), - 0); - break; -#endif /* ACE_HAS_THREADS */ - default: - ACE_NEW_RETURN (the_lock, - ACE_Lock_Adapter<ACE_Null_Mutex> (), - 0); - break; - } - - // Just to make sure we return something. return the_lock; } @@ -231,12 +206,19 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[]) this->concurrency_strategy_ = &threaded_strategy_; } } - else if (ACE_OS::strcmp (argv[curarg], "-ORBtablesize") == 0) + else if (ACE_OS::strcmp (argv[curarg], "-ORBtablesize") == 0 || + ACE_OS::strcmp (argv[curarg], "-ORBactiveobjectmapsize") == 0) { curarg++; if (curarg < argc) this->active_object_map_creation_parameters_.active_object_map_size_ = ACE_OS::strtoul (argv[curarg], 0, 10); } + else if (ACE_OS::strcmp (argv[curarg], "-ORBpoamapsize") == 0) + { + curarg++; + if (curarg < argc) + this->active_object_map_creation_parameters_.poa_map_size_ = ACE_OS::strtoul (argv[curarg], 0, 10); + } else if (ACE_OS::strcmp (argv[curarg], "-ORBactivehintinids") == 0) { curarg++; @@ -247,6 +229,16 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[]) this->active_object_map_creation_parameters_.use_active_hint_in_ids_ = ACE_OS::atoi (value); } } + else if (ACE_OS::strcmp (argv[curarg], "-ORBactivehintinpoanames") == 0) + { + curarg++; + if (curarg < argc) + { + char *value = argv[curarg]; + + this->active_object_map_creation_parameters_.use_active_hint_in_poa_names_ = ACE_OS::atoi (value); + } + } else if (ACE_OS::strcmp (argv[curarg], "-ORBallowreactivationofsystemids") == 0) { curarg++; @@ -286,6 +278,35 @@ TAO_Default_Server_Strategy_Factory::parse_args (int argc, char *argv[]) this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ = TAO_ACTIVE_DEMUX; } } + else if (ACE_OS::strcmp (argv[curarg], "-ORBpersistentidpolicydemuxstrategy") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + // Active demux not supported with user id policy + if (ACE_OS::strcasecmp (name, "dynamic") == 0) + this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ = TAO_DYNAMIC_HASH; + else if (ACE_OS::strcasecmp (name, "linear") == 0) + this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ = TAO_LINEAR; + } + } + else if (ACE_OS::strcmp (argv[curarg], "-ORBtransientidpolicydemuxstrategy") == 0) + { + curarg++; + if (curarg < argc) + { + char *name = argv[curarg]; + + if (ACE_OS::strcasecmp (name, "dynamic") == 0) + this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_DYNAMIC_HASH; + else if (ACE_OS::strcasecmp (name, "linear") == 0) + this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_LINEAR; + else if (ACE_OS::strcasecmp (name, "active") == 0) + this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ = TAO_ACTIVE_DEMUX; + } + } else if (ACE_OS::strcmp (argv[curarg], "-ORBuniqueidpolicyreversedemuxstrategy") == 0) { curarg++; diff --git a/TAO/tao/default_server.h b/TAO/tao/default_server.h index e5ca3566ac9..66d41a508b6 100644 --- a/TAO/tao/default_server.h +++ b/TAO/tao/default_server.h @@ -55,14 +55,8 @@ public: virtual ACE_Lock *create_poa_lock (void); // Creates and returns a lock for POA based on the setting for // <-ORBpoalock>. A setting of <thread> returns an - // <ACE_Lock_Adapter\<ACE_Thread_Mutex\>>; a setting of <null> - // returns an <ACE_Lock_Adapter\<ACE_NULL_Mutex\>>. - - virtual ACE_Lock *create_poa_mgr_lock (void); - // Creates and returns a lock for a POA Manager based on the setting - // for <-ORBpoamgrlock>. A setting of <thread> returns an - // <ACE_Lock_Adapter\<ACE_Thread_Mutex\>>; a setting of <null> - // returns an <ACE_Lock_Adapter\<ACE_NULL_Mutex\>>. + // ACE_Lock_Adapter<ACE_Thread_Mutex>; a setting of <null> returns + // an ACE_Lock_Adapter<ACE_NULL_Mutex>. virtual ACE_Lock *create_servant_lock (void); // Creates and returns a lock for servants based on the setting of diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index b2407836a37..bf8cc163fd3 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -97,6 +97,11 @@ # endif /* TAO_DEFAULT_SERVER_OBJECT_TABLE_SIZE */ #endif /* ! TAO_DEFAULT_SERVER_ACTIVE_OBJECT_MAP_SIZE */ +// The default size of TAO's server poa map. +#if !defined (TAO_DEFAULT_SERVER_POA_MAP_SIZE) +# define TAO_DEFAULT_SERVER_POA_MAP_SIZE 24 +#endif /* ! TAO_DEFAULT_SERVER_POA_MAP_SIZE */ + // The default number of times the ORB will attempt to get a reply // from a service using multicast. #if !defined (TAO_DEFAULT_MULTICAST_SEND_ATTEMPTS) diff --git a/TAO/tao/poa_macros.h b/TAO/tao/poa_macros.h index b1f40199ee4..46b6d0ca3a7 100644 --- a/TAO/tao/poa_macros.h +++ b/TAO/tao/poa_macros.h @@ -7,15 +7,22 @@ // Convenient macro for testing for deadlock, as well as for detecting // when mutexes fail. +#define TAO_POA_GUARD(MUTEX,OBJ,LOCK,ENV) \ + TAO_GUARD_THROW(MUTEX,OBJ,LOCK,ENV,CORBA::OBJ_ADAPTER ()) + +#define TAO_POA_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV) \ + TAO_GUARD_THROW_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV,CORBA::OBJ_ADAPTER ()) + #define TAO_POA_WRITE_GUARD(MUTEX,OBJ,LOCK,ENV) \ - TAO_WRITE_GUARD_THROW(MUTEX,OBJ,LOCK,ENV,CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)) + TAO_WRITE_GUARD_THROW(MUTEX,OBJ,LOCK,ENV,CORBA::OBJ_ADAPTER ()) #define TAO_POA_READ_GUARD(MUTEX,OBJ,LOCK,ENV) \ - TAO_READ_GUARD_THROW(MUTEX,OBJ,LOCK,ENV,CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)) + TAO_READ_GUARD_THROW(MUTEX,OBJ,LOCK,ENV,CORBA::OBJ_ADAPTER ()) #define TAO_POA_WRITE_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV) \ - TAO_WRITE_GUARD_THROW_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV,CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)) + TAO_WRITE_GUARD_THROW_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV,CORBA::OBJ_ADAPTER ()) + #define TAO_POA_READ_GUARD_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV) \ - TAO_READ_GUARD_THROW_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV,CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO)) + TAO_READ_GUARD_THROW_RETURN(MUTEX,OBJ,LOCK,RETURN,ENV,CORBA::OBJ_ADAPTER ()) #endif /* TAO_POA_MACROS_H */ |