public void addInterceptor(int index, PacketInterceptor interceptor) {
        if (index < 0 || (index > globalInterceptors.size())) {
            throw new IndexOutOfBoundsException("Index " + index + " invalid.");
        }
        if (interceptor == null) {
            throw new NullPointerException("Parameter interceptor was null.");
        }
        // Remove the interceptor from the list since the position might have changed
        if (globalInterceptors.contains(interceptor)) {
            int oldIndex = globalInterceptors.indexOf(interceptor);
            if (oldIndex < index) {
                index -= 1;
            }
            globalInterceptors.remove(interceptor);
        }

        globalInterceptors.add(index, interceptor);
    }
Inserts a new interceptor at specified index in the list of currently configured
interceptors. This interceptor will be used for all the sent and received packets.

@param index the index in the list to insert the new interceptor at.
@param interceptor the interceptor to add.
xmppserver/src/main/java/org/jivesoftware/openfire/interceptor/InterceptorManager.java