POA ���ڰ�������Dz�����ǵ��ʹ�����������������һ�ִ���װ�� POA ���ʹӵ�;����ԭ������ͬһ��ʱ���Ͽ����д����Ķ�����һ��������������ͨ��ʹ�� POA ��������ɵġ�ÿ�� POA ��ͬij�� POAManager ������š�
POAManager ����������������������״̬�������͵����ǵ� POA��һ�� POAManager ������ 4 ������״̬����Ծ(active)����ֹ(inactive)������(holding)������(discarding)��������ڻ�Ծ״̬�������͵� POA��������ڱ���״̬��������ȴ����У�һֱ�ȵ� POAManager �ص���Ծ״̬��������ڶ���״̬������ֻ�DZ��Ķ�����
һ��ģ��㲻��Ҫ�Լ�д POAManager ��ʵ�� �������������Ľӿ���ʹ�� RootPOA �� POAManager ��
module PortableServer { interface POA { POA create_POA (in string adapter_name, in POAManager a_POAManager, in CORBA::PolicyList policies) raises (AdapterAllreadyExists, InvalidPolicy); void destroy (in boolean etherealize_objects, in boolean wait_for_completion); POA find_poa (in string adapter_name, in POAManager a_POAManager in CORBA::PolicyList ListPolicies); readonly attribute POA the_parent; readonly attribute string the_name; readonly attribute POAManager the_POAManager; }; }; |
����:
PortableServer_POA root_poa; PortableServer_POAManager root_poa_manager; root_poa = CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); root_poa_manager = PortableServer_POA_get_the_POAManager (root_poa, &ev); PortableServer_POA_create_poa (root_poa, "my_own_poa", root_poa_manager, NULL, &ev); |
һ�� POA ������Ϊ��һ�� POA ���� POA �����ģ�RootPOA �� POA ���ĸ���������֪���� POA �����֣�ͨ���� find_poa ���������ҵ��ض���һ���� POA��the_parent ����(attribute)���и� POA��the_name ���Գ��� create_poa ����������� POA ���֡� destroy_poa ��������Ϊ������������ POA �Լ����������� POA��
Ϊ�˱�������ʹӣ�����һ�� RootPOA ���� POA ����Ϊ����ʹӵ� _base_epv �� default_poa ��Ա����Ҳ����ȷ����� POA ʹ�õ� POAManager (��������˵����������һ���� RootPOA ��ӵ�е��Ǹ� POAManager)���ڼ���״̬��ԭ���� POAManager ����ʼ���ɱ���״̬�ġ����µ���һ�ڽ��ṩ�������롣
����ÿ�� POA ��������һϵ�в���(Policies)������������dz���ȷ�Ŀ������ POA �����棬����������...
ÿ�� POA �� PortableServer_POA_createPOA ��������ʱҪͨ���� CORBA::PolicyList policies �����������IJ��ԡ�
������ݵ���һ�� NULL ������ʹ��ȱʡ�IJ��ԡ������Dz������ͺ����ǿ��ܵ�ֵ���б��� ȱʡ��ֵ��б���ֱ�ʾ��
�� 4-2. POA ����
���Ե����� | ���ܵ�ֵ | ���Ե���; |
---|---|---|
ThreadPolicy(�̲߳���) | ORB_CTRL_MODEL, SINGLE_THREAD_MODEL | �� SINGLE_THREAD �����£�ֻ���Դ���һ�� POA �̡߳� |
LifespanPolicy(�������ڲ���) | TRANSIENT, PERSISTENT | �� TRANSIENT �����£�����ʵ�ֽ�ͬ���� POA һ����ʧ����һ�ַ�ʽ�£�����Ҫʱ����һ���µ� POA�� |
ObjectIdUniqueness(ObjectId Ψһ�Բ���) | UNIQUE_ID, MULTIPLE_ID | �ڸ�����һ�� POA ��ÿ��������һ��Ψһ�� ObjectId�� |
IdAssignmentPolicy(Id �������) | USER_ID, SYSTEM_ID | Ҫô���û�Ҫô��ϵͳ���� ObjectId�� ����: ����һ�������� POA�������ʹ���������������֮һ: activate_object �� activate_object_with_id �� |
ServantRetentionPolicy(�ʹӱ��ֲ���) | RETAIN, NON_RETAIN | �� NON RETAIN �����£���һ���ʹӵ������Ѿ��ڴ����ˣ���һ����������������һ�� ObjectNotExist ���⡣ |
RequestProcessingPolicy(����Ĵ�������) | USE_ACTIVE_OBJECT_MAP_ONLY, USE_DEFAULT_SERVANT, USE_SERVANT_MANAGER | ��һ���ʹӵ������� POA ӳ����û�ҵ���������Ҫô�ǵ�һ��ȱʡ���ʹӵĵ��ã�Ҫô������һ�� ObjectNotExist ���⣬Ҫô�ǵ��ʹӹ�������һ��������Ҫ����ʹӵ����� |
ImplicitActivationPolicy(��ʽ�������) | IMPLICIT_ACTIVATION, NO_IMPLICIT_ACTIVATION | ���ʹ�� NO_IMPLICIT_ACTIVATION ������߽���Ҫ�������еĽ������ʹӡ� |
��Щ���Զ���Ӧʹ�� POA �ӿڵ����е�����������
module PortableServer { interface POA { ThreadPolicy create_thread_policy (in ThreadPolicyValue value); LifespanPolicy create_lifespan_policy (in LifespanPolicyValue value); IdUniquenessPolicy create_id_uniqueness_policy (in IdUniquenessPolicyValue value); IdAssignementPolicy create_id_assignment_policy (in IdAssignmentPolicyValue value); ImplicitActivationPolicy create_implicit_activation_policy (in ImplicitActivationPolicyValue value); ServantRetentionPolicy create_servant_retention_policy (in ServantRetentionPolicyValue value); ProcessingPolicy create_processing_policy (in ProcessingPolicyValue value); }; }; |
��Щ���Զ�Ӧ�ñ����� CORBA::PolicyList �в����ݸ� create_poa ��������������ȷ�IJ��Խ��� POA����һϵ�в��Ը�������ǿ��ķ��������������������Ϊ����߿��Ծ�ȷ����������������Ϊ�������Կ��Ʒ�������װ�ء������ǽ���һ��ʹ����Щ���Ե� POA ���������롣ע���һ�� PolicyList �е�ij���������Ͳ����ڵ�ʱ�������ͱ�ȱʡΪ����ǰ������г�����ȱʡֵ��
// ���Զ���� idl module CORBA { typedef unsigned long PolicyType; interface Policy { readonly attribute PolicyType policy_type; Policy copy(); void destroy(); }; typedef sequence <Policy> PolicyList; }; |
/* ����һ�� PolicyList ����� C ���� */ CORBA_Policy policies[2]; CORBA_PolicyList list = {2, 2, policies}; policies[1] = PortableServer_POA_create_Id_Uniqueness_Policy (MULTIPLE_ID, &ev); policies[2] = PortableServer_POA_create_Id_Assignment_Policy (USER_ID, &ev); PortableServer_POA_create_poa (poa, "my_poa", poa_manager, list, &ev); CORBA_Policy_destroy (policies[1]); CORBA_Policy_destroy (policies[2]); |
������Ҫ�����ʵ�ֺ�������һЩ������(common)������������ĺ�������һ���� PortableServer_Servant �ṹ��ָ����Ϊ��һ���������鿴����Ĵ��룺
typedef struct { PortableServer_Servant servant; long my_field; long my_second_field; void *pointer_to_my_structure; } my_POA_FruitsBasket_Apple my_POA_FruitsBasket_Apple Apple; |
&Apple ��һ���� Apple �ṹ��ָ�룬Ҳ�ǵ�����ṹ�ĵ�һ���ֶε�ָ�룬�� C ������ &Apple == &Apple.servant������ζ����ע�����ʹӵ�ʱ��������õ��ǵ� Apple ��ָ�룬���ָ�뽫�����ݸ����е�ʵ�ֺ�����������������ԭ����һ�� my_POA_FruitsBasket_Apple ָ��Ҳ��һ���� PortableServer_Servant ��ָ�롣
��ע���ϸ��˵��������˵�Ĺ�����(common)�������൱�� C++ �����ݳ�Ա���� PortableServer_Servant �ṹ��ָ���൱�� C++ �� this ָ�롣���ﶨ��Ľṹ�� C ӳ��淶�н��� application servant��������ǿ���Եġ�