/** * Test catching the user exception, thrown on the remote side. */ public void testUserException() { System.out.println("**** Test user exception:"); ExceptionList exList = orb.create_exception_list(); exList.add(WeThrowThisExceptionHelper.type()); Request rq = object._create_request(null, "throwException", orb.create_list(1), null, exList, null ); rq.add_in_arg().insert_long(123); rq.invoke(); UnknownUserException uku = (UnknownUserException) rq.env().exception(); WeThrowThisException our_exception = WeThrowThisExceptionHelper.extract(uku.except); System.out.println(" Our user exception, field " + our_exception.ourField + ", has been thrown on remote side." ); }
/** * Create the request for the local call. */ public Request create_request(org.omg.CORBA.Object target, Context context, String operation, NVList parameters, NamedValue returns, ExceptionList exceptions, ContextList ctx_list ) { if (orb instanceof OrbFunctional) { ((OrbFunctional) orb).ensureRunning(); } gnuRequest g = new gnuRequest(); g.setORB(orb); g.setOperation(operation); g.setIor(ior); g.m_target = target; g.ctx(context); g.set_args(parameters); g.set_exceptions(exceptions); g.set_context_list(ctx_list); if (returns != null) g.set_result(returns); return g; }
/** @inheritDoc */ public TypeCode[] exceptions() { request.checkDii(); ExceptionList ex = request.exceptions(); TypeCode[] et = new TypeCode[ ex.count() ]; try { for (int i = 0; i < et.length; i++) { et [ i ] = ex.item(i); } } catch (Bounds e) { throw new Unexpected(e); } return et; }
/** * Creates the request to invoke the method on this object. * * @param target the object, for that the operation must be invoked. * @param context context (null allowed) * @param operation the method name * @param parameters the method parameters * @param returns the return value holder * * @return the created request. */ public Request create_request(org.omg.CORBA.Object target, Context context, String operation, NVList parameters, NamedValue returns, ExceptionList exceptions, ContextList ctx_list ) { gnuRequest request = getRequestInstance(target); request.setIor(ior); request.set_target(target); request.setOperation(operation); request.set_args(parameters); request.m_context = context; request.set_result(returns); request.set_exceptions(exceptions); request.set_context_list(ctx_list); request.setORB(orb); return request; }
public Request create_request(org.omg.CORBA.Object obj, Context ctx, String operation, NVList arg_list, NamedValue result, ExceptionList exclist, ContextList ctxlist) { return new RequestImpl(orb, obj, ctx, operation, arg_list, result, exclist, ctxlist); }
public Exception unmarshalDIIUserException(String repoId, InputStream is) { if (! isDIIRequest()) { return null; } ExceptionList _exceptions = diiRequest.exceptions(); try { // Find the typecode for the exception for (int i=0; i<_exceptions.count() ; i++) { TypeCode tc = _exceptions.item(i); if ( tc.id().equals(repoId) ) { // Since we dont have the actual user exception // class, the spec says we have to create an // UnknownUserException and put it in the // environment. Any eany = orb.create_any(); eany.read_value(is, (TypeCode)tc); return new UnknownUserException(eany); } } } catch (Exception b) { throw wrapper.unexpectedDiiException(b); } // must be a truly unknown exception return wrapper.unknownCorbaExc( CompletionStatus.COMPLETED_MAYBE); }
/** * See RequestInfoImpl for javadoc. */ public TypeCode[] exceptions (){ checkAccess( MID_EXCEPTIONS ); if( cachedExceptions == null ) { if( request == null ) { throw stdWrapper.piOperationNotSupported2() ; } // Get the list of exceptions from DII request data, If there are // no exceptions raised then this method will return null. ExceptionList excList = request.exceptions( ); int count = excList.count(); TypeCode[] excTCList = new TypeCode[count]; try { for( int i = 0; i < count; i++ ) { excTCList[i] = excList.item( i ); } } catch( Exception e ) { throw wrapper.exceptionInExceptions( e ) ; } cachedExceptions = excTCList; } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the TypeCode[] array. We also assume // they will not change the values of the containing TypeCodes. return cachedExceptions; }
/** * Test catching the system exception, thrown on the remote side. */ public void testSystemException() { System.out.println("**** Test system exception:"); try { ExceptionList exList = orb.create_exception_list(); exList.add(WeThrowThisExceptionHelper.type()); Request rq = object._create_request(null, "throwException", orb.create_list(1), null, exList, null ); rq.add_in_arg().insert_long(-55); rq.invoke(); throw new InternalError(); } catch (BAD_OPERATION ex) { System.out.println(" The expected BAD_OPERATION, minor code " + ex.minor + ", has been thrown on remote side." ); } }
/** * This method is not appropriate for the local objects and just * throws an exception. * * @throws NO_IMPLEMENT, always. */ public Request _create_request(Context context, String operation, NVList parameters, NamedValue returns, ExceptionList exceptions, ContextList ctx_list ) { throw new NO_IMPLEMENT(INAPPROPRIATE); }
/** * Create request for using with DII. */ public Request create_request(org.omg.CORBA.Object target, Context context, String method, NVList parameters, NamedValue returns, ExceptionList exceptions, ContextList ctx_list) { operation = method; LocalRequest rq = new LocalRequest(object, poa, Id); rq.setOperation(method); rq.set_args(parameters); rq.set_result(returns); rq.set_exceptions(exceptions); rq.set_context_list(ctx_list); return rq; }
/** * Not available. */ public TypeCode[] exceptions() { if (m_request == null) { throw new NO_RESOURCES(not_available, 1, CompletionStatus.COMPLETED_MAYBE ); } m_request.checkDii(); ExceptionList ex = m_request.exceptions(); TypeCode[] et = new TypeCode[ ex.count() ]; try { for (int i = 0; i < et.length; i++) { et [ i ] = ex.item(i); } } catch (Bounds e) { throw new Unexpected(e); } return et; }