FileDocCategorySizeDatePackage
ReflectiveTie.javaAPI DocJava SE 6 API4612Tue Jun 10 00:21:40 BST 2008com.sun.corba.se.impl.presentation.rmi

ReflectiveTie

public final class ReflectiveTie extends org.omg.PortableServer.Servant implements javax.rmi.CORBA.Tie

Fields Summary
private Remote
target
private com.sun.corba.se.spi.presentation.rmi.PresentationManager
pm
private PresentationManager.ClassData
classData
private com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
Constructors Summary
public ReflectiveTie(com.sun.corba.se.spi.presentation.rmi.PresentationManager pm, com.sun.corba.se.impl.logging.ORBUtilSystemException wrapper)


          
    
	SecurityManager s = System.getSecurityManager();
 	if (s != null) {
 	    s.checkPermission(new DynamicAccessPermission("access"));
 	}
	this.pm = pm ;
	this.wrapper = wrapper ;
    
Methods Summary
public java.lang.String[]_all_interfaces(org.omg.PortableServer.POA poa, byte[] objectId)

	return classData.getTypeIds() ;
    
public org.omg.CORBA.portable.OutputStream_invoke(java.lang.String method, org.omg.CORBA.portable.InputStream _in, org.omg.CORBA.portable.ResponseHandler reply)

	Method javaMethod = null ;
	DynamicMethodMarshaller dmm = null;

        try {
            InputStream in = (InputStream) _in;

	    javaMethod = classData.getIDLNameTranslator().getMethod( method ) ;
	    if (javaMethod == null)
		throw wrapper.methodNotFoundInTie( method, 
		    target.getClass().getName() ) ;

	    dmm = pm.getDynamicMethodMarshaller( javaMethod ) ;

	    Object[] args = dmm.readArguments( in ) ;

	    Object result = javaMethod.invoke( target, args ) ;

	    OutputStream os = (OutputStream)reply.createReply() ;

	    dmm.writeResult( os, result ) ; 

	    return os ;
	} catch (IllegalAccessException ex) {
	    throw wrapper.invocationErrorInReflectiveTie( ex, 
		javaMethod.getName(), 
		    javaMethod.getDeclaringClass().getName() ) ;
	} catch (IllegalArgumentException ex) {
	    throw wrapper.invocationErrorInReflectiveTie( ex, 
		javaMethod.getName(), 
		    javaMethod.getDeclaringClass().getName() ) ;
	} catch (InvocationTargetException ex) {
	    // Unwrap the actual exception so that it can be wrapped by an
	    // UnknownException or thrown if it is a system exception.
	    // This is expected in the server dispatcher code.
	    Throwable thr = ex.getCause() ;
	    if (thr instanceof SystemException)
		throw (SystemException)thr ;
	    else if ((thr instanceof Exception) && 
		dmm.isDeclaredException( thr )) {
		OutputStream os = (OutputStream)reply.createExceptionReply() ;
		dmm.writeException( os, (Exception)thr ) ;
		return os ;	
	    } else
		throw new UnknownException( thr ) ;
        }
    
public voiddeactivate()

        try{
	    _poa().deactivate_object(_poa().servant_to_id(this));
        } catch (org.omg.PortableServer.POAPackage.WrongPolicy exception){
	    // ignore 
        } catch (org.omg.PortableServer.POAPackage.ObjectNotActive exception){
	    // ignore 
        } catch (org.omg.PortableServer.POAPackage.ServantNotActive exception){
	    // ignore 
        }
    
public java.rmi.RemotegetTarget()

        return target;
    
public org.omg.CORBA.ORBorb()

        return _orb();
    
public voidorb(org.omg.CORBA.ORB orb)

        try {
	    ORB myORB = (ORB)orb ;

            ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this);
        } catch (ClassCastException e) {
	    throw wrapper.badOrbForServant( e ) ;
        }
    
public voidsetTarget(java.rmi.Remote target)

        this.target = target;

	if (target == null) {
	    classData = null ;
	} else {
	    Class targetClass = target.getClass() ;
	    classData = pm.getClassData( targetClass ) ;
	}
    
public org.omg.CORBA.ObjectthisObject()

        return _this_object();