Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/transport/stomp/StompTransportChannel.java


1   /**
2    * 
3    * Copyright 2005 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  
19  package org.activemq.transport.stomp;
20  
21  import EDU.oswego.cs.dl.util.concurrent.Executor;
22  
23  import org.activemq.message.Packet;
24  import org.activemq.transport.tcp.TcpTransportChannel;
25  import org.activemq.transport.tcp.TcpTransportServerChannel;
26  
27  import javax.jms.JMSException;
28  import java.net.Socket;
29  import java.net.URI;
30  import java.io.IOException;
31  
32  /**
33   * A transport for using Stomp to talk to ActiveMQ
34   *
35   * @version $Revision: 1.1 $
36   */
37  public class StompTransportChannel extends TcpTransportChannel {
38  
39      public StompTransportChannel() {
40          super(new StompWireFormat());
41      }
42  
43      public StompTransportChannel(URI remoteLocation) throws JMSException {
44          super(new StompWireFormat(), remoteLocation);
45      }
46  
47      public StompTransportChannel(URI remoteLocation, URI localLocation) throws JMSException {
48          super(new StompWireFormat(), remoteLocation, localLocation);
49      }
50  
51      public StompTransportChannel(TcpTransportServerChannel serverChannel, Socket socket, Executor executor)
52              throws JMSException {
53          super(serverChannel, new StompWireFormat(), socket, executor);
54      }
55  
56      public StompTransportChannel(Socket socket, Executor executor) throws JMSException {
57          super(new StompWireFormat(), socket, executor);
58      }
59  
60      public StompWireFormat getTTMPWireFormat() {
61          return (StompWireFormat) getWireFormat();
62      }
63  
64      protected void readWireFormat() throws JMSException, IOException {
65          // no need to read wire format from wire
66      }
67      
68      protected void doConsumePacket(Packet packet) {
69          if( packet == FlushPacket.PACKET ) {
70              try {
71                  doAsyncSend(null);
72              } catch (JMSException e) {
73                  getExceptionListener().onException(e);
74              }
75          } else {
76              super.doConsumePacket(packet);
77          }
78      }
79      
80  }