KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > poa_monitor > user_poa > FooAdapterActivatorImpl


1 package demo.poa_monitor.user_poa;
2
3 import org.omg.PortableServer.*;
4
5 public class FooAdapterActivatorImpl
6     extends _AdapterActivatorLocalBase
7 {
8     private org.omg.CORBA.ORB JavaDoc orb;
9
10     public FooAdapterActivatorImpl( org.omg.CORBA.ORB JavaDoc orb )
11     {
12         this.orb = orb;
13     }
14
15     public boolean unknown_adapter(POA parent, String JavaDoc name)
16     {
17         try
18         {
19             if (name.equals(Server.fooPOAName) && (Server.kind == 1 ||
20                                                    Server.kind == 2))
21             {
22                 org.omg.CORBA.Policy JavaDoc [] policies = {
23                     parent.create_request_processing_policy(RequestProcessingPolicyValue.USE_SERVANT_MANAGER),
24                     parent.create_id_assignment_policy (IdAssignmentPolicyValue.USER_ID),
25                     parent.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
26                 };
27
28                 POA newPOA = parent.create_POA(name, parent.the_POAManager(), policies);
29
30                 for (int i=0; i<policies.length; i++)
31                     policies[i].destroy();
32                 
33                 newPOA.set_servant_manager(new FooServantActivatorImpl( orb ) );
34                 return true;
35
36             }
37             else if (name.equals(Server.fooPOAName) && Server.kind == 3)
38             {
39                 org.omg.CORBA.Policy JavaDoc [] policies = {
40                     parent.create_request_processing_policy(RequestProcessingPolicyValue.USE_SERVANT_MANAGER),
41                     parent.create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN),
42                     parent.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
43                     parent.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
44                 };
45                 POA newPOA = parent.create_POA(name, parent.the_POAManager(), policies);
46                 for (int i=0; i<policies.length; i++) policies[i].destroy();
47                 
48                 newPOA.set_servant_manager(new FooServantLocatorImpl() );
49                 return true;
50                                                     
51             }
52             else if (name.equals(Server.fooPOAName) && Server.kind == 4)
53             {
54                 org.omg.CORBA.Policy JavaDoc [] policies = {
55                     parent.create_request_processing_policy(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT),
56                     parent.create_id_uniqueness_policy(IdUniquenessPolicyValue.MULTIPLE_ID)
57                 };
58                 POA newPOA = parent.create_POA(name, parent.the_POAManager(), policies);
59                 for (int i=0; i<policies.length; i++) policies[i].destroy();
60
61                 newPOA.set_servant(new FooImpl("0"));
62                 return true;
63                         
64             }
65             else if (name.equals(Server.fooPOAName) && Server.kind == 5)
66             {
67                 org.omg.CORBA.Policy JavaDoc [] policies = {
68                     parent.create_id_uniqueness_policy(IdUniquenessPolicyValue.MULTIPLE_ID),
69                     parent.create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
70                 };
71
72                 POA newPOA = parent.create_POA(name, parent.the_POAManager(), policies);
73                 for (int i=0; i<policies.length; i++)
74                     policies[i].destroy();
75                 return true;
76                     
77             }
78             else if (name.equals(Server.fooPOAName) && Server.kind == 6)
79             {
80                 org.omg.CORBA.Policy JavaDoc [] policies = {
81                     parent.create_thread_policy(ThreadPolicyValue.SINGLE_THREAD_MODEL),
82                     parent.create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
83                 };
84                 POA newPOA = parent.create_POA(name, parent.the_POAManager(), policies);
85
86                 for (int i=0; i<policies.length; i++)
87                     policies[i].destroy();
88                 return true;
89             }
90             else
91             {
92                 System.out.println("unknown poa name (AdapterActivator)");
93             }
94         }
95         catch (org.omg.PortableServer.POAPackage.AdapterAlreadyExists JavaDoc aae) {
96             aae.printStackTrace();
97         }
98         catch (org.omg.PortableServer.POAPackage.InvalidPolicy JavaDoc ip) {
99             ip.printStackTrace();
100         }
101         catch (org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc wp) {
102             wp.printStackTrace();
103         }
104         return false;
105     }
106 }
107
Popular Tags