request.h
上传用户:xfwatch
上传日期:2020-12-14
资源大小:872k
文件大小:4k
源码类别:

中间件编程

开发平台:

Java

  1. /*
  2.  * JBoss, Home of Professional Open Source
  3.  * Copyright 2009, Red Hat, Inc., and others contributors as indicated
  4.  * by the @authors tag. All rights reserved.
  5.  * See the copyright.txt in the distribution for a
  6.  * full listing of individual contributors.
  7.  * This copyrighted material is made available to anyone wishing to use,
  8.  * modify, copy, or redistribute it subject to the terms and conditions
  9.  * of the GNU Lesser General Public License, v. 2.1.
  10.  * This program is distributed in the hope that it will be useful, but WITHOUT A
  11.  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  12.  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  13.  * You should have received a copy of the GNU Lesser General Public License,
  14.  * v.2.1 along with this distribution; if not, write to the Free Software
  15.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16.  * MA  02110-1301, USA.
  17.  */
  18. #ifndef __REQUEST_H
  19. #define __REQUEST_H
  20. #include "atmiBrokerCoreMacro.h"
  21. #include "userlogc.h"
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <userlogc.h>
  26. #include <xatmi.h>
  27. #include <tx.h>
  28. #ifdef UNITTEST
  29. static const char * const TXTEST_SVC_NAME = "tpcall_x_octet";
  30. #else
  31. static const char * const TXTEST_SVC_NAME = "BAR";
  32. #endif
  33. enum TX_TYPE {
  34. TX_TYPE_NONE = 0x0,
  35. TX_TYPE_BEGIN = 0x1,
  36. TX_TYPE_COMMIT = 0x2,
  37. TX_TYPE_ABORT = 0x4,
  38. TX_TYPE_HALT = 0x8,
  39. TX_TYPE_PREPARE = 0x10,
  40. TX_TYPE_BEGIN_COMMIT = (TX_TYPE_BEGIN | TX_TYPE_COMMIT),
  41. TX_TYPE_BEGIN_ABORT = (TX_TYPE_BEGIN | TX_TYPE_ABORT),
  42. TX_TYPE_END = (TX_TYPE_COMMIT | TX_TYPE_ABORT),
  43. TX_TYPE_BEGIN_COMMIT_HALT =  (TX_TYPE_BEGIN | TX_TYPE_COMMIT | TX_TYPE_HALT),
  44. TX_TYPE_BEGIN_PREPARE_HALT = (TX_TYPE_BEGIN | TX_TYPE_PREPARE | TX_TYPE_COMMIT | TX_TYPE_HALT),
  45. };
  46. typedef struct BLACKTIE_XATMI_DLL test_req {
  47. char db[16];
  48. char data[80];
  49. char op;
  50. int  id; // request id
  51. int  expect; // for testing null products (ie force success)
  52. int  prod;
  53. int txtype; //enum TX_TYPE
  54. int status;
  55. } test_req_t;
  56. #ifndef ORACLE
  57. #define ora_access null_access
  58. #define ora_xaflags null_xaflags
  59. #endif
  60. #ifndef DB2
  61. #define db2_access null_access
  62. #define db2_xaflags null_xaflags
  63. #endif
  64. /*
  65.  * some RMs do not allow mixed access - in fact Berkeley Db doesn't even support
  66.  * 2 dbs in different files one accessed remotely and the other locally
  67.  */
  68. #define REMOTE_ACCESS   0x1
  69. #define LOCAL_ACCESS    0x2
  70. #define ANY_ACCESS  (REMOTE_ACCESS | LOCAL_ACCESS)
  71. typedef struct BLACKTIE_XATMI_DLL product {
  72.     int id; /* id for the product (used by servers to index into products) */
  73.     const char *pname;  /* a name for the product configuration */
  74.     const char *dbname; /* identifies the database */
  75.     int loc;    /* bitmap indicating what kind of access is allowed */
  76.     int (*access)(test_req_t *, test_req_t *);  // function for doing CRUD operations
  77.     long (*xaflags)();  // function to return the flags supported by the Resource Manager
  78. } product_t;
  79. extern product_t products[];
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83. #ifdef WIN32
  84. extern __declspec(dllimport) struct xa_switch_t db_xa_switch;
  85. #endif
  86. /* common methods */
  87. extern int fatal(const char *msg);
  88. extern int fail(const char *reason, int ret);
  89. extern test_req_t * get_buf(int remote, const char *data, const char *dbfile, char op, int prod, enum TX_TYPE txtype, int expect);
  90. extern void free_buf(int remote, test_req_t *req);
  91. /* helper methods for controling transactions */
  92. extern  int is_begin(enum TX_TYPE txtype);
  93. extern int is_commit(enum TX_TYPE txtype);
  94. extern int is_abort(enum TX_TYPE txtype);
  95. extern int start_tx(enum TX_TYPE txtype);
  96. extern int end_tx(enum TX_TYPE txtype);
  97. extern int null_access(test_req_t *req, test_req_t *resp);
  98. extern int ora_access(test_req_t *req, test_req_t *resp);
  99. extern int db2_access(test_req_t *req, test_req_t *resp);
  100. extern int is_tx_in_state(enum TX_TYPE txtype);
  101. extern int get_tx_status();
  102. extern long null_xaflags();
  103. extern long ora_xaflags();
  104. extern long db2_xaflags();
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* __REQUEST_H */