public static void startServer(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) throws IOException { ServerProxy proxy = new ServerProxy(channel, server, executor, serverMessageInterceptor); proxy.start(); }
ServerProxy(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) { super(channel); this.channel = channel; this.server = server; this.handlerRegistry = createHandlerRegistry(); this.remoteNotificationManager = new RemoteNotificationManager(); this.executor = executor; this.serverMessageInterceptor = serverMessageInterceptor; }
@Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(FAILURE); output.writeByte(EXCEPTION); Marshaller marshaller = prepareForMarshalling(output); marshaller.writeObject(e); marshaller.finish(); } });
@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); } }
private void writeResponse(final byte inResponseTo, final int correlationId) throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(SUCCESS); } }); }
void start() throws IOException { // Create a connection ID connectionId = UUID.randomUUID(); log.debugf("Created connectionID %s", connectionId.toString()); // Send ID to client sendConnectionId(); // Inform server the connection is now open server.connectionOpened(this); channel.receiveMessage(new MessageReciever()); }
@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); } }
private void writeResponse(final String response, final byte inResponseTo, final int correlationId) throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(SUCCESS); output.writeByte(STRING); output.writeUTF(response); } }); }
void start() throws IOException { // Create a connection ID connectionId = UUID.randomUUID(); log.debugf("Created connectionID %s", connectionId.toString()); // Send ID to client sendConnectionId(); // Inform server the connection is now open server.connectionOpened(this); channel.receiveMessage(new MessageReciever()); }
@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); } }
private void writeResponse(final Integer response, final byte inResponseTo, final int correlationId) throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(SUCCESS); output.writeByte(INTEGER); output.writeInt(response); } }); }
public static void startServer(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) throws IOException { ServerProxy proxy = new ServerProxy(channel, server, executor, serverMessageInterceptor); proxy.start(); }
@Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(SUCCESS); output.writeByte(type); Marshaller marshaller = prepareForMarshalling(output); marshaller.writeObject(response); marshaller.finish(); } });
ServerProxy(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) { super(channel); this.channel = channel; this.server = server; this.handlerRegistry = createHandlerRegistry(); this.remoteNotificationManager = new RemoteNotificationManager(); this.executor = executor; this.serverMessageInterceptor = serverMessageInterceptor; }
void start() throws IOException { // Create a connection ID connectionId = UUID.randomUUID(); log.debugf("Created connectionID %s", connectionId.toString()); // Send ID to client sendConnectionId(); // Inform server the connection is now open server.connectionOpened(this); channel.receiveMessage(new MessageReciever()); }
@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); } }
private void writeResponse(final boolean response, final byte inResponseTo, final int correlationId) throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(inResponseTo ^ RESPONSE_MASK); output.writeInt(correlationId); output.writeByte(SUCCESS); output.writeByte(BOOLEAN); output.writeBoolean(response); } }); }
public static void startServer(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) throws IOException { ServerProxy proxy = new ServerProxy(channel, server, executor, serverMessageInterceptor); proxy.start(); }
@Override public void write(DataOutput output) throws IOException { output.writeByte(SEND_NOTIFICATION); output.writeInt(0x00); output.writeByte(INTEGER); output.writeInt(listenerId); output.writeByte(NOTIFICATION); Marshaller marshaller = prepareForMarshalling(output); marshaller.writeObject(notification); marshaller.writeByte(OBJECT); marshaller.writeObject(handback); marshaller.finish(); } });
ServerProxy(final Channel channel, final WrappedMBeanServerConnection server, final Executor executor, final ServerMessageInterceptor serverMessageInterceptor) { super(channel); this.channel = channel; this.server = server; this.handlerRegistry = createHandlerRegistry(); this.remoteNotificationManager = new RemoteNotificationManager(); this.executor = executor; this.serverMessageInterceptor = serverMessageInterceptor; }