KickJava   Java API By Example, From Geeks To Geeks.

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


1 package demo.poa_monitor.user_poa;
2
3 import demo.poa_monitor.foox.*;
4 import org.omg.PortableServer.*;
5 import org.omg.PortableServer.ServantLocatorPackage.CookieHolder JavaDoc;
6
7 public class FooServantLocatorImpl
8     extends org.omg.PortableServer._ServantLocatorLocalBase JavaDoc
9 {
10     private FooImpl foo = new FooImpl("0");
11  
12     public void postinvoke(byte[] oid,
13                            POA adapter,
14                            String JavaDoc operation,
15                            java.lang.Object JavaDoc cookie,
16                            Servant servant)
17     {
18         String JavaDoc oidStr = new String JavaDoc(oid);
19         if (!oidStr.equals(cookie))
20         {
21             System.out.println("[ postinvoke "+operation+" for oid: "+oidStr+": cookie is unknown ]");
22             throw new org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc();
23         }
24     }
25
26     public Servant preinvoke(byte[] oid,
27                              POA adapter,
28                              String JavaDoc operation, CookieHolder JavaDoc cookie)
29         throws ForwardRequest
30     {
31         String JavaDoc oidStr = new String JavaDoc(oid);
32         int oidInt = Integer.parseInt(oidStr);
33         if (oidInt >= 1000)
34         {
35             cookie.value = oidStr;
36             return foo;
37         }
38         return null;
39     }
40 }
41
Popular Tags