/** * @deprecated */ private static void loadLibrary() { //--agregar dlls faltantes para utilizar jtwain String arch = System.getenv("PROCESSOR_ARCHITECTURE"); String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432"); String realArch = arch.endsWith(ARCHITECTURE_X32) || wow64Arch != null && wow64Arch.endsWith(ARCHITECTURE_X32) ? ARCHITECTURE_X32 : "64"; if (System.getProperty("os.name").startsWith("Windows")) { try { if (realArch.equals(ARCHITECTURE_X32)) { System.load(LIB_X32 + NAME); System.out.println("cargada lib twain x32 "); } else { System.load(LIB_X64 + NAME); System.out.println("cargada lib twain x64 "); } } catch (SystemException e) { System.out.println(e.getMessage()); } } }
private void addExceptionDetailMessage(CorbaMessageMediator mediator, SystemException ex, ServiceContexts serviceContexts) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(baos); ex.printStackTrace(pw); pw.flush(); // NOTE: you must flush or baos will be empty. EncapsOutputStream encapsOutputStream = sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)mediator.getBroker()); encapsOutputStream.putEndian(); encapsOutputStream.write_wstring(baos.toString()); UnknownServiceContext serviceContext = new UnknownServiceContext(ExceptionDetailMessage.value, encapsOutputStream.toByteArray()); serviceContexts.put(serviceContext); }
/** * Binds the object to the name component as the specified binding type. * It creates a InternalBindingKey object and a InternalBindingValue * object and inserts them in the hash table. * @param n A single org.omg.CosNaming::NameComponent under which the * object will be bound. * @param obj An object reference to be bound under the supplied name. * @param bt The type of the binding (i.e., as object or as context). * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA * system exceptions. */ public final void Bind(NameComponent n, org.omg.CORBA.Object obj, BindingType bt) throws org.omg.CORBA.SystemException { // Create a key and a value InternalBindingKey key = new InternalBindingKey(n); NameComponent[] name = new NameComponent[1]; name[0] = n; Binding b = new Binding(name,bt); InternalBindingValue value = new InternalBindingValue(b,null); value.theObjectRef = obj; // insert it InternalBindingValue oldValue = (InternalBindingValue)this.theHashtable.put(key,value); if (oldValue != null) { updateLogger.warning( LogKeywords.NAMING_BIND + "Name " + getName( n ) + " Was Already Bound" ); throw wrapper.transNcBindAlreadyBound() ; } if( updateLogger.isLoggable( Level.FINE ) ) { updateLogger.fine( LogKeywords.NAMING_BIND_SUCCESS + "Name Component: " + n.id + "." + n.kind ); } }
/** * Destroys the NamingContext. */ public void Destroy() throws SystemException { // XXX note that orb.disconnect is illegal here, since the // POA is used. However, there may be some associated state // that needs to be cleaned up in ServerManagerImpl which we will // look into further at another time. /* // XXX This needs to be replaced by cleaning up the // file that backs up the naming context. No explicit // action is necessary at the POA level, since this is // created with the non-retain policy. /* try { orb.disconnect( theNameServiceHandle.getObjectReferenceFromKey( this.objKey ) ); } catch( org.omg.CORBA.SystemException e ) { throw e; } catch( Exception e ) { throw updateWrapper.transNcDestroyGotEx( e ) ; } */ }
/** * The <tt>isLocal</tt> method has the same semantics as the * ObjectImpl._is_local method, except that it can throw a RemoteException. * (no it doesn't but the spec says it should.) * * The <tt>_is_local()</tt> method is provided so that stubs may determine * if a particular object is implemented by a local servant and hence local * invocation APIs may be used. * * @param stub the stub to test. * * @return The <tt>_is_local()</tt> method returns true if * the servant incarnating the object is located in the same process as * the stub and they both share the same ORB instance. The <tt>_is_local()</tt> * method returns false otherwise. The default behavior of <tt>_is_local()</tt> is * to return false. * * @throws RemoteException The Java to IDL specification does to * specify the conditions that cause a RemoteException to be thrown. */ public boolean isLocal(javax.rmi.CORBA.Stub stub) throws RemoteException { boolean result = false ; try { org.omg.CORBA.portable.Delegate delegate = stub._get_delegate() ; if (delegate instanceof CorbaClientDelegate) { // For the Sun ORB CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ; ContactInfoList cil = cdel.getContactInfoList() ; if (cil instanceof CorbaContactInfoList) { CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; LocalClientRequestDispatcher lcs = ccil.getLocalClientRequestDispatcher() ; result = lcs.useLocalInvocation( null ) ; } } else { // For a non-Sun ORB result = delegate.is_local( stub ) ; } } catch (SystemException e) { throw javax.rmi.CORBA.Util.mapSystemException(e); } return result ; }
/** * Wraps an exception thrown by an implementation * method. It returns the corresponding client-side exception. * @param orig the exception to wrap. * @return the wrapped exception. */ public RemoteException wrapException(Throwable orig) { if (orig instanceof SystemException) { return mapSystemException((SystemException)orig); } if (orig instanceof Error) { return new ServerError("Error occurred in server thread",(Error)orig); } else if (orig instanceof RemoteException) { return new ServerException("RemoteException occurred in server thread", (Exception)orig); } else if (orig instanceof RuntimeException) { throw (RuntimeException) orig; } if (orig instanceof Exception) return new UnexpectedException( orig.toString(), (Exception)orig ); else return new UnexpectedException( orig.toString()); }
public boolean reportException(ContactInfo contactInfo, RuntimeException ex) { this.failureContactInfo = (CorbaContactInfo)contactInfo; this.failureException = ex; if (ex instanceof COMM_FAILURE) { SystemException se = (SystemException) ex; if (se.completed == CompletionStatus.COMPLETED_NO) { if (hasNext()) { return true; } if (contactInfoList.getEffectiveTargetIOR() != contactInfoList.getTargetIOR()) { // retry from root ior updateEffectiveTargetIOR(contactInfoList.getTargetIOR()); return true; } } } return false; }
/** * Handles exceptions for the starting and intermediate points for * server request interceptors. This is common code that has been * factored out into this utility method. * <p> * This method will NOT work for ending points. */ private void serverPIHandleExceptions( ServerRequestInfoImpl info ) { int endingPointCall = info.getEndingPointCall(); if(endingPointCall == ServerRequestInfoImpl.CALL_SEND_EXCEPTION) { // If a system exception was thrown, throw it to caller: throw (SystemException)info.getException(); } else if( (endingPointCall == ServerRequestInfoImpl.CALL_SEND_OTHER) && (info.getForwardRequestException() != null) ) { // If an interceptor throws a forward request, convert it // into a ForwardException for easier handling: IOR ior = info.getForwardRequestIOR(); throw new ForwardException( orb, ior ); } }
/** * Deletes the binding with the supplied name. It creates a * InternalBindingKey and uses it to remove the value associated * with the key. If nothing is found an exception is thrown, otherwise * the element is removed from the hash table. * @param n a NameComponent which is the name to unbind * @return the object reference bound to the name, or null if not found. * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA * system exceptions. */ public final org.omg.CORBA.Object Unbind(NameComponent n) throws org.omg.CORBA.SystemException { // Create a key and remove it from the hashtable InternalBindingKey key = new InternalBindingKey(n); InternalBindingValue value = (InternalBindingValue)this.theHashtable.remove(key); // Return what was found if (value == null) { if( updateLogger.isLoggable( Level.FINE ) ) { updateLogger.fine( LogKeywords.NAMING_UNBIND_FAILURE + " There was no binding with the name " + getName( n ) + " to Unbind " ); } return null; } else { if( updateLogger.isLoggable( Level.FINE ) ) { updateLogger.fine( LogKeywords.NAMING_UNBIND_SUCCESS + " NameComponent: " + getName( n ) ); } return value.theObjectRef; } }
/** * The {@code isLocal} method has the same semantics as the * ObjectImpl._is_local method, except that it can throw a RemoteException. * (no it doesn't but the spec says it should.) * * The {@code _is_local()} method is provided so that stubs may determine * if a particular object is implemented by a local servant and hence local * invocation APIs may be used. * * @param stub the stub to test. * * @return The {@code _is_local()} method returns true if * the servant incarnating the object is located in the same process as * the stub and they both share the same ORB instance. The {@code _is_local()} * method returns false otherwise. The default behavior of {@code _is_local()} is * to return false. * * @throws RemoteException The Java to IDL specification does to * specify the conditions that cause a RemoteException to be thrown. */ public boolean isLocal(javax.rmi.CORBA.Stub stub) throws RemoteException { boolean result = false ; try { org.omg.CORBA.portable.Delegate delegate = stub._get_delegate() ; if (delegate instanceof CorbaClientDelegate) { // For the Sun ORB CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ; ContactInfoList cil = cdel.getContactInfoList() ; if (cil instanceof CorbaContactInfoList) { CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; LocalClientRequestDispatcher lcs = ccil.getLocalClientRequestDispatcher() ; result = lcs.useLocalInvocation( null ) ; } } else { // For a non-Sun ORB result = delegate.is_local( stub ) ; } } catch (SystemException e) { throw javax.rmi.CORBA.Util.mapSystemException(e); } return result ; }
/** * Convert the given CORBA SystemException that happened during remote access * to Spring's RemoteAccessException if the method signature does not declare * RemoteException. Else, return the SystemException wrapped in a RemoteException. * @param method the invoked method * @param ex the RemoteException that happened * @return the exception to be thrown to the caller */ private Exception convertCorbaAccessException(SystemException ex, Method method) { if (ReflectionUtils.declaresException(method, RemoteException.class)) { // A traditional RMI service: wrap CORBA exceptions in standard RemoteExceptions. return new RemoteException("Failed to access CORBA service [" + getJndiName() + "]", ex); } else { if (isConnectFailure(ex)) { return new RemoteConnectFailureException("Could not connect to CORBA service [" + getJndiName() + "]", ex); } else { return new RemoteAccessException("Could not access CORBA service [" + getJndiName() + "]", ex); } } }
/** Write the service context to an output stream. This method * must be used for writing the service context to a request or reply * header. */ public void write(OutputStream s, GIOPVersion gv) throws SystemException { EncapsOutputStream os = sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)(s.orb()), gv); os.putEndian() ; writeData( os ) ; byte[] data = os.toByteArray() ; s.write_long(getId()); s.write_long(data.length); s.write_octet_array(data, 0, data.length); }
public void write( OutputStream os , GIOPVersion gv) throws SystemException { os.write_long( id ) ; os.write_long( data.length ) ; os.write_octet_array( data, 0, data.length ) ; }
/** * The CORBA::RepositoryId of the exception to be returned to the client. */ public String received_exception_id (){ checkAccess( MID_RECEIVED_EXCEPTION_ID ); if( cachedReceivedExceptionId == null ) { String result = null; if( exception == null ) { // Note: exception should never be null here since we will // throw a BAD_INV_ORDER if this is not called from // receive_exception. throw wrapper.exceptionWasNull() ; } else if( exception instanceof SystemException ) { String name = exception.getClass().getName(); result = ORBUtility.repositoryIdOf(name); } else if( exception instanceof ApplicationException ) { result = ((ApplicationException)exception).getId(); } // _REVISIT_ We need to be able to handle a UserException in the // DII case. How do we extract the ID from a UserException? cachedReceivedExceptionId = result; } return cachedReceivedExceptionId; }
public boolean reportException(ContactInfo contactInfo, RuntimeException ex) { this.failureContactInfo = (CorbaContactInfo)contactInfo; this.failureException = ex; if (ex instanceof org.omg.CORBA.COMM_FAILURE) { if (ex.getCause() instanceof GetEndPointInfoAgainException) { socketInfoCookie = ((GetEndPointInfoAgainException) ex.getCause()) .getEndPointInfo(); return true; } SystemException se = (SystemException) ex; if (se.completed == CompletionStatus.COMPLETED_NO) { if (contactInfoList.getEffectiveTargetIOR() != contactInfoList.getTargetIOR()) { // retry from root ior contactInfoList.setEffectiveTargetIOR( contactInfoList.getTargetIOR()); return true; } } } return false; }
/** Return the servant for this IOR, if it is local AND if the OA that * implements this objref supports direct access to servants outside of an * invocation. * XXX revisit: do we want this at all? If we do, it might move to the * ObjectKeyTemplate instead. */ public java.lang.Object getServant() { if (!isLocal()) return null ; RequestDispatcherRegistry scr = orb.getRequestDispatcherRegistry() ; ObjectAdapterFactory oaf = scr.getObjectAdapterFactory( oktemp.getSubcontractId() ) ; ObjectAdapterId oaid = oktemp.getObjectAdapterId() ; ObjectAdapter oa = null ; try { oa = oaf.find( oaid ) ; } catch (SystemException exc) { // Could not find the OA, so just return null. // This usually happens when POAs are being deleted, // and the POA always return null for getLocalServant anyway. wrapper.getLocalServantFailure( exc, oaid.toString() ) ; return null ; } byte[] boid = oid.getId() ; java.lang.Object servant = oa.getLocalServant( boid ) ; return servant ; }
public void overflow (ByteBufferWithInfo bbwi) { // Set the fragment's moreFragments field to true MessageBase.setFlag(bbwi.byteBuffer, Message.MORE_FRAGMENTS_BIT); try { sendFragment(false); } catch(SystemException se){ orb.getPIHandler().invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, se); throw se; } // Reuse the old buffer // REVISIT - need to account for case when needed > available // even after fragmenting. This is the large array case, so // the caller should retry when it runs out of space. bbwi.position(0); bbwi.buflen = bbwi.byteBuffer.limit(); bbwi.fragmented = true; // Now we must marshal in the fragment header/GIOP header // REVISIT - we can optimize this by not creating the fragment message // each time. FragmentMessage header = ((CDROutputObject)outputObject).getMessageHeader().createFragmentMessage(); header.write(((CDROutputObject)outputObject)); }
/** * Static method for writing a CORBA standard exception to an Any. * @param any The Any to write the SystemException into. */ public static void insertSystemException(SystemException ex, Any any) { OutputStream out = any.create_output_stream(); ORB orb = (ORB)(out.orb()); String name = ex.getClass().getName(); String repID = ORBUtility.repositoryIdOf(name); out.write_string(repID); out.write_long(ex.minor); out.write_long(ex.completed.value()); any.read_value(out.create_input_stream(), getSystemExceptionTypeCode(orb, repID, name)); }
public static SystemException extractSystemException(Any any) { InputStream in = any.create_input_stream(); ORB orb = (ORB)(in.orb()); if ( ! isSystemExceptionTypeCode(any.type(), orb)) { throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE); } return ORBUtility.readSystemException(in); }
/** * Static method for writing a CORBA standard exception to a stream. * @param strm The OutputStream to use for marshaling. */ public static void writeSystemException(SystemException ex, OutputStream strm) { String s; s = repositoryIdOf(ex.getClass().getName()); strm.write_string(s); strm.write_long(ex.minor); strm.write_long(ex.completed.value()); }
/** * Maps a SystemException to a RemoteException. * @param ex the SystemException to map. * @return the mapped exception. */ public static RemoteException mapSystemException(SystemException ex) { if (utilDelegate != null) { return utilDelegate.mapSystemException(ex); } return null; }
protected SystemException convertThrowableToSystemException( Throwable throwable, CompletionStatus completionStatus) { if (throwable instanceof SystemException) { return (SystemException)throwable; } if (throwable instanceof RequestCanceledException) { // Reporting an exception response causes the // poa current stack, the interceptor stacks, etc. // to be balanced. It also notifies interceptors // that the request was cancelled. return wrapper.requestCanceled( throwable ) ; } // NOTE: We do not trap ThreadDeath above Throwable. // There is no reason to stop the thread. It is // just a worker thread. The ORB never throws // ThreadDeath. Client code may (e.g., in ServantManagers, // interceptors, or servants) but that should not // effect the ORB threads. So it is just handled // generically. // // Last resort. // If user code throws a non-SystemException report it generically. // return wrapper.runtimeexception( CompletionStatus.COMPLETED_MAYBE, throwable ) ; }
public CorbaMessageMediator createSystemExceptionResponse( CorbaMessageMediator messageMediator, SystemException ex, ServiceContexts svc);
public void writeData( OutputStream os ) throws SystemException { os.write_value( (Serializable)unknown ) ; }
public void writeData( OutputStream os ) throws SystemException { csc.write( (MarshalOutputStream)os ) ; }