下面列出了怎么用org.omg.CORBA.portable.ServantObject的API类实例代码及写法,或者点击链接到github查看源代码。
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to clone it.
OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
orb.pushInvocationInfo( info ) ;
try {
info.oa().enter() ;
} catch (OADestroyed pdes) {
throw wrapper.preinvokePoaDestroyed( pdes ) ;
}
return info ;
}
/** Check that the servant in info (which must not be null) is
* an instance of the expectedType. If not, set the thread local flag
* and return false.
*/
protected boolean checkForCompatibleServant( ServantObject so,
Class expectedType )
{
if (so == null)
return false ;
// Normally, this test will never fail. However, if the servant
// and the stub were loaded in different class loaders, this test
// will fail.
if (!expectedType.isInstance( so.servant )) {
isNextCallValid.set( Boolean.FALSE ) ;
// When servant_preinvoke returns null, the stub will
// recursively re-invoke itself. Thus, the next call made from
// the stub is another useLocalInvocation call.
return false ;
}
return true ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to clone it.
OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
orb.pushInvocationInfo( info ) ;
try {
info.oa().enter() ;
} catch (OADestroyed pdes) {
throw wrapper.preinvokePoaDestroyed( pdes ) ;
}
return info ;
}
/** Check that the servant in info (which must not be null) is
* an instance of the expectedType. If not, set the thread local flag
* and return false.
*/
protected boolean checkForCompatibleServant( ServantObject so,
Class expectedType )
{
if (so == null)
return false ;
// Normally, this test will never fail. However, if the servant
// and the stub were loaded in different class loaders, this test
// will fail.
if (!expectedType.isInstance( so.servant )) {
isNextCallValid.set( Boolean.FALSE ) ;
// When servant_preinvoke returns null, the stub will
// recursively re-invoke itself. Thus, the next call made from
// the stub is another useLocalInvocation call.
return false ;
}
return true ;
}
/** Check that the servant in info (which must not be null) is
* an instance of the expectedType. If not, set the thread local flag
* and return false.
*/
protected boolean checkForCompatibleServant( ServantObject so,
Class expectedType )
{
if (so == null)
return false ;
// Normally, this test will never fail. However, if the servant
// and the stub were loaded in different class loaders, this test
// will fail.
if (!expectedType.isInstance( so.servant )) {
isNextCallValid.set( Boolean.FALSE ) ;
// When servant_preinvoke returns null, the stub will
// recursively re-invoke itself. Thus, the next call made from
// the stub is another useLocalInvocation call.
return false ;
}
return true ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to clone it.
OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
orb.pushInvocationInfo( info ) ;
try {
info.oa().enter() ;
} catch (OADestroyed pdes) {
throw wrapper.preinvokePoaDestroyed( pdes ) ;
}
return info ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to clone it.
OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
orb.pushInvocationInfo( info ) ;
try {
info.oa().enter() ;
} catch (OADestroyed pdes) {
throw wrapper.preinvokePoaDestroyed( pdes ) ;
}
return info ;
}
/** Check that the servant in info (which must not be null) is
* an instance of the expectedType. If not, set the thread local flag
* and return false.
*/
protected boolean checkForCompatibleServant( ServantObject so,
Class expectedType )
{
if (so == null)
return false ;
// Normally, this test will never fail. However, if the servant
// and the stub were loaded in different class loaders, this test
// will fail.
if (!expectedType.isInstance( so.servant )) {
isNextCallValid.set( Boolean.FALSE ) ;
// When servant_preinvoke returns null, the stub will
// recursively re-invoke itself. Thus, the next call made from
// the stub is another useLocalInvocation call.
return false ;
}
return true ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to clone it.
OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
orb.pushInvocationInfo( info ) ;
try {
info.oa().enter() ;
} catch (OADestroyed pdes) {
throw wrapper.preinvokePoaDestroyed( pdes ) ;
}
return info ;
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
if (!checkForCompatibleServant( servant, expectedType ))
return null ;
return servant;
}
public void setServant( java.lang.Object servant )
{
if (servant != null && servant instanceof Tie) {
this.servant = new ServantObject();
this.servant.servant = ((Tie)servant).getTarget();
} else {
this.servant = null;
}
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
// REVISIT: Rewrite rmic.HelloTest and rmic.LocalStubTest
// (which directly call servant_preinvoke)
// then revert to exception again.
return null;
//throw new INTERNAL();
}
public void servant_postinvoke(org.omg.CORBA.Object self,
ServantObject servantobj)
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
cachedInfo.oa().exit() ;
orb.popInvocationInfo() ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to copy it.
OAInvocationInfo info = new OAInvocationInfo(cachedInfo, operation) ;
orb.pushInvocationInfo( info ) ;
return info ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (checkForCompatibleServant( cachedInfo, expectedType ))
return cachedInfo ;
else
return null ;
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
return
contactInfoList.getLocalClientRequestDispatcher()
.servant_preinvoke(self, operation, expectedType);
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
if (!checkForCompatibleServant( servant, expectedType ))
return null ;
return servant;
}
public void setServant( java.lang.Object servant )
{
if (servant != null && servant instanceof Tie) {
this.servant = new ServantObject();
this.servant.servant = ((Tie)servant).getTarget();
} else {
this.servant = null;
}
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
// REVISIT: Rewrite rmic.HelloTest and rmic.LocalStubTest
// (which directly call servant_preinvoke)
// then revert to exception again.
return null;
//throw new INTERNAL();
}
public void servant_postinvoke(org.omg.CORBA.Object self,
ServantObject servantobj)
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
cachedInfo.oa().exit() ;
orb.popInvocationInfo() ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to copy it.
OAInvocationInfo info = new OAInvocationInfo(cachedInfo, operation) ;
orb.pushInvocationInfo( info ) ;
return info ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (checkForCompatibleServant( cachedInfo, expectedType ))
return cachedInfo ;
else
return null ;
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
return
contactInfoList.getLocalClientRequestDispatcher()
.servant_preinvoke(self, operation, expectedType);
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
if (!checkForCompatibleServant( servant, expectedType ))
return null ;
return servant;
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
// REVISIT: Rewrite rmic.HelloTest and rmic.LocalStubTest
// (which directly call servant_preinvoke)
// then revert to exception again.
return null;
//throw new INTERNAL();
}
public void servant_postinvoke(org.omg.CORBA.Object self,
ServantObject servantobj)
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
cachedInfo.oa().exit() ;
orb.popInvocationInfo() ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (!checkForCompatibleServant( cachedInfo, expectedType ))
return null ;
// Note that info is shared across multiple threads
// using the same subcontract, each of which may
// have its own operation. Therefore we need to copy it.
OAInvocationInfo info = new OAInvocationInfo(cachedInfo, operation) ;
orb.pushInvocationInfo( info ) ;
return info ;
}
public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
String operation, Class expectedType )
{
OAInvocationInfo cachedInfo = getCachedInfo() ;
if (checkForCompatibleServant( cachedInfo, expectedType ))
return cachedInfo ;
else
return null ;
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
return
contactInfoList.getLocalClientRequestDispatcher()
.servant_preinvoke(self, operation, expectedType);
}
public ServantObject servant_preinvoke(org.omg.CORBA.Object self,
String operation,
Class expectedType)
{
if (!checkForCompatibleServant( servant, expectedType ))
return null ;
return servant;
}