001    package com.mockrunner.mock.jms;
002    
003    import java.io.Serializable;
004    
005    import javax.jms.JMSException;
006    import javax.jms.QueueSession;
007    import javax.jms.ServerSession;
008    import javax.jms.Session;
009    
010    /**
011     * Mock implementation of JMS <code>ServerSession</code>.
012     * The <code>ServerSession</code> is not meant for application
013     * use.
014     */
015    public class MockServerSession implements ServerSession, Serializable
016    {
017        private MockConnection connection;
018        private Session session;
019        private boolean started;
020        
021        public MockServerSession(MockConnection connection)
022        {
023            this.connection = connection;
024            session = new MockSession(connection, false, QueueSession.AUTO_ACKNOWLEDGE);
025            started = false;
026        }
027        
028        /**
029         * Returns if this server session was started.
030         * @return <code>true</code> if this server session is started
031         */
032        public boolean isStarted()
033        {
034            return started;
035        }
036        
037        public void setSession(Session session)
038        {
039            this.session = session;
040        }
041        
042        public Session getSession() throws JMSException
043        {
044            connection.throwJMSException();
045            return session;
046        }
047    
048        public void start() throws JMSException
049        {
050            connection.throwJMSException();
051            started = true;
052        }
053    }