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.util.HashMap;
020import java.util.Map;
021
022import org.apache.activemq.broker.BrokerService;
023import org.apache.activemq.broker.BrokerServiceAware;
024import org.apache.activemq.transport.MutexTransport;
025import org.apache.activemq.transport.Transport;
026import org.apache.activemq.transport.tcp.TcpTransportFactory;
027import org.apache.activemq.util.IntrospectionSupport;
028import org.apache.activemq.wireformat.WireFormat;
029
030/**
031 * A <a href="http://amqp.org/">AMQP</a> transport factory
032 */
033public class AmqpTransportFactory extends TcpTransportFactory implements BrokerServiceAware {
034
035    private BrokerService brokerService = null;
036
037    @Override
038    protected String getDefaultWireFormatType() {
039        return "amqp";
040    }
041
042    @Override
043    @SuppressWarnings("rawtypes")
044    public Transport compositeConfigure(Transport transport, WireFormat format, Map options) {
045        transport = new AmqpTransportFilter(transport, format, brokerService);
046        IntrospectionSupport.setProperties(transport, options);
047        return super.compositeConfigure(transport, format, options);
048    }
049
050    @Override
051    public void setBrokerService(BrokerService brokerService) {
052        this.brokerService = brokerService;
053    }
054
055    @SuppressWarnings("rawtypes")
056    @Override
057    public Transport serverConfigure(Transport transport, WireFormat format, HashMap options) throws Exception {
058        transport = super.serverConfigure(transport, format, options);
059
060        // strip off the mutex transport.
061        if (transport instanceof MutexTransport) {
062            transport = ((MutexTransport) transport).getNext();
063        }
064
065        return transport;
066    }
067
068    @Override
069    protected boolean isUseInactivityMonitor(Transport transport) {
070        return false;
071    }
072}