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 org.apache.activemq.transport.amqp.message.InboundTransformer;
020import org.apache.activemq.wireformat.WireFormat;
021import org.apache.activemq.wireformat.WireFormatFactory;
022
023/**
024 * Creates the default AMQP WireFormat object used to configure the protocol support.
025 */
026public class AmqpWireFormatFactory implements WireFormatFactory {
027
028    private long maxFrameSize = AmqpWireFormat.DEFAULT_MAX_FRAME_SIZE;
029    private int maxAmqpFrameSize = AmqpWireFormat.NO_AMQP_MAX_FRAME_SIZE;
030    private int idelTimeout = AmqpWireFormat.DEFAULT_IDLE_TIMEOUT;
031    private int producerCredit = AmqpWireFormat.DEFAULT_PRODUCER_CREDIT;
032    private String transformer = InboundTransformer.TRANSFORMER_NATIVE;
033
034    @Override
035    public WireFormat createWireFormat() {
036        AmqpWireFormat wireFormat = new AmqpWireFormat();
037
038        wireFormat.setMaxFrameSize(getMaxFrameSize());
039        wireFormat.setMaxAmqpFrameSize(getMaxAmqpFrameSize());
040        wireFormat.setIdleTimeout(getIdelTimeout());
041        wireFormat.setProducerCredit(getProducerCredit());
042        wireFormat.setTransformer(getTransformer());
043
044        return wireFormat;
045    }
046
047    public int getMaxAmqpFrameSize() {
048        return maxAmqpFrameSize;
049    }
050
051    public void setMaxAmqpFrameSize(int maxAmqpFrameSize) {
052        this.maxAmqpFrameSize = maxAmqpFrameSize;
053    }
054
055    public long getMaxFrameSize() {
056        return maxFrameSize;
057    }
058
059    public void setMaxFrameSize(long maxFrameSize) {
060        this.maxFrameSize = maxFrameSize;
061    }
062
063    public int getIdelTimeout() {
064        return idelTimeout;
065    }
066
067    public void setIdelTimeout(int idelTimeout) {
068        this.idelTimeout = idelTimeout;
069    }
070
071    public int getProducerCredit() {
072        return producerCredit;
073    }
074
075    public void setProducerCredit(int producerCredit) {
076        this.producerCredit = producerCredit;
077    }
078
079    public String getTransformer() {
080        return transformer;
081    }
082
083    public void setTransformer(String transformer) {
084        this.transformer = transformer;
085    }
086}