src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte STRING = 0x08;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte QUERY_NAMES = 0x05;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte INVOKE = 0x0C;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte QUERY_MBEANS = 0x04;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_ATTRIBUTE = 0x08;
src/main/java/org/jboss/remotingjmx/Constants.java
public static final String TIMEOUT_KEY = "org.jboss.remoting-jmx.timeout";
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte OBJECT_NAME = 0x06;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte QUERY_EXP = 0x07;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SUCCESS = 0x00;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte RESPONSE_MASK = (byte) 0x80;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_OBJECT_INSTANCE = 0x03;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte INSTANCE_OF = 0x10;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte CREATE_MBEAN = 0x01;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte NOTIFICATION = 0x11;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte IS_REGISTERED = 0x06;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte ATTRIBUTE_LIST = 0x02;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_MBEAN_COUNT = 0x07;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte UNREGISTER_MBEAN = 0x02;
src/main/java/org/jboss/remotingjmx/RemotingMBeanServerConnection.java
public interface RemotingMBeanServerConnection extends MBeanServerConnection {

    Connection getConnection();

}
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte BOOLEAN = 0x0A;
src/main/java/org/jboss/remotingjmx/VersionedConnection.java
public interface VersionedConnection extends Closeable {

    String getConnectionId();

    MBeanServerConnection getMBeanServerConnection(Subject subject);

    void close();

}
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte STRING_ARRAY = 0x09;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SET_ATTRIBUTES = 0x0B;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte INTEGER = 0x0B;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte NOTIFICATION_FILTER = 0x10;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte OBJECT = 0x04;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte EXCEPTION = 0x03;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_DOMAINS = 0x0E;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte REMOVE_NOTIFICATION_LISTENER = 0x12;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SET_OBJECT_INSTANCE = 0x0D;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_DEFAULT_DOMAIN = 0x0D;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte OBJECT_ARRAY = 0x05;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_MBEAN_INFO = 0x0F;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte ATTRIBUTE = 0x01;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SET_ATTRIBUTE = 0x0A;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SEND_NOTIFICATION = 0x13;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte OBJECT_INSTANCE = 0x0C;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte GET_ATTRIBUTES = 0x09;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte MBEAN_INFO = 0x0E;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte SET_OBJECT_NAME = 0x0F;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte FAILURE = 0x01;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte INTEGER_ARRAY = 0x12;
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte VOID = 0x00; // Not actually passed as a parameter but used internally to indicate no parameter expected.
src/main/java/org/jboss/remotingjmx/protocol/v1/Constants.java
static final byte ADD_NOTIFICATION_LISTENER = 0x11;


Question: import static org.jboss.remotingjmx.Constants.TIMEOUT_KEY;
import static org.jboss.remotingjmx.protocol.v1.Constants.ADD_NOTIFICATION_LISTENER;
import static org.jboss.remotingjmx.protocol.v1.Constants.ATTRIBUTE;
import static org.jboss.remotingjmx.protocol.v1.Constants.ATTRIBUTE_LIST;
import static org.jboss.remotingjmx.protocol.v1.Constants.BOOLEAN;
import static org.jboss.remotingjmx.protocol.v1.Constants.CREATE_MBEAN;
import static org.jboss.remotingjmx.protocol.v1.Constants.EXCEPTION;
import static org.jboss.remotingjmx.protocol.v1.Constants.FAILURE;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_ATTRIBUTE;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_ATTRIBUTES;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_DEFAULT_DOMAIN;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_DOMAINS;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_MBEAN_COUNT;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_MBEAN_INFO;
import static org.jboss.remotingjmx.protocol.v1.Constants.GET_OBJECT_INSTANCE;
import static org.jboss.remotingjmx.protocol.v1.Constants.INSTANCE_OF;
import static org.jboss.remotingjmx.protocol.v1.Constants.INTEGER;
import static org.jboss.remotingjmx.protocol.v1.Constants.INTEGER_ARRAY;
import static org.jboss.remotingjmx.protocol.v1.Constants.INVOKE;
import static org.jboss.remotingjmx.protocol.v1.Constants.IS_REGISTERED;
import static org.jboss.remotingjmx.protocol.v1.Constants.MBEAN_INFO;
import static org.jboss.remotingjmx.protocol.v1.Constants.NOTIFICATION;
import static org.jboss.remotingjmx.protocol.v1.Constants.NOTIFICATION_FILTER;
import static org.jboss.remotingjmx.protocol.v1.Constants.OBJECT;
import static org.jboss.remotingjmx.protocol.v1.Constants.OBJECT_ARRAY;
import static org.jboss.remotingjmx.protocol.v1.Constants.OBJECT_INSTANCE;
import static org.jboss.remotingjmx.protocol.v1.Constants.OBJECT_NAME;
import static org.jboss.remotingjmx.protocol.v1.Constants.QUERY_EXP;
import static org.jboss.remotingjmx.protocol.v1.Constants.QUERY_MBEANS;
import static org.jboss.remotingjmx.protocol.v1.Constants.QUERY_NAMES;
import static org.jboss.remotingjmx.protocol.v1.Constants.REMOVE_NOTIFICATION_LISTENER;
import static org.jboss.remotingjmx.protocol.v1.Constants.RESPONSE_MASK;
import static org.jboss.remotingjmx.protocol.v1.Constants.SEND_NOTIFICATION;
import static org.jboss.remotingjmx.protocol.v1.Constants.SET_ATTRIBUTE;
import static org.jboss.remotingjmx.protocol.v1.Constants.SET_ATTRIBUTES;
import static org.jboss.remotingjmx.protocol.v1.Constants.SET_OBJECT_INSTANCE;
import static org.jboss.remotingjmx.protocol.v1.Constants.SET_OBJECT_NAME;
import static org.jboss.remotingjmx.protocol.v1.Constants.STRING;
import static org.jboss.remotingjmx.protocol.v1.Constants.STRING_ARRAY;
import static org.jboss.remotingjmx.protocol.v1.Constants.SUCCESS;
import static org.jboss.remotingjmx.protocol.v1.Constants.UNREGISTER_MBEAN;
import static org.jboss.remotingjmx.protocol.v1.Constants.VOID;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException;
import javax.management.JMRuntimeException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServerConnection;
import javax.management.NotCompliantMBeanException;
import javax.management.Notification;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.QueryExp;
import javax.management.ReflectionException;
import javax.security.auth.Subject;
import org.jboss.logging.Logger;
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.Unmarshaller;
import org.jboss.remoting3.Channel;
import org.jboss.remoting3.Connection;
import org.jboss.remoting3.MessageInputStream;
import org.jboss.remotingjmx.RemotingMBeanServerConnection;
import org.jboss.remotingjmx.VersionedConnection;
import org.xnio.IoFuture;
import org.xnio.IoUtils;
/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2012, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.remotingjmx.protocol.v1;






/**
 * The VersionOne client connection.
 *
 * @author <a href="mailto:darran.lofthouse@jboss.com">Darran Lofthouse</a>
 */
class ClientConnection extends Common implements VersionedConnection {

    private static final String REMOTING_JMX = "remoting-jmx";
    private static final String CLIENT_THREAD = "client-thread-";
    private static final AtomicInteger THREAD_NUMBER = new AtomicInteger(1);

    public static final int DEFAULT_TIMEOUT = 60;

    private static final Logger log = Logger.getLogger(ClientConnection.class);

    private final Channel channel;
    // Registry of handlers for the incoming messages.
    private final Map<Byte, Common.MessageHandler> handlerRegistry;
    private boolean manageExecutor = false;
    private final Executor executor;
    private final int timeoutSeconds;

    private String connectionId;
    private TheConnection mbeanServerConnection;
    private LocalNotificationManager localNotificationManager;

    private int nextCorrelationId = 1;

    static final ThreadGroup THREAD_GROUP;
    static {
        THREAD_GROUP = AccessController.doPrivileged(new PrivilegedAction<ThreadGroup>() {
            public ThreadGroup run() {
                ThreadGroup t = Thread.currentThread().getThreadGroup();
                while (t.getParent() != null) t = t.getParent();
                return t;
            }
        });
    }

    /**
     * The in-progress requests awaiting a response.
     */
    private final Map<Integer, VersionedIoFuture> requests = new HashMap<Integer, VersionedIoFuture>();

    ClientConnection(final Channel channel, final Map<String, ?> environment) {
        super(channel);
        this.channel = channel;
        handlerRegistry = createHandlerRegistry();
        Integer seconds = null;
        if (environment != null && environment.containsKey(TIMEOUT_KEY)) {
            final Object timeout = environment.get(TIMEOUT_KEY);
            if (timeout instanceof Number) {
                seconds = ((Number) timeout).intValue();
            } else if (timeout instanceof String) {
                try {
                    seconds = Integer.parseInt((String) timeout);
                } catch (NumberFormatException e) {
                    log.warnf(e, "Could not parse configured timeout %s", timeout);
                }
            } else {
                log.warnf("Timeout %s configured via environment is not valid ", timeout);
            }
        } else {
            seconds = Integer.getInteger(TIMEOUT_KEY, DEFAULT_TIMEOUT);
        }
        if (environment != null && environment.containsKey(Executor.class.getName())) {
            executor = (Executor) environment.get(Executor.class.getName());
        } else {
            executor = Executors.newCachedThreadPool(new ThreadFactory() {

                public Thread newThread(Runnable r) {
                    return new Thread(THREAD_GROUP, r, REMOTING_JMX + " " + CLIENT_THREAD + THREAD_NUMBER.getAndIncrement());
                }
            });
            manageExecutor = true;
        }
        timeoutSeconds = seconds == null ? DEFAULT_TIMEOUT : seconds;
    }

    private Map<Byte, Common.MessageHandler> createHandlerRegistry() {
        Map<Byte, Common.MessageHandler> registry = new HashMap<Byte, Common.MessageHandler>();
        registry.put((byte) (ADD_NOTIFICATION_LISTENER ^ RESPONSE_MASK), new MarshalledResponseHandler<Void>(VOID));
Answer:         registry.put((byte) (CREATE_MBEAN ^ RESPONSE_MASK), new MarshalledResponseHandler<ObjectInstance>(OBJECT_INSTANCE));