本文整理了Java中org.jboss.marshalling.Marshalling.createByteInput()
方法的一些代码示例,展示了Marshalling.createByteInput()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marshalling.createByteInput()
方法的具体详情如下:
包路径:org.jboss.marshalling.Marshalling
类名称:Marshalling
方法名:createByteInput
[英]Create a ByteInput wrapper for an InputStream.
[中]为输入流创建字节输入包装器。
代码示例来源:origin: wildfly/wildfly
/**
* Construct a new instance which delegates to the given unmarshaller, reading from the given input. The unmarshaller
* will read from the input stream until it is closed.
*
* @param unmarshaller the delegate unmarshaller
* @param stream the input stream to read from
*
* @throws java.io.IOException if an I/O error occurs
* @throws SecurityException if the caller does not have permission to construct an instance of this class
*/
public UnmarshallingObjectInputStream(final Unmarshaller unmarshaller, final InputStream stream) throws IOException, SecurityException {
this(unmarshaller, Marshalling.createByteInput(stream));
}
代码示例来源:origin: wildfly/wildfly
/**
* Construct a new instance.
*/
public BytePipe() {
final PipedOutputStream output = new PipedOutputStream();
final PipedInputStream input;
try {
input = new PipedInputStream(output);
} catch (IOException e) {
throw new IllegalStateException(e);
}
this.input = Marshalling.createByteInput(input);
this.output = Marshalling.createByteOutput(output);
}
代码示例来源:origin: wildfly/wildfly
public static Unmarshaller createUnmarshaller(MessageInputStream is, MarshallingConfiguration configuration) throws IOException {
final Unmarshaller unmarshaller = riverMarshallerFactory.createUnmarshaller(configuration);
unmarshaller.start(Marshalling.createByteInput(is));
return unmarshaller;
}
代码示例来源:origin: wildfly/wildfly
@Override
public Object objectFromStream(DataInput stream) throws Exception {
int size = IndexSerializer.VARIABLE.readInt(stream);
byte[] buffer = new byte[size];
stream.readFully(buffer);
if (this.factory.isUnknownForkResponse(ByteBuffer.wrap(buffer))) return NoSuchService.INSTANCE;
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(buffer))) {
int version = this.versionSerializer.readInt(input);
try (Unmarshaller unmarshaller = this.context.createUnmarshaller(version)) {
unmarshaller.start(Marshalling.createByteInput(input));
return unmarshaller.readObject();
}
}
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Creates and returns a {@link org.jboss.marshalling.Unmarshaller} which is ready to be used for unmarshalling. The
* {@link org.jboss.marshalling.Unmarshaller#start(org.jboss.marshalling.ByteInput)} will be invoked by this method, to use
* the passed {@link java.io.DataInput dataInput}, before returning the unmarshaller.
*
* @param dataInput The data input from which to unmarshall
* @param classResolver The class resolver to use for unmarshalling
* @return
* @throws IOException
*/
protected Unmarshaller prepareForUnMarshalling(final DataInput dataInput, final ClassResolver classResolver)
throws IOException {
final Unmarshaller unmarshaller = this.getUnMarshaller(marshallerFactory, classResolver);
final InputStream is = new InputStream() {
@Override
public int read() throws IOException {
try {
final int b = dataInput.readByte();
return b & 0xff;
} catch (EOFException eof) {
return -1;
}
}
};
final ByteInput byteInput = Marshalling.createByteInput(is);
// start the unmarshaller
unmarshaller.start(byteInput);
return unmarshaller;
}
代码示例来源:origin: wildfly/wildfly
/**
* Creates and returns a {@link org.jboss.marshalling.Unmarshaller} which is ready to be used for unmarshalling. The
* {@link org.jboss.marshalling.Unmarshaller#start(org.jboss.marshalling.ByteInput)} will be invoked by this method, to use
* the passed {@link java.io.DataInput dataInput}, before returning the unmarshaller.
*
* @param dataInput The data input from which to unmarshall
* @param classResolver The class resolver to use for unmarshalling
* @return
* @throws IOException
*/
protected Unmarshaller prepareForUnMarshalling(final DataInput dataInput, final ClassResolver classResolver)
throws IOException {
final Unmarshaller unmarshaller = this.getUnMarshaller(marshallerFactory, classResolver);
final InputStream is = new InputStream() {
@Override
public int read() throws IOException {
try {
final int b = dataInput.readByte();
return b & 0xff;
} catch (EOFException eof) {
return -1;
}
}
};
final ByteInput byteInput = Marshalling.createByteInput(is);
// start the unmarshaller
unmarshaller.start(byteInput);
return unmarshaller;
}
代码示例来源:origin: wildfly/wildfly
private Callable<Object> read(Message message) throws Exception {
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(message.getRawBuffer(), message.getOffset(), message.getLength()))) {
int version = IndexSerializer.VARIABLE.readInt(input);
try (Unmarshaller unmarshaller = this.marshallingContext.createUnmarshaller(version)) {
unmarshaller.start(Marshalling.createByteInput(input));
Object clientId = unmarshaller.readObject();
Optional<Object> context = this.contexts.get(clientId);
if (context == null) return () -> NoSuchService.INSTANCE;
@SuppressWarnings("unchecked")
Command<Object, Object> command = (Command<Object, Object>) unmarshaller.readObject();
// Wrap execution result in an Optional, since command execution might return null
ExceptionSupplier<Optional<Object>, Exception> task = () -> Optional.ofNullable(command.execute(context.orElse(null)));
return () -> this.executor.execute(task).orElse(Optional.of(NoSuchService.INSTANCE)).orElse(null);
}
}
}
代码示例来源:origin: wildfly/wildfly
/**
* {@inheritDoc}
* @see org.wildfly.clustering.marshalling.spi.MarshalledValue#get(java.lang.Object)
*/
@SuppressWarnings("unchecked")
@Override
public synchronized T get(MarshallingContext context) throws IOException, ClassNotFoundException {
if (this.object == null) {
this.context = context;
if (this.bytes != null) {
ByteArrayInputStream input = new ByteArrayInputStream(this.bytes);
ClassLoader loader = setThreadContextClassLoader(this.context.getClassLoader());
try (SimpleDataInput data = new SimpleDataInput(Marshalling.createByteInput(input))) {
int version = IndexSerializer.VARIABLE.readInt(data);
try (Unmarshaller unmarshaller = context.createUnmarshaller(version)) {
unmarshaller.start(data);
this.object = (T) unmarshaller.readObject();
unmarshaller.finish();
this.bytes = null; // Free up memory
}
} finally {
setThreadContextClassLoader(loader);
}
}
}
return this.object;
}
代码示例来源:origin: wildfly/wildfly
if (version >= 3) {
unmarshaller = marshallerFactory.createUnmarshaller(configuration);
unmarshaller.start(Marshalling.createByteInput(input));
identifier = unmarshaller.readObject(EJBIdentifier.class);
methodLocator = unmarshaller.readObject(EJBMethodLocator.class);
unmarshaller.start(Marshalling.createByteInput(data));
String appName = unmarshaller.readObject(String.class);
String moduleName = unmarshaller.readObject(String.class);
代码示例来源:origin: wildfly/wildfly
static XAException readAppException(final EJBClientChannel channel, final BlockingInvocation.Response response) throws XAException {
Exception e;
try (final Unmarshaller unmarshaller = channel.createUnmarshaller()) {
try (MessageInputStream inputStream = response.getInputStream()) {
unmarshaller.start(Marshalling.createByteInput(inputStream));
e = unmarshaller.readObject(Exception.class);
unmarshaller.finish();
// The version is probably < 3 else we would not be here
// drain off attachments so the server doesn't complain
while (inputStream.read() != -1) {
inputStream.skip(Long.MAX_VALUE);
}
}
} catch (IOException | ClassNotFoundException e1) {
throw new XAException(XAException.XAER_RMERR);
}
if (e == null) {
throw new XAException(XAException.XAER_RMFAIL);
}
try {
throw e;
} catch (RuntimeException | XAException e1) {
throw e1;
} catch (Exception e1) {
final XAException xae = new XAException(XAException.XAER_RMERR);
xae.initCause(e1);
return xae;
}
}
代码示例来源:origin: wildfly/wildfly
static SystemException readAppException(final EJBClientChannel channel, final BlockingInvocation.Response response) throws SystemException {
Exception e;
try (final Unmarshaller unmarshaller = channel.createUnmarshaller()) {
try (MessageInputStream inputStream = response.getInputStream()) {
unmarshaller.start(Marshalling.createByteInput(inputStream));
e = unmarshaller.readObject(Exception.class);
unmarshaller.finish();
// The version is probably < 3 else we would not be here
// drain off attachments so the server doesn't complain
while (inputStream.read() != -1) {
inputStream.skip(Long.MAX_VALUE);
}
}
} catch (IOException | ClassNotFoundException e1) {
throw new SystemException();
}
if (e == null) {
throw new SystemException();
}
try {
throw e;
} catch (RuntimeException | SystemException e1) {
throw e1;
} catch (Exception e1) {
final SystemException e2 = new SystemException();
e2.initCause(e1);
return e2;
}
}
代码示例来源:origin: wildfly/wildfly
unmarshaller.start(Marshalling.createByteInput(inputStream));
for (int i = 0; i < count; i ++) {
xids[i ++] = unmarshaller.readObject(XidTransactionID.class).getXid();
代码示例来源:origin: org.wildfly/wildfly-naming-client
public static Unmarshaller createUnmarshaller(MessageInputStream is, MarshallingConfiguration configuration) throws IOException {
final Unmarshaller unmarshaller = riverMarshallerFactory.createUnmarshaller(configuration);
unmarshaller.start(Marshalling.createByteInput(is));
return unmarshaller;
}
代码示例来源:origin: org.jboss.as/jboss-as-domain-client
@Override
protected final DomainUpdateApplierResponse receiveResponse(final InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, DomainClientProtocol.RETURN_APPLY_UPDATE);
DomainUpdateApplierResponse rsp = unmarshal(unmarshaller, DomainUpdateApplierResponse.class);
unmarshaller.finish();
return rsp;
}
}
代码示例来源:origin: org.jboss.as/jboss-as-domain-client
@Override
protected final DomainModel receiveResponse(final InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, DomainClientProtocol.RETURN_DOMAIN_MODEL);
final DomainModel domainModel = unmarshal(unmarshaller, DomainModel.class);
unmarshaller.finish();
return domainModel;
}
}
代码示例来源:origin: org.jboss.as/jboss-as-domain-client
@Override
protected final ServerModel receiveResponse(final InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, DomainClientProtocol.RETURN_SERVER_MODEL);
final ServerModel serverModel = unmarshal(unmarshaller, ServerModel.class);
unmarshaller.finish();
return serverModel;
}
}
代码示例来源:origin: org.jboss.as/jboss-as-standalone-client
/** {@inheritDoc} */
@Override
protected ServerModel receiveResponse(InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, StandaloneClientProtocol.PARAM_SERVER_MODEL);
final ServerModel serverModel = unmarshal(unmarshaller, ServerModel.class);
unmarshaller.finish();
return serverModel;
}
}
代码示例来源:origin: org.infinispan/infinispan-commons
@Override
final public ObjectInput startObjectInput(final InputStream is, final boolean isReentrant) throws IOException {
PerThreadInstanceHolder instanceHolder = getPerThreadInstanceHolder();
Unmarshaller unmarshaller = instanceHolder.getUnmarshaller();
if (trace)
log.tracef("Start unmarshaller after retrieving marshaller from %s",
isReentrant ? "factory" : "thread local");
unmarshaller.start(Marshalling.createByteInput(is));
return unmarshaller;
}
代码示例来源:origin: org.jboss.as/jboss-as-domain-client
@Override
protected final ServerStatus receiveResponse(final InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, DomainClientProtocol.RETURN_SERVER_STATUS);
final ServerStatus serverStatus = unmarshal(unmarshaller, ServerStatus.class);
unmarshaller.finish();
return serverStatus;
}
}
代码示例来源:origin: org.jboss.as/jboss-as-standalone-client
/** {@inheritDoc} */
@Override
protected final ServerDeploymentPlanResult receiveResponse(final InputStream input) throws IOException {
final Unmarshaller unmarshaller = getUnmarshaller();
unmarshaller.start(createByteInput(input));
expectHeader(unmarshaller, StandaloneClientProtocol.PARAM_DEPLOYMENT_PLAN_RESULT);
final ServerDeploymentPlanResult result = unmarshal(unmarshaller, ServerDeploymentPlanResult.class);
unmarshaller.finish();
return result;
}
}
内容来源于网络,如有侵权,请联系作者删除!