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.broker;
018
019import java.util.concurrent.atomic.AtomicInteger;
020
021import org.apache.activemq.command.ConnectionInfo;
022
023/**
024 * 
025 */
026
027public class TransportConnectionState extends org.apache.activemq.state.ConnectionState {
028
029    private ConnectionContext context;
030    private TransportConnection connection;
031    private AtomicInteger referenceCounter = new AtomicInteger();
032    private final Object connectionMutex = new Object();
033
034    public TransportConnectionState(ConnectionInfo info, TransportConnection transportConnection) {
035        super(info);
036        connection = transportConnection;
037    }
038
039    public ConnectionContext getContext() {
040        return context;
041    }
042
043    public TransportConnection getConnection() {
044        return connection;
045    }
046
047    public void setContext(ConnectionContext context) {
048        this.context = context;
049    }
050
051    public void setConnection(TransportConnection connection) {
052        this.connection = connection;
053    }
054
055    public int incrementReference() {
056        return referenceCounter.incrementAndGet();
057    }
058
059    public int decrementReference() {
060        return referenceCounter.decrementAndGet();
061    }
062
063        public AtomicInteger getReferenceCounter() {
064                return referenceCounter;
065        }
066
067        public void setReferenceCounter(AtomicInteger referenceCounter) {
068                this.referenceCounter = referenceCounter;
069        }
070
071        public Object getConnectionMutex() {
072                return connectionMutex;
073        }
074}