/** {@inheritDoc} */ public void write(final byte[] buf) throws IOException { marshaller.write(buf, 0, buf.length); }
public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException { marshaller.write(0); final Module module = Module.forClass(clazz); if (module == null) { marshaller.writeObject(null); } else { final ModuleIdentifier identifier = module.getIdentifier(); marshaller.writeObject(identifier.getName()); marshaller.writeObject(identifier.getSlot()); } marshaller.writeObject(clazz.getName()); } }
public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException { marshaller.write(1); final Module module = Module.forClass(clazz); if (module == null) { marshaller.writeObject(null); } else { final ModuleIdentifier identifier = module.getIdentifier(); marshaller.writeObject(identifier.getName()); marshaller.writeObject(identifier.getSlot()); } final Class<?>[] interfaces = clazz.getInterfaces(); marshaller.writeInt(interfaces.length); for (Class<?> interfaze : interfaces) { marshaller.writeObject(interfaze.getName()); } } }
public static void sendException(HttpServerExchange exchange, int status, Throwable e) { try { exchange.setStatusCode(status); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/x-wf-jbmar-exception;version=1"); final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration(); marshallingConfiguration.setVersion(2); final Marshaller marshaller = MARSHALLER_FACTORY.createMarshaller(marshallingConfiguration); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final ByteOutput byteOutput = new NoFlushByteOutput(Marshalling.createByteOutput(outputStream)); // start the marshaller marshaller.start(byteOutput); marshaller.writeObject(e); marshaller.write(0); marshaller.finish(); marshaller.flush(); exchange.getResponseSender().send(ByteBuffer.wrap(outputStream.toByteArray())); } catch (IOException e1) { HttpRemoteTransactionMessages.MESSAGES.debugf(e, "Failed to write exception"); } } }
/** {@inheritDoc} */ public void write(final int b) throws IOException { marshaller.write(b); }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { try { String timeoutString = exchange.getRequestHeaders().getFirst(TransactionConstants.TIMEOUT); if (timeoutString == null) { exchange.setStatusCode(StatusCodes.BAD_REQUEST); HttpRemoteTransactionMessages.MESSAGES.debugf("Exchange %s is missing %s header", exchange, TransactionConstants.TIMEOUT); return; } final Integer timeout = Integer.parseInt(timeoutString); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, TransactionConstants.NEW_TRANSACTION.toString()); final LocalTransaction transaction = transactionContext.beginTransaction(timeout); final Xid xid = xidResolver.apply(transaction); final ByteArrayOutputStream out = new ByteArrayOutputStream(); Marshaller marshaller = MARSHALLER_FACTORY.createMarshaller(createMarshallingConf()); marshaller.start(new NoFlushByteOutput(Marshalling.createByteOutput(out))); marshaller.writeInt(xid.getFormatId()); marshaller.writeInt(xid.getGlobalTransactionId().length); marshaller.write(xid.getGlobalTransactionId()); marshaller.writeInt(xid.getBranchQualifier().length); marshaller.write(xid.getBranchQualifier()); marshaller.finish(); exchange.getResponseSender().send(ByteBuffer.wrap(out.toByteArray())); } catch (Exception e) { sendException(exchange, StatusCodes.INTERNAL_SERVER_ERROR, e); } } }
public static void sendException(HttpServerExchange exchange, int status, Throwable e) throws IOException { exchange.setStatusCode(status); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/x-wf-jbmar-exception;version=1"); final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration(); marshallingConfiguration.setVersion(2); final Marshaller marshaller = MARSHALLER_FACTORY.createMarshaller(marshallingConfiguration); OutputStream outputStream = exchange.getOutputStream(); final ByteOutput byteOutput = new NoFlushByteOutput(Marshalling.createByteOutput(outputStream)); // start the marshaller marshaller.start(byteOutput); marshaller.writeObject(e); marshaller.write(0); marshaller.finish(); marshaller.flush(); } }
/** {@inheritDoc} */ public void write(final byte[] b) throws IOException { marshaller.write(b); }
public static void sendException(HttpServerExchange exchange, int status, Throwable e) { try { exchange.setStatusCode(status); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/x-wf-jbmar-exception;version=1"); final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration(); marshallingConfiguration.setVersion(2); final Marshaller marshaller = RIVER_MARSHALLER_FACTORY.createMarshaller(marshallingConfiguration); OutputStream outputStream = exchange.getOutputStream(); final ByteOutput byteOutput = Marshalling.createByteOutput(outputStream); // start the marshaller marshaller.start(byteOutput); marshaller.writeObject(e); marshaller.write(0); marshaller.finish(); marshaller.flush(); exchange.endExchange(); } catch (Exception ex) { HttpClientMessages.MESSAGES.failedToWriteException(ex); exchange.endExchange(); } } }
/** {@inheritDoc} */ public void write(final byte[] b, final int off, final int len) throws IOException { marshaller.write(b, off, len); }
public void writeObject(final Marshaller marshaller, final Object object) throws IOException { marshaller.write(bytes); } }
/** {@inheritDoc} */ public void write(final byte[] buf, final int off, final int len) throws IOException { marshaller.write(buf, off, len); }
/** {@inheritDoc} */ public void write(final int val) throws IOException { output.write(val); }
/** {@inheritDoc} */ public void write(final byte[] buf) throws IOException { output.write(buf, 0, buf.length); }
/** {@inheritDoc} */ public void write(final int val) throws IOException { marshaller.write(val); }
/** {@inheritDoc} */ public void write(final byte[] buf, final int off, final int len) throws IOException { output.write(buf, off, len); }
public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException { marshaller.write(bytes); } }
public void writeObject(final Marshaller marshaller, final Object object) throws IOException { marshaller.write(bytes); }