public void writeShort(final int v) throws IOException { delegate.writeShort(v); }
public static void writeId(final MessageOutputStream stream, final int version, final int id) throws IOException { if (version == 1) { stream.writeInt(id); } else { stream.writeShort(id); } }
void writeParamError(final int invId) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(M_RESP_PARAM_ERROR); } catch (IOException e) { log.outboundException(e); } } }
void writeSimpleResponse(final int msgId, final int invId) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); } catch (IOException e) { log.outboundException(e); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e, int errorCode) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); dos.writeInt(errorCode); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
@Override public void writeProceedAsync() { if(version >= 3) { //not used in newer protocols return; } try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.PROCEED_ASYNC_RESPONSE); os.writeShort(invId); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB async response write failed", e); } }
private void writeExceptionResponse(final int msgId, final int invId, final int exceptionKind, final Exception e) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeInt8(outputStream, exceptionKind); final RemoteExceptionCause remoteExceptionCause = RemoteExceptionCause.of(e); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); remoteExceptionCause.writeToStream(dos); dos.flush(); writePackedUnsignedInt31(outputStream, os.size()); os.writeTo(outputStream); } catch (IOException ioe) { log.outboundException(ioe); } }
public void writeCancelResponse() { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CANCEL_RESPONSE); os.writeShort(invId); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
private void writeTxnResponse(final int invId) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(false); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
void writeSimpleResponse(final int msgId, final int invId, final int param1) { try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(msgId); writeParam(param1, outputStream); } catch (IOException e) { log.outboundException(e); } }
void handleCapabilityMessage(final MessageInputStream message, final int invId) throws IOException { while (message.read() != -1) { // ignore parameters readIntParam(message, StreamUtils.readPackedUnsignedInt32(message)); } // acknowledge no capabilities try (final MessageOutputStream outputStream = messageTracker.openMessageUninterruptibly()) { outputStream.writeShort(invId); outputStream.writeByte(M_RESP_CAPABILITY); } return; }
private void writeTxnResponse(final int invId, final int flag) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.TXN_RESPONSE); os.writeShort(invId); os.writeBoolean(true); PackedInteger.writePackedInteger(os, flag); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB transaction response write failed", e); } }
public void writeNoSuchMethod() { final String message = Logs.REMOTING.remoteMessageNoSuchMethod(methodLocator, identifier); try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.NO_SUCH_METHOD); os.writeShort(invId); os.writeUTF(message); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
public void writeSessionNotActive() { final String message = Logs.REMOTING.remoteMessageSessionNotActive(methodLocator, identifier); try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.NO_SUCH_METHOD); os.writeShort(invId); os.writeUTF(message); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
void writeCancellation() { if (version >= 3) try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.CANCEL_RESPONSE); os.writeShort(invId); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } else { writeFailure(Logs.REMOTING.requestCancelled()); } } }
public void writeNoSuchEJB() { final String message = Logs.REMOTING.remoteMessageNoSuchEJB(getEJBIdentifier()); try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.NO_SUCH_EJB); os.writeShort(invId); os.writeUTF(message); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
public void writeNotStateful() { final String message = Logs.REMOTING.remoteMessageEJBNotStateful(getEJBIdentifier()); try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.EJB_NOT_STATEFUL); os.writeShort(invId); os.writeUTF(message); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }
private void writeFailedResponse(final int invId, final Throwable e) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.APPLICATION_EXCEPTION); os.writeShort(invId); final Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(os))); marshaller.writeObject(new RequestSendFailedException(e.getMessage() + "@" + channel.getConnection().getPeerURI(), e)); marshaller.writeByte(0); marshaller.finish(); } catch (IOException e2) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e2); } }
public <T> StatefulEJBLocator<T> openSession(final StatelessEJBLocator<T> statelessLocator, final ConnectionPeerIdentity identity, EJBSessionCreationInvocationContext clientInvocationContext) throws Exception { SessionOpenInvocation<T> invocation = invocationTracker.addInvocation(id -> new SessionOpenInvocation<>(id, statelessLocator, clientInvocationContext)); try (MessageOutputStream out = invocationTracker.allocateMessage()) { out.write(Protocol.OPEN_SESSION_REQUEST); out.writeShort(invocation.getIndex()); writeRawIdentifier(statelessLocator, out); if (version >= 3) { out.writeInt(identity.getId()); invocation.setOutflowHandle(writeTransaction(clientInvocationContext.getTransaction(), out)); } } catch (IOException e) { CreateException createException = new CreateException(e.getMessage()); createException.initCause(e); throw createException; } // await the response return invocation.getResult(); }
protected void writeFailure(Exception reason) { try (MessageOutputStream os = messageTracker.openMessageUninterruptibly()) { os.writeByte(Protocol.APPLICATION_EXCEPTION); os.writeShort(invId); if (version >= 3) os.writeByte(getEnlistmentStatus()); final Marshaller marshaller = marshallerFactory.createMarshaller(configuration); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(os))); marshaller.writeObject(reason); marshaller.writeByte(0); marshaller.finish(); } catch (IOException e) { // nothing to do at this point; the client doesn't want the response Logs.REMOTING.trace("EJB response write failed", e); } finally { invocations.removeKey(invId); } }