You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/11/13 00:08:49 UTC
svn commit: r1034596 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ cms/
Author: tabish
Date: Fri Nov 12 23:08:49 2010
New Revision: 1034596
URL: http://svn.apache.org/viewvc?rev=1034596&view=rev
Log:
Add the initial interface definitions needed to support XA Transactions in CMS Providers.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h (with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=1034596&r1=1034595&r2=1034596&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Fri Nov 12 23:08:49 2010
@@ -225,18 +225,49 @@ cc_sources = \
activemq/wireformat/stomp/StompHelper.cpp \
activemq/wireformat/stomp/StompWireFormat.cpp \
activemq/wireformat/stomp/StompWireFormatFactory.cpp \
+ cms/BytesMessage.cpp \
cms/CMSException.cpp \
+ cms/CMSProperties.cpp \
cms/CMSSecurityException.cpp \
+ cms/Closeable.cpp \
+ cms/Connection.cpp \
+ cms/ConnectionFactory.cpp \
+ cms/ConnectionMetaData.cpp \
+ cms/DeliveryMode.cpp \
+ cms/Destination.cpp \
+ cms/ExceptionListener.cpp \
cms/IllegalStateException.cpp \
cms/InvalidClientIdException.cpp \
cms/InvalidDestinationException.cpp \
cms/InvalidSelectorException.cpp \
+ cms/MapMessage.cpp \
cms/Message.cpp \
+ cms/MessageConsumer.cpp \
cms/MessageEOFException.cpp \
+ cms/MessageEnumeration.cpp \
cms/MessageFormatException.cpp \
+ cms/MessageListener.cpp \
cms/MessageNotReadableException.cpp \
cms/MessageNotWriteableException.cpp \
+ cms/MessageProducer.cpp \
+ cms/ObjectMessage.cpp \
+ cms/Queue.cpp \
+ cms/QueueBrowser.cpp \
+ cms/Session.cpp \
+ cms/Startable.cpp \
+ cms/Stoppable.cpp \
+ cms/StreamMessage.cpp \
+ cms/TemporaryQueue.cpp \
+ cms/TemporaryTopic.cpp \
+ cms/TextMessage.cpp \
+ cms/Topic.cpp \
cms/UnsupportedOperationException.cpp \
+ cms/XAConnection.cpp \
+ cms/XAConnectionFactory.cpp \
+ cms/XAException.cpp \
+ cms/XAResource.cpp \
+ cms/XASession.cpp \
+ cms/Xid.cpp \
decaf/internal/AprPool.cpp \
decaf/internal/DecafRuntime.cpp \
decaf/internal/io/StandardErrorOutputStream.cpp \
@@ -687,6 +718,12 @@ h_sources = \
cms/TextMessage.h \
cms/Topic.h \
cms/UnsupportedOperationException.h \
+ cms/XAConnection.h \
+ cms/XAConnectionFactory.h \
+ cms/XAException.h \
+ cms/XAResource.h \
+ cms/XASession.h \
+ cms/Xid.h \
decaf/internal/AprPool.h \
decaf/internal/DecafRuntime.h \
decaf/internal/io/StandardErrorOutputStream.h \
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "XAConnection.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+XAConnection::~XAConnection() {
+
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XACONNECTION_H_
+#define _CMS_XACONNECTION_H_
+
+#include <cms/Config.h>
+
+#include <cms/CMSException.h>
+#include <cms/Connection.h>
+#include <cms/XASession.h>
+
+namespace cms {
+
+ /**
+ * The XAConnection interface defines an extended Connection type that is used to create
+ * XASession objects. This is an optional interface and CMS providers are allowed to omit
+ * an implementation and instead throw an exception from an XAConnectionFactory stub to
+ * indicate that XA is not supported.
+ *
+ * @since 2.3
+ */
+ class CMS_API XAConnection {
+ public:
+
+ virtual ~XAConnection();
+
+ /**
+ * Creates an XASession object.
+ *
+ * @returns a newly created XASession instance, caller owns the pointer.
+ *
+ * @throws CMSException
+ * If the XAConnection object fails to create the XASession instance due to
+ * an internal error.
+ */
+ virtual XASession* createXASession() = 0;
+
+ };
+
+}
+
+#endif /* _CMS_XACONNECTION_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnection.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "XAConnectionFactory.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+XAConnectionFactory::~XAConnectionFactory() {
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XACONNECTIONFACTORY_H_
+#define _CMS_XACONNECTIONFACTORY_H_
+
+#include <cms/Config.h>
+
+#include <cms/XAConnection.h>
+#include <cms/XAException.h>
+
+namespace cms {
+
+ /**
+ * The XAConnectionFactory interface is specialized interface that defines an
+ * ConnectionFactory that creates Connection instance that will participate in
+ * XA Transactions.
+ *
+ * Some application provide support for grouping XA capable resource use into
+ * a distributed transaction (optional). To include CMS API transactions in a
+ * XA transaction, an application requires a XA aware library. A CMS provider
+ * exposes its XA support using an XAConnectionFactory object, which an application
+ * uses to create XAConnection objects.
+ *
+ * The XAConnectionFactory interface is optional. CMS providers are not required
+ * to support this interface. This interface is for use by CMS providers to support
+ * transactional environments. Client programs are strongly encouraged to use the
+ * transactional support available in their environment, rather than use these
+ * XA interfaces directly.
+ *
+ * @since 2.3
+ */
+ class CMS_API XAConnectionFactory {
+ public:
+
+ virtual ~XAConnectionFactory();
+
+ /**
+ * Creates an XAConnection with the default user name and password. The connection is created
+ * in stopped mode just as the standard Connection object is created from the ConnectionFactory.
+ * No messages will be delivered until the Connection.start method is explicitly called.
+ *
+ * @returns a new XAConnectionFactory instance, the caller owns the returned pointer.
+ *
+ * @throws CMSException if an internal error occurs while creating the Connection.
+ * @throws CMSSecurityException if the client authentication fails because the user name or
+ * password are invalid.
+ */
+ virtual XAConnection* createXAConnection() = 0;
+
+ /**
+ * Creates an XA connection with the specified user name and password. The connection is
+ * created in stopped mode just as the standard ConnectionFactory creates a new Connection.
+ * No messages will be delivered until the Connection.start method is explicitly called.
+ *
+ * @returns a new XAConnectionFactory instance, the caller owns the returned pointer.
+ *
+ * @throws CMSException if an internal error occurs while creating the Connection.
+ * @throws CMSSecurityException if the client authentication fails because the user name or
+ * password are invalid.
+ */
+ virtual XAConnection* createXAConnection( const std::string& userName,
+ const std::string& password ) = 0;
+
+ };
+
+}
+
+#endif /* _CMS_XACONNECTIONFACTORY_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAConnectionFactory.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "XAException.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+const int XAException::XA_RBBASE = 100;
+const int XAException::XA_RBROLLBACK = 100;
+const int XAException::XA_RBCOMMFAIL = 101;
+const int XAException::XA_RBDEADLOCK = 102;
+const int XAException::XA_RBINTEGRITY = 103;
+const int XAException::XA_RBOTHER = 104;
+const int XAException::XA_RBPROTO = 105;
+const int XAException::XA_RBTIMEOUT = 106;
+const int XAException::XA_RBTRANSIENT = 107;
+const int XAException::XA_RBEND = 107;
+const int XAException::XA_NOMIGRATE = 9;
+const int XAException::XA_HEURHAZ = 8;
+const int XAException::XA_HEURCOM = 7;
+const int XAException::XA_HEURRB = 6;
+const int XAException::XA_HEURMIX = 5;
+const int XAException::XA_RETRY = 4;
+const int XAException::XA_RDONLY = 3;
+const int XAException::XAER_ASYNC = -2;
+const int XAException::XAER_RMERR = -3;
+const int XAException::XAER_NOTA = -4;
+const int XAException::XAER_INVAL = -5;
+const int XAException::XAER_PROTO = -6;
+const int XAException::XAER_RMFAIL = -7;
+const int XAException::XAER_DUPID = -8;
+const int XAException::XAER_OUTSIDE = -9;
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException() : CMSException(), errorCode(0) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException( int errorCode ) : CMSException(), errorCode(errorCode) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException( const XAException& ex ) : CMSException( ex ) {
+ this->errorCode = ex.errorCode;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException( const std::string& message )
+ : CMSException( message, NULL ), errorCode(0) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException( const std::string& message, const std::exception* cause )
+ : CMSException( message, cause ), errorCode(0) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::XAException( const std::string& message,
+ const std::exception* cause,
+ const std::vector< std::pair< std::string, int> >& stackTrace )
+ : CMSException( message, cause, stackTrace ), errorCode(0) {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+XAException::~XAException() throw() {
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XAEXCEPTION_H_
+#define _CMS_XAEXCEPTION_H_
+
+#include <cms/Config.h>
+#include <cms/CMSException.h>
+
+namespace cms {
+
+ /**
+ * The XAException is thrown by the Resource Manager (RM) to inform the
+ * Transaction Manager of an error encountered by the involved transaction.
+ *
+ * @since 2.3
+ */
+ class CMS_API XAException : CMSException {
+ private:
+
+ int errorCode;
+
+ public:
+
+ /**
+ * Code which contains the inclusive lower bound of the rollback error codes
+ */
+ static const int XA_RBBASE;
+
+ /**
+ * Code which means that the rollback occurred for an unspecified reason
+ */
+ static const int XA_RBROLLBACK;
+
+ /**
+ * Code which means that rollback was caused by a communication failure
+ */
+ static const int XA_RBCOMMFAIL;
+
+ /**
+ * Code which means that a failure occurred because a deadlock was detected
+ */
+ static const int XA_RBDEADLOCK;
+
+ /**
+ * Code which means that a condition was detected than implies a violation
+ * of the integrity of the resource
+ */
+ static const int XA_RBINTEGRITY;
+
+ /**
+ * Code which means that the Resource Manager rolled back the transaction
+ * branch for a reason not separately listed
+ */
+ static const int XA_RBOTHER;
+
+ /**
+ * Code which means that a protocol error occurred in the Resource Manager
+ */
+ static const int XA_RBPROTO;
+
+ /**
+ * Code which means that a transaction branch took too long
+ */
+ static const int XA_RBTIMEOUT;
+
+ /**
+ * Code which means that the caller may retry the transaction branch
+ */
+ static const int XA_RBTRANSIENT;
+
+ /**
+ * Code which contains the inclusive upper bound of the rollback error codes
+ */
+ static const int XA_RBEND;
+
+ /**
+ * Code which means that resumption must occur where the suspension occurred
+ */
+ static const int XA_NOMIGRATE;
+
+ /**
+ * Code which means that the transaction branch may have been heuristically
+ * completed
+ */
+ static const int XA_HEURHAZ;
+
+ /**
+ * Code which means that the transaction branch has been heuristically
+ * committed
+ */
+ static const int XA_HEURCOM;
+
+ /**
+ * Code which means that the transaction branch has been heuristically
+ * rolled back
+ */
+ static const int XA_HEURRB;
+
+ /**
+ * Code which means that the transaction branch has been heuristically
+ * committed and rolled back
+ */
+ static const int XA_HEURMIX;
+
+ /**
+ * Code which means that the method returned with no effect and can be
+ * reissued
+ */
+ static const int XA_RETRY;
+
+ /**
+ * Code which means that the transaction branch was read only and has been
+ * committed
+ */
+ static const int XA_RDONLY;
+
+ /**
+ * Code which means that there is already an asynchronous operation
+ * outstanding
+ */
+ static const int XAER_ASYNC;
+
+ /**
+ * Code which means that a Resource Manager error has occurred for the
+ * transaction branch
+ */
+ static const int XAER_RMERR;
+
+ /**
+ * Code which means that the XID is not valid
+ */
+ static const int XAER_NOTA;
+
+ /**
+ * Code which means that invalid arguments were supplied
+ */
+ static const int XAER_INVAL;
+
+ /**
+ * Code which means that the method was invoked in an improper context
+ */
+ static const int XAER_PROTO;
+
+ /**
+ * Code which means that the Resource Manager is unavailable
+ */
+ static const int XAER_RMFAIL;
+
+ /**
+ * Code which means that the XID already exists
+ */
+ static const int XAER_DUPID;
+
+ /**
+ * Work is being done by the Resource Manager outside the boundaries of a
+ * global transaction.
+ */
+ static const int XAER_OUTSIDE;
+
+ public:
+
+ XAException();
+
+ XAException( int errorCode );
+
+ XAException( const XAException& ex );
+
+ XAException( const std::string& message );
+
+ XAException( const std::string& message,
+ const std::exception* cause );
+
+ XAException( const std::string& message,
+ const std::exception* cause,
+ const std::vector< std::pair< std::string, int> >& stackTrace );
+
+ virtual ~XAException() throw();
+ };
+
+}
+
+#endif /* _CMS_XAEXCEPTION_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAException.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "XAResource.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+const int XAResource::TMENDRSCAN = 0x800000;
+const int XAResource::TMFAIL = 0x20000000;
+const int XAResource::TMJOIN = 0x200000;
+const int XAResource::TMNOFLAGS = 0;
+const int XAResource::TMONEPHASE = 0x40000000;
+const int XAResource::TMRESUME = 0x8000000;
+const int XAResource::TMSTARTRSCAN = 0x1000000;
+const int XAResource::TMSUCCESS = 0x4000000;
+const int XAResource::TMSUSPEND = 0x2000000;
+const int XAResource::XA_RDONLY = 3;
+const int XAResource::XA_OK = 0;
+
+////////////////////////////////////////////////////////////////////////////////
+XAResource::~XAResource() {
+}
+
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XARESOURCE_H_
+#define _CMS_XARESOURCE_H_
+
+#include <cms/Config.h>
+
+#include <cms/Xid.h>
+#include <cms/XAException.h>
+
+namespace cms {
+
+ /**
+ * The XAResource interface is a CMS mapping of the industry standard XA interface based
+ * on the X/Open CAE Specification (Distributed Transaction Processing: The XA Specification).
+ *
+ * The XA interface defines the contract between a Resource Manager and a Transaction Manager
+ * in a distributed transaction processing (DTP) environment. A CMS provider implements this
+ * interface to support the association between a global transaction and a message broker
+ * connection.
+ *
+ * The XAResource is exposed to CMS client so that they can proxy calls from the Transaction
+ * Manager API of their choosing to the CMS provider. The CMS provider should behave and a
+ * standard XA Resource Manager its up to the client however to transmit the Transaction
+ * Manager's calls to the CMS provider through this interface.
+ *
+ * @since 2.3
+ */
+ class CMS_API XAResource {
+ public:
+
+ /**
+ * Flag to end a recovery scan
+ */
+ static const int TMENDRSCAN;
+
+ /**
+ * Flag to indicate that the caller is dissociation from a transaction
+ * branch and that it should be marked rollback only
+ */
+ static const int TMFAIL;
+
+ /**
+ * Flag to indicate that the caller is joining sn existing transaction
+ * branch.
+ */
+ static const int TMJOIN;
+
+ /**
+ * Flag that indicates that no flags options are selected. (ie a null flag)
+ */
+ static const int TMNOFLAGS;
+
+ /**
+ * Flag that indicates the caller is using one-phase commit optimization
+ */
+ static const int TMONEPHASE;
+
+ /**
+ * Flag that indicates the caller is resuming association with a suspended
+ * transaction branch
+ */
+ static const int TMRESUME;
+
+ /**
+ * Flag that indicates the start of a recovery scan
+ */
+ static const int TMSTARTRSCAN;
+
+ /**
+ * Flag that indicates the caller is dissociating from a transaction branch
+ */
+ static const int TMSUCCESS;
+
+ /**
+ * Flag that indicates that the caller is suspending (not terminating) its
+ * association with a transaction branch.
+ */
+ static const int TMSUSPEND;
+
+ /**
+ * Flag that indicates that transaction work has been read only and has been
+ * committed normally
+ */
+ static const int XA_RDONLY;
+
+ /**
+ * Flag that indicates that transaction work has been Prepared normally
+ */
+ static const int XA_OK;
+
+ public:
+
+ virtual ~XAResource();
+
+ /**
+ * Commits a global transaction.
+ *
+ * @param xid
+ * the XID which identifies the global transaction.
+ * @param onePhase
+ * true if the resource manager should use a one-phase commit
+ * protocol to commit the transaction.
+ *
+ * @throws XAException
+ * if an error occurred.
+ * <p>
+ * Possible errors are identified by the errorcode in the
+ * XAException and include: XA_HEURHAZ, XA_HEURCOM, XA_HEURRB,
+ * XA_HEURMIX, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL,
+ * or XAER_PROTO. In addition, one of the XA_RB* errors can
+ * occur if the transaction was not committed and onePhase
+ * was set to true. On completion of this method, the Resource
+ * Manager has rolled back the transaction and released
+ * resources held by the transaction.
+ */
+ virtual void commit( const Xid* xid, bool onePhase ) = 0;
+
+ /**
+ * Ends the work done for a transaction branch. The Resource Manager
+ * disconnects the XA resource from the transaction branch and allows the
+ * transaction to complete.
+ *
+ * @param xid
+ * the XID which identifies the global transaction. Should have
+ * previously been used as the parameter to a start.
+ * method.
+ * @param flags
+ * a flags integer - one of: XAResource.TMSUCCESS,
+ * XAResource.TMFAIL, or XAResource.TMSUSPEND.
+ * <p>
+ * TMSUCCESS means that this section of work completed
+ * successfully.
+ * <p>
+ * TMFAIL means that this section of work failed. The Resource
+ * Manager can mark the transaction for rollback only.
+ * <p>
+ * TMSUSPEND means that this section of work is suspended and not
+ * yet complete. The associated transaction context is also
+ * suspended and must be restarted with a call to
+ * {@link #start(Xid, int)} with the TMRESUME
+ * flag.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR, XAER_RMFAIL, XAER_NOTA,
+ * XAER_INVAL, XAER_PROTO, or XA_RB*.
+ */
+ virtual void end( const Xid* xid, int flags ) = 0;
+
+ /**
+ * Informs the Resource Manager that it can forget about a specified
+ * transaction branch.
+ *
+ * @param xid
+ * the XID which identifies the global transaction.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR, XAER_RMFAIL, XAER_NOTA,
+ * XAER_INVAL, or XAER_PROTO.
+ */
+ virtual void forget( const Xid* xid ) = 0;
+
+ /**
+ * Gets the transaction timeout value for this XAResource. The default
+ * timeout value is the default timeout value set for the Resource Manager.
+ *
+ * @return the transaction timeout value for this XAResource in seconds.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR and XAER_RMFAIL.
+ */
+ virtual int getTransactionTimeout() const = 0;
+
+ /**
+ * Returns true if the ResourceManager for this XAResource is the same as
+ * the Resource Manager for a supplied XAResource.
+ *
+ * @param theXAResource
+ * an XAResource object
+ * @return true if the Resource Manager for this XAResource is the same as
+ * the Resource Manager for <code>theXAResource</code>.
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR and XAER_RMFAIL.
+ */
+ virtual bool isSameRM( const XAResource* theXAResource ) = 0;
+
+ /**
+ * Requests the Resource manager to prepare to commit a specified
+ * transaction.
+ *
+ * @param xid
+ * the XID which identifies the global transaction.
+ *
+ * @return an integer: XA_RDONLY or XA_OK. XA_OK implies that the
+ * transaction work has been prepared normally, XA_RDONLY implies
+ * that the transaction branch is read only and has been committed.
+ * If there is a failure which requires a rollback, an XAException
+ * is raised.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XA_RB*, XAER_RMERR, XAER_RMFAIL,
+ * XAER_NOTA, XAER_INVAL, or XAER_PROTO.
+ */
+ virtual int prepare( const Xid* xid ) = 0;
+
+ /**
+ * Get a list of prepared transaction branches.
+ *
+ * Typically used by a transaction manager during recovery to find
+ * transaction branches that are in prepared or heuristically completed
+ * states.
+ *
+ * @param flag
+ * an integer. Must be one of: XAResource.TMSTARTRSCAN,
+ * XAResource.TMENDRSCAN, XAResource.TMNOFLAGS.
+ *
+ * @return an array of zero or more XIDs identifying the transaction
+ * branches in the prepared or heuristically completed states.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and
+ * XAER_PROTO.
+ */
+ virtual int recover(int flag, Xid** recovered ) = 0;
+
+ /**
+ * Requests the Resource Manager to rollback a specified transaction branch.
+ *
+ * @param xid
+ * the XID which identifies the transaction branch.
+ *
+ * @throws XAException
+ * if an error occurs.
+ */
+ virtual void rollback( const Xid* xid ) = 0;
+
+ /**
+ * Sets the transaction timeout value for this XAResource. If the value is
+ * set to 0, the default timeout value for the Resource Manager is used.
+ *
+ * @param seconds
+ * the new Timeout value in seconds.
+ *
+ * @return true if the transaction timeout value has been updated, false
+ * otherwise.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
+ */
+ virtual bool setTransactionTimeout( int seconds ) = 0;
+
+ /**
+ * Starts work for a specified transaction branch.
+ *
+ * @param xid
+ * the XID which identifies the transaction branch.
+ * @param flags
+ * an integer. Must be one of XAResource.TMNOFLAGS,
+ * XAResource.TMJOIN, or XAResource.TMRESUME.
+ * <p>
+ * TMJOIN implies that the start applies to joining a transaction
+ * previously passed to the Resource Manager.
+ * <p>
+ * TMRESUME implies that the start applies to a suspended
+ * transaction that should be restarted.
+ * <p>
+ * If TMNOFLAGS is specified, then if the transaction has been
+ * previously seen by the Resource Manager, an XAException is
+ * raised with the code XAER_DUPID.
+ *
+ * @throws XAException
+ * if an error occurs. Possible error identified in the
+ * errorcode include: XA_RB*, XAER_RMERR, XAER_RMFAIL,
+ * XAER_DUPID, XAER_OUTSIDE, XAER_NOTA, XAER_INVAL, or
+ * XAER_PROTO.
+ */
+ virtual void start( const Xid* xid, int flags ) = 0;
+
+ };
+
+}
+
+#endif /* _CMS_XARESOURCE_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XAResource.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "XASession.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+XASession::~XASession() {
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XASESSION_H_
+#define _CMS_XASESSION_H_
+
+#include <cms/Config.h>
+
+#include <cms/XAResource.h>
+
+namespace cms {
+
+ /**
+ * The XASession interface extends the capability of Session by adding access to a CMS provider's
+ * support for the operating inside an XA Transaction (optional). This support takes the form of
+ * a cms::XAResource object. The functionality of this object closely resembles that defined by
+ * the standard X/Open XA Resource interface.
+ *
+ * An application controls the transactional assignment of an XASession by obtaining its XAResource.
+ * It uses the XAResource to assign the session to a transaction, prepare and commit work on the
+ * transaction, and so on.
+ *
+ * An XAResource provides some fairly sophisticated facilities for interleaving work on multiple
+ * transactions, recovering a list of transactions in progress, and so on. A XA aware CMS provider
+ * must fully implement this functionality.
+ *
+ * The XASession instance will behave much like a normal cms::Session however some methods will
+ * will not operate as normal, any call to Session::commit, or Session::rollback will result in
+ * a CMSException being thrown. Also when not inside an XA transaction the MessageConsumer will
+ * operate as if it were in the AutoAcknowlege mode.
+ *
+ * The XASession interface is optional. CMS providers are not required to support this interface.
+ * This interface is for use by CMS providers to support transactional environments. Client programs
+ * are strongly encouraged to use the transactional support available in their environment, rather
+ * than use these XA interfaces directly.
+ *
+ * @since 2.3
+ */
+ class CMS_API XASession {
+ public:
+
+ virtual ~XASession();
+
+ /**
+ * Returns the XA resource associated with this Session to the caller.
+ *
+ * The client can use the provided XA resource to interact with the XA Transaction
+ * Manager in use in the client application.
+ *
+ * @returns an XAResouce instance to the caller, the caller does not own this
+ * pointer and should not delete it.
+ */
+ virtual XAResource* getXAResource() const = 0;
+
+ };
+
+}
+
+#endif /* _CMS_XASESSION_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/XASession.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp Fri Nov 12 23:08:49 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Xid.h"
+
+using namespace cms;
+
+////////////////////////////////////////////////////////////////////////////////
+const int Xid::MAXGTRIDSIZE = 64;
+const int Xid::MAXBQUALSIZE = 64;
+
+////////////////////////////////////////////////////////////////////////////////
+Xid::~Xid() {
+}
+
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h?rev=1034596&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h Fri Nov 12 23:08:49 2010
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMS_XID_H_
+#define _CMS_XID_H_
+
+#include <cms/Config.h>
+
+#include <cms/CMSException.h>
+
+namespace cms {
+
+ /**
+ * An interface which provides a mapping for the X/Open XID transaction
+ * identifier structure. The Xid interface is used by the Transaction Manager
+ * and the Resource managers. It is not typically used by application programs
+ * directly but the application developer must define a mechanism to map the
+ * calls and structures used by the Transaction Manager API in use into the
+ * format used by the CMS XA interfaces.
+ *
+ * @since 2.3
+ */
+ class CMS_API Xid {
+ private:
+
+ Xid( const Xid& );
+ Xid& operator= ( const Xid& );
+
+ public:
+
+ /**
+ * The maximum number of bytes which will be copied into the array passed to
+ * getGlobaltransactionId().
+ */
+ static const int MAXGTRIDSIZE;
+
+ /**
+ * The maximum number of bytes which will be copied into the array that is passed
+ * to getBranchQualifier().
+ */
+ static const int MAXBQUALSIZE;
+
+ public:
+
+ virtual ~Xid();
+
+ /**
+ * Creates a Copy of this Xid instance that contains the same id values.
+ *
+ * @returns a new Xid instance that is equal to this one when compared.
+ */
+ virtual Xid* clone() const = 0;
+
+ /**
+ * Compares this Xid to another and returns true if they are the same.
+ *
+ * @returns true if both Xid's represent that same id value.
+ */
+ virtual bool equals( const Xid* other ) const = 0;
+
+ /**
+ * Gets the transaction branch qualifier component of the XID. The value of this
+ * Xid's branch qualifier is copied into the buffer provided. If the size of the
+ * provided buffer is not large enough to accommodate the branch qualifier then
+ * no copy is performed and the method returns -1.
+ *
+ * @param buffer
+ * The location in memory to copy the qualifier bytes to.
+ * @param size
+ * The size of the buffer provided.
+ *
+ * @return the number of bytes copied into the buffer, or -1 if the buffer
+ * provided was not large enough.
+ *
+ * @throws CMSException if the size parameter is less than zero or buffer is NULL.
+ */
+ virtual int getBranchQualifier( unsigned char* buffer, int size ) const = 0;
+
+ /**
+ * Gets the format identifier component of the XID.
+ *
+ * @return an integer containing the format identifier. 0 means the OSI CCR
+ * format.
+ */
+ virtual int getFormatId() const = 0;
+
+ /**
+ * Gets the global transaction id component of the XID. The value of this
+ * Xid's transaction id is copied into the buffer provided. If the size of the
+ * provided buffer is not large enough to accommodate the transaction id then
+ * no copy is performed and the method returns -1.
+ *
+ * @param buffer
+ * The location in memory to copy the transaction id bytes to.
+ * @param size
+ * The size of the buffer provided.
+ *
+ * @return the number of bytes copied into the buffer, or -1 if the buffer
+ * provided was not large enough.
+ *
+ * @throws CMSException if the size parameter is less than zero or buffer is NULL.
+ */
+ virtual int getGlobalTransactionId( unsigned char* buffer, int size ) = 0;
+
+ };
+
+}
+
+#endif /* _CMS_XID_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/cms/Xid.h
------------------------------------------------------------------------------
svn:eol-style = native