1d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen/*
2d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * Copyright 2009 Mike Cumings
3d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen *
4d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * Licensed under the Apache License, Version 2.0 (the "License");
5d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * you may not use this file except in compliance with the License.
6d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * You may obtain a copy of the License at
7d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen *
8d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen *   http://www.apache.org/licenses/LICENSE-2.0
9d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen *
10d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * Unless required by applicable law or agreed to in writing, software
11d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * distributed under the License is distributed on an "AS IS" BASIS,
12d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * See the License for the specific language governing permissions and
14d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * limitations under the License.
15d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen */
16d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
17d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chenpackage com.kenai.jbosh;
18d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
19d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen/**
20d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * Interface used to represent code which can send a BOSH XML body over
21d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen * HTTP to a connection manager.
22d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen */
23d7955ce24d294fb2014c59d11fca184471056f44Shuyi Cheninterface HTTPSender {
24d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
25d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    /**
26d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * Initialize the HTTP sender instance for use with the session provided.
27d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * This method will be called once before use of the service instance.
28d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     *
29d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * @param sessionCfg session configuration
30d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     */
31d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    void init(BOSHClientConfig sessionCfg);
32d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
33d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    /**
34d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * Dispose of all resources used to provide the required services.  This
35d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * method will be called once when the service instance is no longer
36d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * required.
37d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     */
38d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    void destroy();
39d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
40d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    /**
41d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * Create a {@code Callable} instance which can be used to send the
42d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * request specified to the connection manager.  This method should
43d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * return immediately, prior to doing any real work.  The invocation
44d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * of the returned {@code Callable} should send the request (if it has
45d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * not already been sent by the time of the call), block while waiting
46d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * for the response, and then return the response body.
47d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     *
48d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * @param params CM session creation resopnse params
49d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * @param body request body to send
50d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     * @return callable used to access the response
51d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen     */
52d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen    HTTPResponse send(CMSessionParams params, AbstractBody body);
53d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen
54d7955ce24d294fb2014c59d11fca184471056f44Shuyi Chen}
55