1 22 package org.jboss.iiop.rmi.ir; 23 24 import org.omg.CORBA.ORB ; 25 import org.omg.CORBA.IRObject ; 26 import org.omg.CORBA.IRObjectOperations ; 27 import org.omg.CORBA.DefinitionKind ; 28 import org.omg.CORBA.BAD_INV_ORDER ; 29 import org.omg.CORBA.UserException ; 30 import org.omg.CORBA.CompletionStatus ; 31 import org.omg.PortableServer.POA ; 32 import org.omg.PortableServer.Servant ; 33 import org.omg.PortableServer.POAPackage.WrongPolicy ; 34 import org.omg.PortableServer.POAPackage.ServantAlreadyActive ; 35 import org.omg.PortableServer.POAPackage.ObjectAlreadyActive ; 36 import org.omg.PortableServer.POAPackage.ObjectNotActive ; 37 39 45 abstract class IRObjectImpl 46 implements IRObjectOperations 47 { 48 50 52 protected RepositoryImpl repository; 53 protected DefinitionKind def_kind; 54 55 56 58 private static final org.jboss.logging.Logger logger = 59 org.jboss.logging.Logger.getLogger(IRObjectImpl.class); 60 61 63 IRObjectImpl(DefinitionKind def_kind, RepositoryImpl repository) 64 { 65 this.def_kind = def_kind; 66 this.repository = repository; 67 } 68 69 71 73 public DefinitionKind def_kind() 74 { 75 logger.trace("IRObjectImpl.def_kind() entered."); 76 return def_kind; 77 } 78 79 public void destroy() 80 { 81 throw new BAD_INV_ORDER ("Cannot destroy RMI/IIOP mapping.", 2, 82 CompletionStatus.COMPLETED_NO); 83 } 84 85 87 abstract public IRObject getReference(); 88 89 public void allDone() 90 throws IRConstructionException 91 { 92 getReference(); 93 } 94 95 98 public void shutdown() 99 { 100 POA poa = getPOA(); 101 102 try { 103 poa.deactivate_object(poa.reference_to_id(getReference())); 104 } catch (UserException ex) { 105 logger.warn("Could not deactivate IR object", ex); 106 } 107 } 108 109 public RepositoryImpl getRepository() 110 { 111 return repository; 112 } 113 114 116 118 121 protected ORB getORB() 122 { 123 return repository.orb; 124 } 125 126 129 protected POA getPOA() 130 { 131 return repository.poa; 132 } 133 134 137 protected abstract byte[] getObjectId(); 138 139 142 protected org.omg.CORBA.Object servantToReference(Servant servant) 143 { 144 byte[] id = getObjectId(); 145 146 try { 147 150 153 logger.debug("#### IRObject.srv2ref: id=[" + new String (id) + "]"); 154 repository.poa.activate_object_with_id(id, servant); 155 org.omg.CORBA.Object ref = repository.poa.id_to_reference(id); 156 logger.debug("#### IRObject.srv2ref: returning ref."); 157 return ref; 159 } catch (WrongPolicy ex) { 160 logger.debug("Exception converting CORBA servant to reference", ex); 161 } catch (ServantAlreadyActive ex) { 162 logger.debug("Exception converting CORBA servant to reference", ex); 163 } catch (ObjectAlreadyActive ex) { 164 logger.debug("Exception converting CORBA servant to reference", ex); 165 } catch (ObjectNotActive ex) { 166 logger.debug("Exception converting CORBA servant to reference", ex); 167 } 170 return null; 171 } 172 173 175 } 177 | Popular Tags |