KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > protocol > INSServerRequestDispatcher


1 /*
2  * @(#)INSServerRequestDispatcher.java 1.6 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8  * Licensed Materials - Property of IBM
9  * RMI-IIOP v1.0
10  * Copyright IBM Corp. 1998 1999 All Rights Reserved
11  *
12  * US Government Users Restricted Rights - Use, duplication or
13  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14  */

15
16 package com.sun.corba.se.impl.protocol;
17
18 import com.sun.corba.se.pept.protocol.MessageMediator;
19
20 import com.sun.corba.se.spi.ior.IOR;
21 import com.sun.corba.se.spi.ior.ObjectKey;
22 import com.sun.corba.se.spi.orb.ORB;
23 import com.sun.corba.se.spi.logging.CORBALogDomains;
24 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
25 import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
26
27 import com.sun.corba.se.impl.orbutil.ORBUtility;
28 import com.sun.corba.se.impl.logging.ORBUtilSystemException;
29
30 /**
31  * INSServerRequestDispatcher handles all INS related discovery request. The INS Service
32  * can be registered using ORB.register_initial_reference().
33  * This Singleton subcontract just
34  * finds the target IOR and does location forward.
35  * XXX PI points are not invoked in either dispatch() or locate() method this
36  * should be fixed in Tiger.
37  */

38 public class INSServerRequestDispatcher
39     implements CorbaServerRequestDispatcher
40 {
41
42     private ORB orb = null;
43     private ORBUtilSystemException wrapper ;
44
45     public INSServerRequestDispatcher( ORB orb ) {
46         this.orb = orb;
47     this.wrapper = ORBUtilSystemException.get( orb,
48         CORBALogDomains.RPC_PROTOCOL ) ;
49     }
50
51     // Need to signal one of OBJECT_HERE, OBJECT_FORWARD, OBJECT_NOT_EXIST.
52
public IOR locate(ObjectKey okey) {
53         // send a locate forward with the right IOR. If the insKey is not
54
// registered then it will throw OBJECT_NOT_EXIST Exception
55
String JavaDoc insKey = new String JavaDoc( okey.getBytes(orb) );
56         return getINSReference( insKey );
57     }
58
59     public void dispatch(MessageMediator mediator)
60     {
61     CorbaMessageMediator request = (CorbaMessageMediator) mediator;
62         // send a locate forward with the right IOR. If the insKey is not
63
// registered then it will throw OBJECT_NOT_EXIST Exception
64
String JavaDoc insKey = new String JavaDoc( request.getObjectKey().getBytes(orb) );
65     request.getProtocolHandler()
66         .createLocationForward(request, getINSReference( insKey ), null);
67         return;
68     }
69
70     /**
71      * getINSReference if it is registered in INSObjectKeyMap.
72      */

73     private IOR getINSReference( String JavaDoc insKey ) {
74         IOR entry = ORBUtility.getIOR( orb.getLocalResolver().resolve( insKey ) ) ;
75         if( entry != null ) {
76             // If entry is not null then the locate is with an INS Object key,
77
// so send a location forward with the right IOR.
78
return entry;
79         }
80
81     throw wrapper.servantNotFound() ;
82     }
83 }
84
Popular Tags