KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > ActiveMQXAConnection


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq;
19
20 import javax.jms.JMSException JavaDoc;
21 import javax.jms.Session JavaDoc;
22 import javax.jms.XAConnection JavaDoc;
23 import javax.jms.XAQueueConnection JavaDoc;
24 import javax.jms.XAQueueSession JavaDoc;
25 import javax.jms.XASession JavaDoc;
26 import javax.jms.XATopicConnection JavaDoc;
27 import javax.jms.XATopicSession JavaDoc;
28
29 import org.apache.activemq.management.JMSStatsImpl;
30 import org.apache.activemq.transport.Transport;
31 import org.apache.activemq.util.IdGenerator;
32
33 /**
34  * The XAConnection interface extends the capability of Connection by providing
35  * an XASession (optional).
36  * <p/>
37  * The XAConnection interface is optional. JMS providers are not required to
38  * support this interface. This interface is for use by JMS providers to
39  * support transactional environments. Client programs are strongly encouraged
40  * to use the transactional support available in their environment, rather
41  * than use these XA interfaces directly.
42  *
43  * @version $Revision: 1.6 $
44  * @see javax.jms.Connection
45  * @see javax.jms.ConnectionFactory
46  * @see javax.jms.QueueConnection
47  * @see javax.jms.TopicConnection
48  * @see javax.jms.TopicConnectionFactory
49  * @see javax.jms.QueueConnection
50  * @see javax.jms.QueueConnectionFactory
51  */

52 public class ActiveMQXAConnection extends ActiveMQConnection implements XATopicConnection JavaDoc, XAQueueConnection JavaDoc, XAConnection JavaDoc {
53
54     protected ActiveMQXAConnection(Transport transport, IdGenerator clientIdGenerator, JMSStatsImpl factoryStats) throws Exception JavaDoc {
55         super(transport, clientIdGenerator, factoryStats);
56     }
57
58     public XASession JavaDoc createXASession() throws JMSException JavaDoc {
59         return (XASession JavaDoc) createSession(true, Session.SESSION_TRANSACTED);
60     }
61
62     public XATopicSession JavaDoc createXATopicSession() throws JMSException JavaDoc {
63         return (XATopicSession JavaDoc) createSession(true, Session.SESSION_TRANSACTED);
64     }
65
66     public XAQueueSession JavaDoc createXAQueueSession() throws JMSException JavaDoc {
67         return (XAQueueSession JavaDoc) createSession(true, Session.SESSION_TRANSACTED);
68     }
69
70     public Session JavaDoc createSession(boolean transacted, int acknowledgeMode) throws JMSException JavaDoc {
71         checkClosedOrFailed();
72         ensureConnectionInfoSent();
73         return new ActiveMQXASession(this, getNextSessionId(), Session.SESSION_TRANSACTED, dispatchAsync);
74     }
75 }
76
Popular Tags