Save This Page
Home » openjdk-7 » com.sun.corba.se.impl » protocol » [javadoc | source]
    1   /*
    2    * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   /*
   26    * Licensed Materials - Property of IBM
   27    * RMI-IIOP v1.0
   28    * Copyright IBM Corp. 1998 1999  All Rights Reserved
   29    *
   30    */
   31   
   32   package com.sun.corba.se.impl.protocol;
   33   
   34   import com.sun.corba.se.pept.protocol.MessageMediator;
   35   
   36   import com.sun.corba.se.spi.ior.IOR;
   37   import com.sun.corba.se.spi.ior.ObjectKey;
   38   import com.sun.corba.se.spi.orb.ORB;
   39   import com.sun.corba.se.spi.logging.CORBALogDomains;
   40   import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher;
   41   import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
   42   
   43   import com.sun.corba.se.impl.orbutil.ORBUtility;
   44   import com.sun.corba.se.impl.logging.ORBUtilSystemException;
   45   
   46   /**
   47    * INSServerRequestDispatcher handles all INS related discovery request. The INS Service
   48    * can be registered using ORB.register_initial_reference().
   49    * This Singleton subcontract just
   50    * finds the target IOR and does location forward.
   51    * XXX PI points are not invoked in either dispatch() or locate() method this
   52    * should be fixed in Tiger.
   53    */
   54   public class INSServerRequestDispatcher
   55       implements CorbaServerRequestDispatcher
   56   {
   57   
   58       private ORB orb = null;
   59       private ORBUtilSystemException wrapper ;
   60   
   61       public INSServerRequestDispatcher( ORB orb ) {
   62           this.orb = orb;
   63           this.wrapper = ORBUtilSystemException.get( orb,
   64               CORBALogDomains.RPC_PROTOCOL ) ;
   65       }
   66   
   67       // Need to signal one of OBJECT_HERE, OBJECT_FORWARD, OBJECT_NOT_EXIST.
   68       public IOR locate(ObjectKey okey) {
   69           // send a locate forward with the right IOR. If the insKey is not
   70           // registered then it will throw OBJECT_NOT_EXIST Exception
   71           String insKey = new String( okey.getBytes(orb) );
   72           return getINSReference( insKey );
   73       }
   74   
   75       public void dispatch(MessageMediator mediator)
   76       {
   77           CorbaMessageMediator request = (CorbaMessageMediator) mediator;
   78           // send a locate forward with the right IOR. If the insKey is not
   79           // registered then it will throw OBJECT_NOT_EXIST Exception
   80           String insKey = new String( request.getObjectKey().getBytes(orb) );
   81           request.getProtocolHandler()
   82               .createLocationForward(request, getINSReference( insKey ), null);
   83           return;
   84       }
   85   
   86       /**
   87        * getINSReference if it is registered in INSObjectKeyMap.
   88        */
   89       private IOR getINSReference( String insKey ) {
   90           IOR entry = ORBUtility.getIOR( orb.getLocalResolver().resolve( insKey ) ) ;
   91           if( entry != null ) {
   92               // If entry is not null then the locate is with an INS Object key,
   93               // so send a location forward with the right IOR.
   94               return entry;
   95           }
   96   
   97           throw wrapper.servantNotFound() ;
   98       }
   99   }

Save This Page
Home » openjdk-7 » com.sun.corba.se.impl » protocol » [javadoc | source]