/** * Test catching the system exception, thrown on the remote side. */ public void testSystemException() { System.out.println("**** Test system exception:"); try { // Negative parameter = system exception. object.throwException(-55); } catch (BAD_OPERATION ex) { System.out.println(" The expected BAD_OPERATION, minor code " + ex.minor + ", has been thrown on remote side." ); } catch (UserException uex) { throw new InternalError(); } }
/** * Create the DynAny using the passed value as template and assign this value. */ public DynAny create_dyn_any(Any value) throws InconsistentTypeCode { DynAny created = create_dyn_any_from_type_code(value.type()); try { created.from_any(value); } catch (UserException uex) { InconsistentTypeCode t = new InconsistentTypeCode("Inconsistent Any"); t.initCause(uex); throw t; } catch (Exception e) { throw new Unexpected(e); } return created; }
/** * Reads the user exception, having the given Id, from the input stream. The * id is expected to be in the form like * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0' * * @param idl the exception idl name. * @param input the stream to read from. * * @return the loaded exception. * @return null if the helper class cannot be found. */ public static UserException readUserException(String idl, InputStream input) { try { Class helperClass = findHelper(idl); Method read = helperClass.getMethod("read", new Class[] { org.omg.CORBA.portable.InputStream.class }); return (UserException) read.invoke(null, new Object[] { input }); } catch (MARSHAL mex) { // This one is ok to throw throw mex; } catch (Exception ex) { ex.printStackTrace(); return null; } }
private void createSSLTaggedComponent(IIOPProfileTemplate profileTemplate, int port) throws UserException { SSL ssl = new SSL(); ssl.port = (short) port; short sslOptions = Integrity.value | Confidentiality.value | DetectMisordering.value | DetectReplay.value | EstablishTrustInTarget.value | EstablishTrustInClient.value; ssl.target_supports = sslOptions; ssl.target_requires = sslOptions; GIOPVersion giopVersion = orb.getORBData().getGIOPVersion(); CDREncapsCodec codec = new CDREncapsCodec(orb, giopVersion.getMajor(),giopVersion.getMinor()); Any any = orb.create_any(); SSLHelper.insert(any, ssl); byte[] componentData = codec.encode_value(any); TaggedComponent sslTaggedComponent = new TaggedComponent(TAG_SSL_SEC_TRANS.value, componentData); TaggedComponentFactoryFinder finder = orb.getTaggedComponentFactoryFinder(); Object newTaggedComponent = finder.create( orb, sslTaggedComponent); profileTemplate.add(newTaggedComponent); }
/** * Write the TypeCode. This implementation delegates functionality * to {@link cdrTypeCode}. * * @param x a TypeCode to write. */ public void write_TypeCode(TypeCode x) { try { TypeCodeHelper.write(this, x); } catch (UserException ex) { Unexpected.error(ex); } }
/** * Checks if the given type can be encoded. Currently only checks for wide * strings and wide chars for GIOP 1.0. * * @param t a typecode to chek. * * @throws InvalidTypeForEncoding if the typecode is not valid for the given * version. */ private void checkTypePossibility(String name, TypeCode t) throws InvalidTypeForEncoding { if (noWide) { try { int kind = t.kind().value(); if (kind == TCKind._tk_wchar || kind == TCKind._tk_wstring) throw new InvalidTypeForEncoding(name + " wide char in " + version ); else if (kind == TCKind._tk_alias || kind == TCKind._tk_array || kind == TCKind._tk_sequence ) checkTypePossibility("Array member", t.content_type()); else if (kind == TCKind._tk_struct || kind == TCKind._tk_union) { for (int i = 0; i < t.member_count(); i++) { checkTypePossibility(t.member_name(i), t.member_type(i)); } } } catch (UserException ex) { InternalError ierr = new InternalError(); ierr.initCause(ex); throw ierr; } } }
/** * Insert this exception into the given Any. On failure, insert the UNKNOWN * exception. */ public static void insertException(Any into, Throwable exception) { boolean ok = false; if (exception instanceof SystemException) ok = insertSysException(into, (SystemException) exception); else if (exception instanceof UserException) ok = insertWithHelper(into, exception); if (!ok) ok = insertSysException(into, new UNKNOWN()); if (!ok) throw new InternalError("Exception wrapping broken"); }
public Object export(Remote server, Class<?> remoteClass) throws RemoteException { try { PortableRemoteObject.exportObject(server); POA poa = getPOA(); Object servant = Util.getTie(server); Object ref = poa.servant_to_reference((Servant)servant); return PortableRemoteObject.narrow(ref, remoteClass); } catch(UserException e) { throw new ExportException("could not export corba stream servant", e); } }
public void invokeClientPIStartingPoint() throws RemarshalException { if( !hasClientInterceptors ) return; if( !isClientPIEnabledForThisThread() ) return; // Invoke the starting interception points and record exception // and reply status info in the info object: ClientRequestInfoImpl info = peekClientRequestInfoImplStack(); interceptorInvoker.invokeClientInterceptorStartingPoint( info ); // Check reply status. If we will not have another chance later // to invoke the client ending points, do it now. short replyStatus = info.getReplyStatus(); if( (replyStatus == SYSTEM_EXCEPTION.value) || (replyStatus == LOCATION_FORWARD.value) ) { // Note: Transport retry cannot happen here since this happens // before the request hits the wire. Exception exception = invokeClientPIEndingPoint( convertPIReplyStatusToReplyMessage( replyStatus ), info.getException() ); if( exception == null ) { // Do not throw anything. Otherwise, it must be a // SystemException, UserException or RemarshalException. } if( exception instanceof SystemException ) { throw (SystemException)exception; } else if( exception instanceof RemarshalException ) { throw (RemarshalException)exception; } else if( (exception instanceof UserException) || (exception instanceof ApplicationException) ) { // It should not be possible for an interceptor to throw // a UserException. By asserting instead of throwing the // UserException, we need not declare anything but // RemarshalException in the throws clause. throw wrapper.exceptionInvalid() ; } } else if( replyStatus != ClientRequestInfoImpl.UNINITIALIZED ) { throw wrapper.replyStatusNotInit() ; } }
public void raise_exception_with_list(org.omg.CORBA.TypeCode[] exc_list) throws org.omg.CORBA.UserException { throw new NO_IMPLEMENT(); }