use of org.jboss.marshalling.Unmarshaller in project wildfly by wildfly.
the class ChannelCommandDispatcherFactory method handle.
@Override
public Object handle(Message message) throws Exception {
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(message.getRawBuffer(), message.getOffset(), message.getLength()))) {
int version = IndexExternalizer.VARIABLE.readData(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();
Callable<Optional<Object>> task = new Callable<Optional<Object>>() {
@Override
public Optional<Object> call() throws Exception {
// Wrap in an Optional, since command execution might return null
return Optional.ofNullable(command.execute(context.orElse(null)));
}
};
return this.executor.execute(task).orElse(Optional.of(NoSuchService.INSTANCE)).orElse(null);
}
}
}
use of org.jboss.marshalling.Unmarshaller in project wildfly by wildfly.
the class DiskBasedModularPersistentSessionManager method loadSerializedSessions.
@Override
protected Map<String, SessionEntry> loadSerializedSessions(String deploymentName) throws IOException {
File file = new File(baseDir, deploymentName);
if (!file.exists()) {
return null;
}
FileInputStream in = new FileInputStream(file);
try {
Unmarshaller unMarshaller = createUnmarshaller();
try {
try {
unMarshaller.start(new InputStreamByteInput(in));
return (Map<String, SessionEntry>) unMarshaller.readObject();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} finally {
unMarshaller.finish();
}
} finally {
unMarshaller.close();
}
} finally {
IoUtils.safeClose(in);
}
}
use of org.jboss.marshalling.Unmarshaller in project wildfly by wildfly.
the class EjbCorbaServant method unmarshalIdentifier.
private Object unmarshalIdentifier() throws IOException, ClassNotFoundException {
final Object id;
try {
final byte[] idData = poaCurrent.get_object_id();
final Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
unmarshaller.start(new InputStreamByteInput(new ByteArrayInputStream(idData)));
id = unmarshaller.readObject();
unmarshaller.finish();
} catch (NoContext noContext) {
throw new RuntimeException(noContext);
}
return id;
}
Aggregations