001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. 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 */ 017package org.apache.activemq.transport.amqp; 018 019import java.io.IOException; 020import java.net.Socket; 021import java.net.URI; 022import java.net.UnknownHostException; 023import java.nio.ByteBuffer; 024 025import javax.net.SocketFactory; 026 027import org.apache.activemq.transport.nio.NIOSSLTransport; 028import org.apache.activemq.wireformat.WireFormat; 029 030public class AmqpNioSslTransport extends NIOSSLTransport { 031 032 private final AmqpFrameParser frameReader = new AmqpFrameParser(this); 033 034 public AmqpNioSslTransport(WireFormat wireFormat, SocketFactory socketFactory, URI remoteLocation, URI localLocation) throws UnknownHostException, IOException { 035 super(wireFormat, socketFactory, remoteLocation, localLocation); 036 037 frameReader.setWireFormat((AmqpWireFormat) wireFormat); 038 } 039 040 public AmqpNioSslTransport(WireFormat wireFormat, Socket socket) throws IOException { 041 super(wireFormat, socket); 042 043 frameReader.setWireFormat((AmqpWireFormat) wireFormat); 044 } 045 046 @Override 047 protected void initializeStreams() throws IOException { 048 super.initializeStreams(); 049 if (inputBuffer.position() != 0 && inputBuffer.hasRemaining()) { 050 serviceRead(); 051 } 052 } 053 054 @Override 055 protected void processCommand(ByteBuffer plain) throws Exception { 056 frameReader.parse(plain); 057 } 058}