You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/12/16 13:33:44 UTC
svn commit: r891215 - in /commons/sandbox/runtime/trunk/src/main/native:
Makefile.msc.in os/win32/dtc.cpp
Author: mturk
Date: Wed Dec 16 12:33:44 2009
New Revision: 891215
URL: http://svn.apache.org/viewvc?rev=891215&view=rev
Log:
Add Distributed Transactions stub
Added:
commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=891215&r1=891214&r2=891215&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Wed Dec 16 12:33:44 2009
@@ -116,6 +116,7 @@
$(SRCDIR)/os/win32/dhtml.$(OBJ) \
$(SRCDIR)/os/win32/dir.$(OBJ) \
$(SRCDIR)/os/win32/dirent.$(OBJ) \
+ $(SRCDIR)/os/win32/dtc.$(OBJ) \
$(SRCDIR)/os/win32/dso.$(OBJ) \
$(SRCDIR)/os/win32/env.$(OBJ) \
$(SRCDIR)/os/win32/exec.$(OBJ) \
Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp?rev=891215&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp Wed Dec 16 12:33:44 2009
@@ -0,0 +1,136 @@
+/* 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 "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_arch_service.h"
+#include "acr_clazz.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_tlsd.h"
+#include "acr_vm.h"
+
+#include <comdef.h>
+#include <xolehlp.h>
+#include <txdtc.h>
+#include <transact.h>
+
+#pragma comment(lib, "xaswitch.lib")
+#pragma comment(lib, "xolehlp.lib")
+
+typedef struct dtc_transaction_t {
+ ITransaction *pITransaction;
+ HANDLE hTransactionHandle;
+} dtc_transaction_t;
+
+static HRESULT CreateTransaction(ITransaction** ppITransaction)
+{
+ HRESULT hr = E_FAIL;
+ ITransactionDispenser* pITransactionDispenser = NULL;
+ ITransaction* pITransaction = NULL;
+
+ hr = DtcGetTransactionManagerExW(
+ NULL,
+ NULL,
+ IID_ITransactionDispenser,
+ OLE_TM_FLAG_NONE,
+ NULL,
+ (void**) &pITransactionDispenser);
+ if (FAILED(hr)) {
+ // Getting a transaction dispenser object failed.
+ goto cleanup;
+ }
+
+ // Set the transaction isolation level to ISOLATIONLEVEL_READCOMMITTED,
+ // since this is the isolation level supported by the transactional file system.
+ hr = pITransactionDispenser->BeginTransaction(
+ NULL,
+ ISOLATIONLEVEL_READCOMMITTED,
+ ISOFLAG_RETAIN_NONE,
+ NULL,
+ &pITransaction);
+ if (FAILED(hr)) {
+ goto cleanup;
+ }
+
+ *ppITransaction = pITransaction;
+
+cleanup:
+
+ if(pITransactionDispenser) {
+ pITransactionDispenser->Release();
+ pITransactionDispenser = NULL;
+ }
+
+ return hr;
+}
+
+static HRESULT GetKernelTransactionHandle(ITransaction* pITransaction,
+ HANDLE* pTransactionHandle)
+{
+ HRESULT hr = E_FAIL;
+ IKernelTransaction* pKernelTransaction = NULL;
+ HANDLE hTransactionHandle = INVALID_HANDLE_VALUE;
+
+ // Query for IKernelTransaction interface for a handle to use with
+ // transacted file operation
+ hr = pITransaction->QueryInterface(IID_IKernelTransaction,
+ (void**) &pKernelTransaction);
+ if (FAILED(hr)) {
+ // QueryInterface for IKernelTransaction failed
+ goto cleanup;
+ }
+ hr = pKernelTransaction->GetHandle(&hTransactionHandle);
+ if (FAILED(hr)) {
+ // GetHandle call on IKernelTransaction failed
+ goto cleanup;
+ }
+
+ *pTransactionHandle = hTransactionHandle;
+
+cleanup:
+ if(pKernelTransaction) {
+ pKernelTransaction->Release();
+ pKernelTransaction = NULL;
+ }
+
+ return hr;
+}
+
+extern "C"
+void *dtc_create_transaction(JNIEnv *_E)
+{
+ dtc_transaction_t *ts = NULL;
+ HRESULT hres;
+
+ if (!(ts = ACR_CALLOC(dtc_transaction_t, 1))) {
+ return NULL;
+ }
+
+ hres = CreateTransaction(&ts->pITransaction);
+ if (FAILED(hres)) {
+ ACR_THROW_EX_IF_ERR(ACR_EX_OSERR, hres);
+ goto cleanup;
+ }
+
+
+ return ts;
+cleanup:
+ x_free(ts);
+ return NULL;
+}
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/dtc.cpp
------------------------------------------------------------------------------
svn:eol-style = native