View Javadoc

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.codehaus.activemq.transport.http;
    19
    20  import EDU.oswego.cs.dl.util.concurrent.Channel;
    21  import org.codehaus.activemq.message.Packet;
    22  import org.codehaus.activemq.transport.TransportChannelSupport;
    23  import org.codehaus.activemq.util.JMSExceptionHelper;
    24
    25  import javax.jms.JMSException;
    26
    27  /***
    28   * A server side HTTP based TransportChannel which processes incoming packets
    29   * and adds outgoing packets onto a {@link Channel} so that they can be dispatched
    30   * by the HTTP GET requests from the client.
    31   *
    32   * @version $Revision: 1.2 $
    33   */
    34  public class HttpServerTransportChannel extends TransportChannelSupport {
    35      private Channel channel;
    36
    37      public HttpServerTransportChannel(Channel channel) {
    38          this.channel = channel;
    39      }
    40
    41      public Channel getChannel() {
    42          return channel;
    43      }
    44
    45      public void start() throws JMSException {
    46      }
    47
    48      public void asyncSend(Packet packet) throws JMSException {
    49          // lets queue up the request waiting for it to be requested
    50          // using a HTTP GET
    51          try {
    52              channel.put(packet);
    53          }
    54          catch (InterruptedException e) {
    55              throw JMSExceptionHelper.newJMSException("Failed to send: " + packet + ". Reason: " + e, e);
    56          }
    57      }
    58
    59      public boolean isMulticast() {
    60          return false;
    61      }
    62
    63      /***
    64       * Can this wireformat process packets of this version
    65       * @param version the version number to test
    66       * @return true if can accept the version
    67       */
    68      public boolean canProcessWireFormatVersion(int version){
    69          return true;
    70      }
    71
    72      /***
    73       * @return the current version of this wire format
    74       */
    75      public int getCurrentWireFormatVersion(){
    76          return 1;
    77      }
    78  }