1. /*
  2. * @(#)INSSubcontract.java 1.4 03/01/23
  3. *
  4. * Copyright 2003 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. package com.sun.corba.se.internal.corba;
  16. import org.omg.CORBA.NO_IMPLEMENT;
  17. import org.omg.CORBA.OBJECT_NOT_EXIST;
  18. import org.omg.CORBA.CompletionStatus;
  19. import org.omg.CORBA.ORB;
  20. import com.sun.corba.se.internal.core.ServerSubcontract;
  21. import com.sun.corba.se.internal.core.IOR;
  22. import com.sun.corba.se.internal.core.INSObjectKeyMap;
  23. import com.sun.corba.se.internal.core.INSObjectKeyEntry;
  24. import com.sun.corba.se.internal.core.ServerRequest;
  25. import com.sun.corba.se.internal.core.ServerResponse;
  26. import com.sun.corba.se.internal.ior.ObjectKey;
  27. import com.sun.corba.se.internal.orbutil.MinorCodes;
  28. /**
  29. * INSSubcontract handles all INS related discovery request. The INSService
  30. * can be registered using ORB.register_initial_reference(), these registrations
  31. * will be maintained in INSObjectKeyMap. This Singleton subcontract just
  32. * finds the target IOR and does location forward.
  33. * NOTE: PI points are not invoked in either dispatch() or locate() method this
  34. * should be fixed in Tiger.
  35. */
  36. public class INSSubcontract implements ServerSubcontract {
  37. private ORB orb = null;
  38. public INSSubcontract( ORB orb ) {
  39. this.orb = orb;
  40. }
  41. // Need to signal one of OBJECT_HERE, OBJECT_FORWARD, OBJECT_NOT_EXIST.
  42. public IOR locate(ObjectKey okey) {
  43. // send a locate forward with the right IOR. If the insKey is not
  44. // registered then it will throw OBJECT_NOT_EXIST Exception
  45. String insKey = new String( okey.getBytes(orb) );
  46. return getINSReference( insKey );
  47. }
  48. public ServerResponse dispatch(ServerRequest request) {
  49. // send a locate forward with the right IOR. If the insKey is not
  50. // registered then it will throw OBJECT_NOT_EXIST Exception
  51. String insKey = new String( request.getObjectKey().getBytes(orb) );
  52. return request.createLocationForward( getINSReference( insKey ), null);
  53. }
  54. /**
  55. * getINSReference if it is registered in INSObjectKeyMap.
  56. */
  57. protected IOR getINSReference( String insKey ) {
  58. INSObjectKeyEntry entry =
  59. INSObjectKeyMap.getInstance().getEntry(insKey);
  60. if( entry != null ) {
  61. // If entry is not null then the locate is with an INS Object key,
  62. // so send a location forward with the right IOR.
  63. return entry.getIOR( );
  64. }
  65. throw new OBJECT_NOT_EXIST(MinorCodes.SERVANT_NOT_FOUND,
  66. CompletionStatus.COMPLETED_NO);
  67. }
  68. public boolean isServantSupported() {
  69. return false;
  70. }
  71. public void destroyObjref(Object objref) {
  72. throw new NO_IMPLEMENT();
  73. }
  74. public Object createObjref(IOR ior) {
  75. throw new NO_IMPLEMENT();
  76. }
  77. public Object createObjref(byte[] key, Object servant) {
  78. throw new NO_IMPLEMENT();
  79. }
  80. public Object getServant(IOR ior) {
  81. throw new NO_IMPLEMENT();
  82. }
  83. public Class getClientSubcontractClass() {
  84. return null;
  85. }
  86. public void setId(int id) {
  87. throw new NO_IMPLEMENT();
  88. }
  89. public int getId() {
  90. throw new NO_IMPLEMENT();
  91. }
  92. private INSSubcontract( ) {
  93. orb = ORB.init( (String[]) null, (java.util.Properties) null );
  94. }
  95. public void setOrb(com.sun.corba.se.internal.core.ORB orb) {
  96. this.orb = orb;
  97. }
  98. }