001/**
002 *
003 * Copyright 2015-2019 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smack.iqrequest;
018
019import javax.xml.namespace.QName;
020
021import org.jivesoftware.smack.packet.IQ;
022
023/**
024 * IQ request handler are responsible for handling incoming IQ requests. They can be registered with
025 * {@link org.jivesoftware.smack.XMPPConnection#registerIQRequestHandler(IQRequestHandler)}.
026 *
027 * @see AbstractIqRequestHandler
028 */
029public interface IQRequestHandler {
030
031    enum Mode {
032        /**
033         * Process requests synchronously, i.e. in the order they arrive. Uses a single thread, which means that the other
034         * requests have to wait until all previous synchronous requests have been handled. Use {@link #async} if
035         * possible for performance reasons.
036         */
037        sync,
038
039        /**
040         * Process IQ requests asynchronously, i.e. concurrent. This does not guarantee that requests are processed in the
041         * same order they arrive.
042         */
043        async,
044    }
045
046    IQ handleIQRequest(IQ iqRequest);
047
048    Mode getMode();
049
050    IQ.Type getType();
051
052    String getElement();
053
054    String getNamespace();
055
056    default QName getQName() {
057        return new QName(getNamespace(), getElement());
058    }
059}