Esempio n. 1
0
// static method
DbTxn *DbTxn::wrap_DB_TXN(DB_TXN *txn)
{
	DbTxn *wrapped_txn = get_DbTxn(txn);
	// txn may have a valid parent transaction, but here we don't care. 
	// We maintain parent-kid relationship in DbTxn only to make sure 
	// unresolved kids of DbTxn objects are deleted.
	return (wrapped_txn != NULL) ?  wrapped_txn : new DbTxn(txn, NULL);
}
Esempio n. 2
0
JNIEXPORT jobject JNICALL Java_com_sleepycat_db_xa_DbXAResource_xa_1attach
  (JNIEnv *jnienv, jclass jthisclass, jobject jxid, jobject jrmid)
{
	XID xid;
	XID *xidp;
	int ret;
	DB_ENV *env;
	DB_TXN *txn;
	int rmid;
	int *rmidp;
	jobject jtxn;
	jobject jenv;
	jclass cl;
	jmethodID mid;

	COMPQUIET(jthisclass, NULL);
	if (jxid == NULL) {
		xidp = NULL;
	}
	else {
		xidp = &xid;
		if (!get_XID(jnienv, jxid, &xid))
			return (NULL);
	}
	if (jrmid == NULL) {
		rmidp = NULL;
	}
	else {
		rmidp = &rmid;
		rmid = (int)(*jnienv)->CallIntMethod(jnienv, jrmid,
						     mid_Integer_intValue);
	}

	if ((ret = db_env_xa_attach(rmidp, xidp, &env, &txn)) != 0) {
		/*
		 * DB_NOTFOUND is a normal return, it means we
		 * have no current transaction,
		 */
		if (ret != DB_NOTFOUND)
			verify_return(jnienv, ret, 0);
		return (NULL);
	}

	jenv = ((DB_ENV_JAVAINFO *)env->api2_internal)->jenvref;
	jtxn = get_DbTxn(jnienv, txn);
	if ((cl = get_class(jnienv, name_DB_XAATTACH)) == NULL)
		return (NULL);
	mid = (*jnienv)->GetMethodID(jnienv, cl, "<init>",
		     "(Lcom/sleepycat/db/DbEnv;Lcom/sleepycat/db/DbTxn;)V");
	return (*jnienv)->NewObject(jnienv, cl, mid, jenv, jtxn);
}
Esempio n. 3
0
// static method
DbTxn *DbTxn::wrap_DB_TXN(DB_TXN *txn)
{
	DbTxn *wrapped_txn = get_DbTxn(txn);
	return (wrapped_txn != NULL) ?  wrapped_txn : new DbTxn(txn);
}