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