001 /**
002 *
003 * Copyright 2004 Protique Ltd
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 *
017 **/
018 package org.activemq.transport.http;
019
020 import EDU.oswego.cs.dl.util.concurrent.Channel;
021 import org.activemq.message.Packet;
022 import org.activemq.transport.TransportChannelSupport;
023 import org.activemq.util.JMSExceptionHelper;
024
025 import javax.jms.JMSException;
026
027 /**
028 * A server side HTTP based TransportChannel which processes incoming packets
029 * and adds outgoing packets onto a {@link Channel} so that they can be dispatched
030 * by the HTTP GET requests from the client.
031 *
032 * @version $Revision$
033 */
034 public class HttpServerTransportChannel extends TransportChannelSupport {
035 private Channel channel;
036
037 public HttpServerTransportChannel(Channel channel) {
038 this.channel = channel;
039 }
040
041 public Channel getChannel() {
042 return channel;
043 }
044
045 public void start() throws JMSException {
046 }
047
048 public void asyncSend(Packet packet) throws JMSException {
049 // lets queue up the request waiting for it to be requested
050 // using a HTTP GET
051 try {
052 channel.put(packet);
053 }
054 catch (InterruptedException e) {
055 throw JMSExceptionHelper.newJMSException("Failed to send: " + packet + ". Reason: " + e, e);
056 }
057 }
058
059 public boolean isMulticast() {
060 return false;
061 }
062
063 /**
064 * Can this wireformat process packets of this version
065 * @param version the version number to test
066 * @return true if can accept the version
067 */
068 public boolean canProcessWireFormatVersion(int version){
069 return true;
070 }
071
072 /**
073 * @return the current version of this wire format
074 */
075 public int getCurrentWireFormatVersion(){
076 return 1;
077 }
078
079 public void forceDisconnect() {
080 // TODO: implement me.
081 throw new RuntimeException("Not yet Implemented.");
082 }
083 }