📄 poaimpl.java
字号:
unlock() ; } } /** * <code>get_servant_manager</code> * <b>Section 3.3.8.10</b> */ public ServantManager get_servant_manager() throws WrongPolicy { try { lock() ; return mediator.getServantManager() ; } finally { unlock() ; } } /** * <code>set_servant_manager</code> * <b>Section 3.3.8.10</b> */ public void set_servant_manager(ServantManager servantManager) throws WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling set_servant_manager on poa " + this + " servantManager=" + servantManager ) ; } mediator.setServantManager( servantManager ) ; } finally { unlock() ; } } /** * <code>get_servant</code> * <b>Section 3.3.8.12</b> */ public Servant get_servant() throws NoServant, WrongPolicy { try { lock() ; return mediator.getDefaultServant() ; } finally { unlock() ; } } /** * <code>set_servant</code> * <b>Section 3.3.8.13</b> */ public void set_servant(Servant defaultServant) throws WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling set_servant on poa " + this + " defaultServant=" + defaultServant ) ; } mediator.setDefaultServant( defaultServant ) ; } finally { unlock() ; } } /** * <code>activate_object</code> * <b>Section 3.3.8.14</b> */ public byte[] activate_object(Servant servant) throws ServantAlreadyActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling activate_object on poa " + this + " (servant=" + servant + ")" ) ; } // Allocate a new system-generated object-id. // This will throw WrongPolicy if not SYSTEM_ID // policy. byte[] id = mediator.newSystemId(); try { mediator.activateObject( id, servant ) ; } catch (ObjectAlreadyActive oaa) { // This exception can not occur in this case, // since id is always brand new. // } return id ; } finally { if (debug) { ORBUtility.dprint( this, "Exiting activate_object on poa " + this ) ; } unlock() ; } } /** * <code>activate_object_with_id</code> * <b>Section 3.3.8.15</b> */ public void activate_object_with_id(byte[] id, Servant servant) throws ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling activate_object_with_id on poa " + this + " (servant=" + servant + " id=" + id + ")" ) ; } // Clone the id to avoid possible errors due to aliasing // (e.g. the client passes the id in and then changes it later). byte[] idClone = (byte[])(id.clone()) ; mediator.activateObject( idClone, servant ) ; } finally { if (debug) { ORBUtility.dprint( this, "Exiting activate_object_with_id on poa " + this ) ; } unlock() ; } } /** * <code>deactivate_object</code> * <b>3.3.8.16</b> */ public void deactivate_object(byte[] id) throws ObjectNotActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling deactivate_object on poa " + this + " (id=" + id + ")" ) ; } mediator.deactivateObject( id ) ; } finally { if (debug) { ORBUtility.dprint( this, "Exiting deactivate_object on poa " + this ) ; } unlock() ; } } /** * <code>create_reference</code> * <b>3.3.8.17</b> */ public org.omg.CORBA.Object create_reference(String repId) throws WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling create_reference(repId=" + repId + ") on poa " + this ) ; } return makeObject( repId, mediator.newSystemId()) ; } finally { unlock() ; } } /** * <code>create_reference_with_id</code> * <b>3.3.8.18</b> */ public org.omg.CORBA.Object create_reference_with_id(byte[] oid, String repId) { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling create_reference_with_id(oid=" + oid + " repId=" + repId + ") on poa " + this ) ; } // Clone the id to avoid possible errors due to aliasing // (e.g. the client passes the id in and then changes it later). byte[] idClone = (byte[])(oid.clone()) ; return makeObject( repId, idClone ) ; } finally { unlock() ; } } /** * <code>servant_to_id</code> * <b>3.3.8.19</b> */ public byte[] servant_to_id(Servant servant) throws ServantNotActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling servant_to_id(servant=" + servant + ") on poa " + this ) ; } return mediator.servantToId( servant ) ; } finally { unlock() ; } } /** * <code>servant_to_reference</code> * <b>3.3.8.20</b> */ public org.omg.CORBA.Object servant_to_reference(Servant servant) throws ServantNotActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling servant_to_reference(servant=" + servant + ") on poa " + this ) ; } byte[] oid = mediator.servantToId(servant); String repId = servant._all_interfaces( this, oid )[0] ; return create_reference_with_id(oid, repId); } finally { unlock() ; } } /** * <code>reference_to_servant</code> * <b>3.3.8.21</b> */ public Servant reference_to_servant(org.omg.CORBA.Object reference) throws ObjectNotActive, WrongPolicy, WrongAdapter { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling reference_to_servant(reference=" + reference + ") on poa " + this ) ; } if ( state >= STATE_DESTROYING ) { throw lifecycleWrapper().adapterDestroyed() ; } // reference_to_id should throw WrongAdapter // if the objref was not created by this POA byte [] id = internalReferenceToId(reference); return mediator.idToServant( id ) ; } finally { unlock() ; } } /** * <code>reference_to_id</code> * <b>3.3.8.22</b> */ public byte[] reference_to_id(org.omg.CORBA.Object reference) throws WrongAdapter, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling reference_to_id(reference=" + reference + ") on poa " + this ) ; } if( state >= STATE_DESTROYING ) { throw lifecycleWrapper().adapterDestroyed() ; } return internalReferenceToId( reference ) ; } finally { unlock() ; } } /** * <code>id_to_servant</code> * <b>3.3.8.23</b> */ public Servant id_to_servant(byte[] id) throws ObjectNotActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling id_to_servant(id=" + id + ") on poa " + this ) ; } if( state >= STATE_DESTROYING ) { throw lifecycleWrapper().adapterDestroyed() ; } return mediator.idToServant( id ) ; } finally { unlock() ; } } /** * <code>id_to_reference</code> * <b>3.3.8.24</b> */ public org.omg.CORBA.Object id_to_reference(byte[] id) throws ObjectNotActive, WrongPolicy { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling id_to_reference(id=" + id + ") on poa " + this ) ; } if( state >= STATE_DESTROYING ) { throw lifecycleWrapper().adapterDestroyed() ; } Servant s = mediator.idToServant( id ) ; String repId = s._all_interfaces( this, id )[0] ; return makeObject(repId, id ); } finally { unlock() ; } } /** * <code>id</code> * <b>11.3.8.26 in ptc/00-08-06</b> */ public byte[] id() { try { lock() ; return getAdapterId() ; } finally { unlock() ; } } //*************************************************************** //Implementation of ObjectAdapter interface //*************************************************************** public Policy getEffectivePolicy( int type ) { return mediator.getPolicies().get_effective_policy( type ) ; } public int getManagerId() { return manager.getManagerId() ; } public short getState() { return manager.getORTState() ; } public String[] getInterfaces( java.lang.Object servant, byte[] objectId ) { Servant serv = (Servant)servant ; return serv._all_interfaces( this, objectId ) ; } protected ObjectCopierFactory getObjectCopierFactory() { int copierId = mediator.getPolicies().getCopierId() ; CopierManager cm = getORB().getCopierManager() ; return cm.getObjectCopierFactory( copierId ) ; } public void enter() throws OADestroyed { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling enter on poa " + this ) ; } // Avoid deadlock if this is the thread that is processing the // POA.destroy because this is the only thread that can notify // waiters on beingDestroyedCV. This can happen if an // etherealize upcall invokes a method on a colocated object // served by this POA. while ((state == STATE_DESTROYING) && (isDestroying.get() == Boolean.FALSE)) { try { beingDestroyedCV.await(); } catch (InterruptedException ex) { // NO-OP } } if (!waitUntilRunning()) throw new OADestroyed() ; invocationCount++; } finally { if (debug) { ORBUtility.dprint( this, "Exiting enter on poa " + this ) ; } unlock() ; } manager.enter(); } public void exit() { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling exit on poa " + this ) ; } invocationCount--; if ((invocationCount == 0) && (state == STATE_DESTROYING)) { invokeCV.broadcast(); } } finally { if (debug) { ORBUtility.dprint( this, "Exiting exit on poa " + this ) ; } unlock() ; } manager.exit(); } public void getInvocationServant( OAInvocationInfo info ) { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling getInvocationServant on poa " + this ) ; } java.lang.Object servant = null ; try { servant = mediator.getInvocationServant( info.id(), info.getOperation() ); } catch (ForwardRequest freq) { throw new ForwardException( getORB(), freq.forward_reference ) ; } info.setServant( servant ) ; } finally { if (debug) { ORBUtility.dprint( this, "Exiting getInvocationServant on poa " + this ) ; } unlock() ; } } public org.omg.CORBA.Object getLocalServant( byte[] objectId ) { return null ; } /** Called from the subcontract to let this POA cleanup after an * invocation. Note: If getServant was called, then returnServant * MUST be called, even in the case of exceptions. This may be * called multiple times for a single request. */ public void returnServant() { try { lock() ; if (debug) { ORBUtility.dprint( this, "Calling returnServant on poa " + this ) ; } mediator.returnServant(); } catch (Throwable thr) { if (debug) { ORBUtility.dprint( this, "Exception " + thr + " in returnServant on poa " + this ) ; } if (thr instanceof Error) throw (Error)thr ; else if (thr instanceof RuntimeException) throw (RuntimeException)thr ; } finally { if (debug) { ORBUtility.dprint( this, "Exiting returnServant on poa " + this ) ; } unlock() ; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -