FileDocCategorySizeDatePackage
ExceptionHandlerImpl.javaAPI DocJava SE 5 API7055Fri Aug 26 14:54:30 BST 2005com.sun.corba.se.impl.presentation.rmi

ExceptionHandlerImpl

public class ExceptionHandlerImpl extends Object implements ExceptionHandler

Fields Summary
private ExceptionRW[]
rws
private final com.sun.corba.se.impl.logging.ORBUtilSystemException
wrapper
Constructors Summary
public ExceptionHandlerImpl(Class[] exceptions)

	wrapper = ORBUtilSystemException.get( 
	    CORBALogDomains.RPC_PRESENTATION ) ;

	int count = 0 ;
	for (int ctr=0; ctr<exceptions.length; ctr++) {
	    Class cls = exceptions[ctr] ;
	    if (!RemoteException.class.isAssignableFrom(cls))
		count++ ;
	}

	rws = new ExceptionRW[count] ;

	int index = 0 ;
	for (int ctr=0; ctr<exceptions.length; ctr++) {
	    Class cls = exceptions[ctr] ;
	    if (!RemoteException.class.isAssignableFrom(cls)) {
		ExceptionRW erw = null ;
		if (UserException.class.isAssignableFrom(cls))
		    erw = new ExceptionRWIDLImpl( cls ) ;
		else
		    erw = new ExceptionRWRMIImpl( cls ) ;

		/* The following check is not performed
		 * in order to maintain compatibility with 
		 * rmic.  See bug 4989312.
		 
		// Check for duplicate repository ID
		String repositoryId = erw.getId() ;
		int duplicateIndex = findDeclaredException( repositoryId ) ;
		if (duplicateIndex > 0) {
		    ExceptionRW duprw = rws[duplicateIndex] ;
		    String firstClassName = 
			erw.getExceptionClass().getName() ;
		    String secondClassName = 
			duprw.getExceptionClass().getName() ;
		    throw wrapper.duplicateExceptionRepositoryId(
			firstClassName, secondClassName, repositoryId ) ;
		}

		*/

		rws[index++] = erw ;
	    }
	}
    
Methods Summary
private intfindDeclaredException(java.lang.Class cls)

        for (int ctr = 0; ctr < rws.length; ctr++) {
            Class next = rws[ctr].getExceptionClass() ;
            if (next.isAssignableFrom(cls))
		return ctr ;
        }

        return -1 ;
    
private intfindDeclaredException(java.lang.String repositoryId)

	for (int ctr=0; ctr<rws.length; ctr++) {
	    // This may occur when rws has not been fully 
	    // populated, in which case the search should just fail.
	    if (rws[ctr]==null)
		return -1 ;

	    String rid = rws[ctr].getId() ;
	    if (repositoryId.equals( rid )) 
		return ctr ;
	}

	return -1 ;
    
public com.sun.corba.se.impl.presentation.rmi.ExceptionHandlerImpl$ExceptionRWgetRMIExceptionRW(java.lang.Class cls)

	return new ExceptionRWRMIImpl( cls ) ;
    
public booleanisDeclaredException(java.lang.Class cls)

	return findDeclaredException( cls ) >= 0 ;
    
public java.lang.ExceptionreadException(org.omg.CORBA.portable.ApplicationException ae)

	// Note that the exception ID is present in both ae 
	// and in the input stream from ae.  The exception 
	// reader must actually read the exception ID from
	// the stream.
	InputStream is = (InputStream)ae.getInputStream() ;
	String excName = ae.getId() ;
	int index = findDeclaredException( excName ) ;
	if (index < 0) {
	    excName = is.read_string() ;
	    Exception res = new UnexpectedException( excName ) ;
	    res.initCause( ae ) ;
	    return res ;
	}

	return rws[index].read( is ) ;
    
public voidwriteException(org.omg.CORBA_2_3.portable.OutputStream os, java.lang.Exception ex)

	int index = findDeclaredException( ex.getClass() ) ;
	if (index < 0)
	    throw wrapper.writeUndeclaredException( ex,
		ex.getClass().getName() ) ;

	rws[index].write( os, ex ) ;