1. /*
  2. * @(#)InitialNamingImpl.java 1.19 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. package com.sun.corba.se.internal.Activation;
  8. import org.omg.CORBA.ORB;
  9. import org.omg.CORBA.Object;
  10. import org.omg.CORBA.INITIALIZE;
  11. import org.omg.CORBA.CompletionStatus;
  12. import org.omg.CORBA.ORBPackage.InvalidName;
  13. import com.sun.corba.se.internal.CosNaming.BootstrapServer;
  14. import com.sun.corba.se.ActivationIDL.InitialNameServicePackage.NameAlreadyBound;
  15. import com.sun.corba.se.ActivationIDL._InitialNameServiceImplBase;
  16. /**
  17. *
  18. * @version 1.19, 04/02/22
  19. * @author Rohit Garg
  20. * @since JDK1.2
  21. */
  22. public class InitialNamingImpl extends _InitialNameServiceImplBase
  23. {
  24. InitialNamingImpl(ORB theOrb, BootstrapServer initialBoot)
  25. {
  26. orb = theOrb;
  27. bootServer = initialBoot;
  28. ((com.sun.corba.se.internal.corba.ORB)orb).connect(this);
  29. try {
  30. bind("InitialNameService", this, false);
  31. } catch (NameAlreadyBound ex) {
  32. throw new INITIALIZE(MinorCodes.CANNOT_ADD_INITIAL_NAMING,
  33. CompletionStatus.COMPLETED_NO);
  34. }
  35. }
  36. synchronized public void bind(String name, Object obj, boolean save)
  37. throws NameAlreadyBound
  38. {
  39. // If no Service is registered with the name then register the Service
  40. if( bootServer.getService( name ) == null ) {
  41. bootServer.addService(name, orb.object_to_string(obj), save);
  42. } else {
  43. throw new NameAlreadyBound();
  44. }
  45. }
  46. ORB orb;
  47. BootstrapServer bootServer;
  48. }