use of org.jboss.marshalling.Unmarshaller in project wildfly by wildfly.
the class EjbTimerXmlParser_1_0 method deserialize.
private Object deserialize(final String info) throws IOException, ClassNotFoundException {
byte[] data = Base64.getDecoder().decode(info.trim());
Unmarshaller unmarshaller = factory.createUnmarshaller(configuration);
unmarshaller.start(new ByteBufferInput(ByteBuffer.wrap(data)));
try {
return unmarshaller.readObject();
} finally {
unmarshaller.close();
}
}
use of org.jboss.marshalling.Unmarshaller in project wildfly by wildfly.
the class SimpleMarshalledValue method get.
/**
* {@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 = IndexExternalizer.VARIABLE.readData(data);
try (Unmarshaller unmarshaller = context.createUnmarshaller(version)) {
unmarshaller.start(data);
this.object = (T) unmarshaller.readObject();
unmarshaller.finish();
// Free up memory
this.bytes = null;
}
} finally {
setThreadContextClassLoader(loader);
}
}
}
return this.object;
}
use of org.jboss.marshalling.Unmarshaller in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method loadProgramAsync.
/**
* Deserializes {@link CpsThreadGroup} from {@link #getProgramDataFile()} if necessary.
*
* This moves us into the PREPARING state.
* @param programDataFile
*/
public void loadProgramAsync(File programDataFile) {
final SettableFuture<CpsThreadGroup> result = SettableFuture.create();
programPromise = result;
try {
scriptClass = parseScript().getClass();
final RiverReader r = new RiverReader(programDataFile, scriptClass.getClassLoader(), owner);
Futures.addCallback(r.restorePickles(pickleFutures = new ArrayList<>()), new FutureCallback<Unmarshaller>() {
public void onSuccess(Unmarshaller u) {
pickleFutures = null;
try {
CpsFlowExecution old = PROGRAM_STATE_SERIALIZATION.get();
PROGRAM_STATE_SERIALIZATION.set(CpsFlowExecution.this);
try {
CpsThreadGroup g = (CpsThreadGroup) u.readObject();
result.set(g);
try {
if (g.isPaused()) {
owner.getListener().getLogger().println("Still paused");
} else {
owner.getListener().getLogger().println("Ready to run at " + new Date());
// In case we last paused execution due to Jenkins.isQuietingDown, make sure we do something after we restart.
g.scheduleRun();
}
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, x);
}
} catch (Throwable t) {
onFailure(t);
} finally {
PROGRAM_STATE_SERIALIZATION.set(old);
}
} finally {
r.close();
}
}
public void onFailure(Throwable t) {
// Note: not calling result.setException(t) since loadProgramFailed in fact sets a result
try {
loadProgramFailed(t, result);
} finally {
r.close();
}
}
});
} catch (Exception | GroovyBugError e) {
loadProgramFailed(e, result);
}
}
use of org.jboss.marshalling.Unmarshaller in project netty by netty.
the class CompatibleMarshallingDecoder method decode.
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
if (discardingTooLongFrame) {
buffer.skipBytes(actualReadableBytes());
checkpoint();
return;
}
Unmarshaller unmarshaller = provider.getUnmarshaller(ctx);
ByteInput input = new ChannelBufferByteInput(buffer);
if (maxObjectSize != Integer.MAX_VALUE) {
input = new LimitingByteInput(input, maxObjectSize);
}
try {
unmarshaller.start(input);
Object obj = unmarshaller.readObject();
unmarshaller.finish();
out.add(obj);
} catch (LimitingByteInput.TooBigObjectException ignored) {
discardingTooLongFrame = true;
throw new TooLongFrameException();
} finally {
// Call close in a finally block as the ReplayingDecoder will throw an Error if not enough bytes are
// readable. This helps to be sure that we do not leak resource
unmarshaller.close();
}
}
use of org.jboss.marshalling.Unmarshaller in project netty by netty.
the class ThreadLocalUnmarshallerProvider method getUnmarshaller.
@Override
public Unmarshaller getUnmarshaller(ChannelHandlerContext ctx) throws Exception {
Unmarshaller unmarshaller = unmarshallers.get();
if (unmarshaller == null) {
unmarshaller = factory.createUnmarshaller(config);
unmarshallers.set(unmarshaller);
}
return unmarshaller;
}
Aggregations