KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > memoryusage > SessionFactoryServant


1 package test.memoryusage;
2
3 import org.omg.CORBA.*;
4 import org.omg.CORBA.ORBPackage.*;
5 import org.omg.PortableServer.*;
6
7 public class SessionFactoryServant
8     extends SessionFactoryPOA
9 {
10     private ORB orb;
11     private POA poa;
12
13     public SessionFactoryServant( ORB orb, org.omg.PortableServer.POA JavaDoc poa)
14     {
15         this.orb = orb;
16         this.poa = poa;
17     }
18
19     public Session get_Session(String JavaDoc userName, String JavaDoc fullName,
20                                String JavaDoc emailAddress, String JavaDoc ip)
21     {
22         synchronized (this)
23         {
24             try
25             {
26                 Session session = null;
27                 SessionServant servant = new SessionServant();
28                 //poa.activate_object(servant);
29
org.omg.CORBA.Object JavaDoc o = poa.servant_to_reference( servant );
30                 session = SessionHelper.narrow(o);
31
32                 //session = servant._this(orb);
33

34                 return session;
35             }
36             catch( Exception JavaDoc e )
37             {
38                 org.jacorb.util.Debug.output(1,e);
39                 throw new org.omg.CORBA.UNKNOWN JavaDoc();
40             }
41         }
42     }
43
44     public synchronized void releaseSession( Session session )
45     {
46         try
47         {
48             poa.deactivate_object(poa.reference_to_id( session ));
49             // session._release();
50
}
51         catch(org.omg.PortableServer.POAPackage.WrongAdapter JavaDoc sna)
52         {
53             System.out.println(sna);
54         }
55         catch(org.omg.PortableServer.POAPackage.ObjectNotActive JavaDoc ona)
56         {
57             System.out.println(ona);
58         }
59         catch(org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc wp)
60         {
61             System.out.println(wp);
62         }
63     }
64 }
65
Popular Tags