Refine search
@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(); } } } }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } Unmarshaller unmarshaller = provider.getUnmarshaller(ctx); ByteInput input = new ChannelBufferByteInput(frame); try { unmarshaller.start(input); Object obj = unmarshaller.readObject(); unmarshaller.finish(); return obj; } 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(); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("Notification"); byte paramType = input.readByte(); if (paramType != INTEGER) { throw new IOException("Unexpected paramType"); } int listenerId = input.readInt(); paramType = input.readByte(); if (paramType != NOTIFICATION) { throw new IOException("Unexpected paramType"); } try { Unmarshaller unmarshaller = prepareForUnMarshalling(input); Notification notification = unmarshaller.readObject(Notification.class); paramType = unmarshaller.readByte(); if (paramType != OBJECT) { throw new IOException("Unexpected paramType"); } Object handBack = unmarshaller.readObject(); localNotificationManager.notify(listenerId, notification, handBack); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } }
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(); } }
protected ReceivedTransaction readTransaction(Unmarshaller unmarshaller) throws IOException { int type = unmarshaller.readByte(); if (type == 0) { return null; } else if (type == 1 || type == 2) { int formatId = unmarshaller.readInt(); int len = unmarshaller.readInt(); byte[] globalId = new byte[len]; unmarshaller.readFully(globalId); len = unmarshaller.readInt(); byte[] branchId = new byte[len]; unmarshaller.readFully(branchId); SimpleXid simpleXid = new SimpleXid(formatId, globalId, branchId); if (type == 2) { return new ReceivedTransaction(simpleXid, unmarshaller.readInt(), true); } return new ReceivedTransaction(simpleXid, 0, false); } else { throw EjbHttpClientMessages.MESSAGES.invalidTransactionType(type); } }
Unmarshaller unmarshaller = prepareForUnMarshalling(input, resolver); for (int i = 0; i < paramCount; i++) { byte param = unmarshaller.readByte(); switch (param) { case STRING: if (className == null) { className = unmarshaller.readUTF(); } else { throw new IOException("Unexpected paramter"); try { if (name == null) { name = unmarshaller.readObject(ObjectName.class); } else if (loader == null) { loader = unmarshaller.readObject(ObjectName.class); switchClassLoaderForLoader(loader, resolver); } else { case OBJECT_ARRAY: if (params == null) { int count = unmarshaller.readInt(); params = new Object[count]; for (int j = 0; j < count; j++) { try { params[j] = unmarshaller.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); case STRING_ARRAY:
log.trace("Invoke"); objectName = unmarshaller.readObject(ObjectName.class); switchClassLoaderForMBean(objectName, resolver); paramType = unmarshaller.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); operationName = unmarshaller.readUTF(); paramType = unmarshaller.readByte(); if (paramType != OBJECT_ARRAY) { throw new IOException("Unexpected paramType"); int count = unmarshaller.readInt(); params = new Object[count]; for (int i = 0; i < count; i++) { params[i] = unmarshaller.readObject(); paramType = unmarshaller.readByte(); if (paramType != STRING_ARRAY) { throw new IOException("Unexpected paramType"); count = unmarshaller.readInt(); signature = new String[count]; for (int i = 0; i < count; i++) { signature[i] = unmarshaller.readUTF();
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("QueryNames"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } ObjectName objectName; QueryExp query; try { Unmarshaller unmarshaller = prepareForUnMarshalling(input); objectName = unmarshaller.readObject(ObjectName.class); paramType = unmarshaller.readByte(); if (paramType != QUERY_EXP) { throw new IOException("Unexpected paramType"); } query = unmarshaller.readObject(QueryExp.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } Set<ObjectName> instances = server.getMBeanServerConnection().queryNames(objectName, query); writeResponse(instances, SET_OBJECT_NAME, QUERY_NAMES, correlationId); log.tracef("[%d] QueryNames - Success Response Sent", correlationId); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("GetMBeanInfo"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } Unmarshaller unmarshaller = prepareForUnMarshalling(input); ObjectName objectName; try { objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } try { MBeanInfo info = server.getMBeanServerConnection().getMBeanInfo(objectName); writeResponse(info, MBEAN_INFO, GET_MBEAN_INFO, correlationId); log.tracef("[%d] GetMBeanInfo - Success Response Sent", correlationId); } catch (IntrospectionException e) { writeResponse(e, MBEAN_INFO, correlationId); log.tracef("[%d] GetMBeanInfo - Failure Response Sent", correlationId); } catch (InstanceNotFoundException e) { writeResponse(e, MBEAN_INFO, correlationId); log.tracef("[%d] GetMBeanInfo - Failure Response Sent", correlationId); } catch (ReflectionException e) { writeResponse(e, MBEAN_INFO, correlationId); log.tracef("[%d] GetMBeanInfo - Failure Response Sent", correlationId); } }
log.trace("AddNotificationListener"); name = unmarshaller.readObject(ObjectName.class); paramType = unmarshaller.readByte(); if (paramType == INTEGER) { remoteNotification = true; listenerId = unmarshaller.readInt(); } else if (paramType == OBJECT_NAME) { remoteNotification = false; listener = unmarshaller.readObject(ObjectName.class); } else { throw new IOException("Unexpected paramType"); paramType = unmarshaller.readByte(); if (paramType != NOTIFICATION_FILTER) { throw new IOException("Unexpected paramType"); filter = unmarshaller.readObject(NotificationFilter.class); paramType = unmarshaller.readByte(); if (paramType != OBJECT) { throw new IOException("Unexpected paramType"); handback = unmarshaller.readObject(); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe);
log.trace("GetAttributes"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); paramType = unmarshaller.readByte(); if (paramType != STRING_ARRAY) { throw new IOException("Unexpected paramType"); int count = unmarshaller.readInt(); String[] attributes = new String[count]; for (int i = 0; i < count; i++) { attributes[i] = unmarshaller.readUTF(); AttributeList attributeValues = server.getMBeanServerConnection().getAttributes(objectName, attributes);
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("QueryMBeans"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } ObjectName objectName; QueryExp query; try { Unmarshaller unmarshaller = prepareForUnMarshalling(input); objectName = unmarshaller.readObject(ObjectName.class); paramType = unmarshaller.readByte(); if (paramType != QUERY_EXP) { throw new IOException("Unexpected paramType"); } query = unmarshaller.readObject(QueryExp.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } Set<ObjectInstance> instances = server.getMBeanServerConnection().queryMBeans(objectName, query); writeResponse(instances, SET_OBJECT_INSTANCE, QUERY_MBEANS, correlationId); log.tracef("[%d] QueryMBeans - Success Response Sent", correlationId); } }
log.trace("GetAttribute"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); paramType = unmarshaller.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); String attribute = unmarshaller.readUTF(); final Object attributeValue = server.getMBeanServerConnection().getAttribute(objectName, attribute);
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("IsRegistered"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } Unmarshaller unmarshaller = prepareForUnMarshalling(input); ObjectName objectName; try { objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } boolean registered = server.getMBeanServerConnection().isRegistered(objectName); writeResponse(registered, IS_REGISTERED, correlationId); log.tracef("[%d] IsRegistered - Success Response Sent", correlationId); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("IsInstanceOf"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } Unmarshaller unmarshaller = prepareForUnMarshalling(input); ObjectName objectName; try { objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } paramType = unmarshaller.readByte(); if (paramType != STRING) { throw new IOException("Unexpected paramType"); } String className = unmarshaller.readUTF(); try { boolean instanceOf = server.getMBeanServerConnection().isInstanceOf(objectName, className); writeResponse(instanceOf, INSTANCE_OF, correlationId); log.tracef("[%d] IsInstanceOf - Success Response Sent", correlationId); } catch (InstanceNotFoundException e) { writeResponse(e, INSTANCE_OF, correlationId); log.tracef("[%d] IsInstanceOf - Failure Response Sent", correlationId); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("GetObjectInstance"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } Unmarshaller unmarshaller = prepareForUnMarshalling(input); ObjectName objectName; try { objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } try { ObjectInstance objectInstance = server.getMBeanServerConnection().getObjectInstance(objectName); writeResponse(objectInstance, OBJECT_INSTANCE, GET_OBJECT_INSTANCE, correlationId); log.tracef("[%d] GetObjectInstance - Success Response Sent", correlationId); } catch (InstanceNotFoundException e) { writeResponse(e, GET_OBJECT_INSTANCE, correlationId); log.tracef("[%d] GetObjectInstance - Failure Response Sent", correlationId); } }
@Override public void handle(DataInput input, int correlationId) throws IOException { log.trace("UnregisterMBean"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); } Unmarshaller unmarshaller = prepareForUnMarshalling(input); ObjectName objectName; try { objectName = unmarshaller.readObject(ObjectName.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } try { server.getMBeanServerConnection().unregisterMBean(objectName); writeResponse(UNREGISTER_MBEAN, correlationId); log.tracef("[%d] UnregisterMBean - Success Response Sent", correlationId); } catch (MBeanRegistrationException e) { writeResponse(e, UNREGISTER_MBEAN, correlationId); log.tracef("[%d] UnregisterMBean - Failure Response Sent", correlationId); } catch (InstanceNotFoundException e) { writeResponse(e, UNREGISTER_MBEAN, correlationId); log.tracef("[%d] UnregisterMBean - Failure Response Sent", correlationId); } }
log.trace("SetAttributes"); byte paramType = input.readByte(); if (paramType != OBJECT_NAME) { throw new IOException("Unexpected paramType"); objectName = unmarshaller.readObject(ObjectName.class); switchClassLoaderForMBean(objectName, resolver); paramType = unmarshaller.readByte(); if (paramType != ATTRIBUTE_LIST) { throw new IOException("Unexpected paramType"); attributes = unmarshaller.readObject(AttributeList.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); AttributeList attributeValues = server.getMBeanServerConnection().setAttributes(objectName, attributes);
/** * {@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; }
@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; } }