diff --git a/xflaim/java/jni/jbackup.cpp b/xflaim/java/jni/jbackup.cpp
index f7d5bb7..b9c4c2e 100644
--- a/xflaim/java/jni/jbackup.cpp
+++ b/xflaim/java/jni/jbackup.cpp
@@ -26,8 +26,40 @@
#include "jniftk.h"
#include "xflaim_Backup.h"
-#define THIS_BACKUP() \
- ((IF_Backup *)(FLMUINT)lThis)
+#define THIS_BACKUP() ((IF_Backup *)(FLMUINT)lThis)
+
+/****************************************************************************
+Desc:
+****************************************************************************/
+JNIEXPORT void JNICALL Java_xflaim_Backup__1release(
+ JNIEnv *, // pEnv,
+ jobject, // obj,
+ jlong lThis)
+{
+ THIS_BACKUP()->Release();
+}
+
+/****************************************************************************
+Desc:
+****************************************************************************/
+JNIEXPORT jlong JNICALL Java_xflaim_Backup__1getBackupTransId(
+ JNIEnv *, // pEnv,
+ jobject, // obj,
+ jlong lThis)
+{
+ return( THIS_BACKUP()->getBackupTransId());
+}
+
+/****************************************************************************
+Desc:
+****************************************************************************/
+JNIEXPORT jlong JNICALL Java_xflaim_Backup__1getLastBackupTransId(
+ JNIEnv *, // pEnv,
+ jobject, // obj,
+ jlong lThis)
+{
+ return( THIS_BACKUP()->getLastBackupTransId());
+}
/****************************************************************************
Desc:
@@ -222,42 +254,44 @@ JNIEXPORT jlong JNICALL Java_xflaim_Backup__1backup(
jlong lThis,
jstring sBackupPath,
jstring sPassword,
- jobject Client,
- jobject Status)
+ jobject backupClient,
+ jobject backupStatus)
{
RCODE rc = NE_XFLM_OK;
IF_Backup * pBackup = THIS_BACKUP();
FLMUINT uiSeqNum = 0;
JavaVM * pJvm;
- char * pszBackupPath = NULL;
- char * pszPassword = NULL;
JNIBackupClient * pClient;
JNIBackupStatus * pStatus = NULL;
-
+ FLMBYTE ucBackupPath [F_PATH_MAX_SIZE];
+ F_DynaBuf backupPathBuf( ucBackupPath, sizeof( ucBackupPath));
+ FLMBYTE ucPassword [100];
+ F_DynaBuf passwordBuf( ucPassword, sizeof( ucPassword));
- flmAssert( Client);
+ if (RC_BAD( rc = getUTF8String( pEnv, sBackupPath, &backupPathBuf)))
+ {
+ ThrowError( rc, pEnv);
+ goto Exit;
+ }
+ if (RC_BAD( rc = getUTF8String( pEnv, sPassword, &passwordBuf)))
+ {
+ ThrowError( rc, pEnv);
+ goto Exit;
+ }
+
+ flmAssert( backupClient);
pEnv->GetJavaVM( &pJvm);
- if( (pClient = f_new JNIBackupClient( Client, pJvm)) == NULL)
+ if( (pClient = f_new JNIBackupClient( backupClient, pJvm)) == NULL)
{
rc = RC_SET( NE_XFLM_MEM);
ThrowError( rc, pEnv);
goto Exit;
}
- if (sBackupPath)
+ if (backupStatus)
{
- pszBackupPath = (char *)pEnv->GetStringUTFChars( sBackupPath, NULL);
- }
-
- if (sPassword)
- {
- pszPassword = (char *)pEnv->GetStringUTFChars( sPassword, NULL);
- }
-
- if (Status)
- {
- if( (pStatus = f_new JNIBackupStatus( Status, pJvm)) == NULL)
+ if( (pStatus = f_new JNIBackupStatus( backupStatus, pJvm)) == NULL)
{
rc = RC_SET( NE_XFLM_MEM);
ThrowError( rc, pEnv);
@@ -265,8 +299,14 @@ JNIEXPORT jlong JNICALL Java_xflaim_Backup__1backup(
}
}
- if (RC_BAD( rc = pBackup->backup( pszBackupPath, pszPassword, pClient,
- pStatus, &uiSeqNum)))
+ if (RC_BAD( rc = pBackup->backup(
+ (const char *)(backupPathBuf.getDataLength() > 1
+ ? (const char *)backupPathBuf.getBufferPtr()
+ : (const char *)NULL),
+ (const char *)(passwordBuf.getDataLength() > 1
+ ? (const char *)passwordBuf.getBufferPtr()
+ : (const char *)NULL),
+ pClient, pStatus, &uiSeqNum)))
{
ThrowError( rc, pEnv);
goto Exit;
@@ -274,16 +314,6 @@ JNIEXPORT jlong JNICALL Java_xflaim_Backup__1backup(
Exit:
- if( pszBackupPath)
- {
- pEnv->ReleaseStringUTFChars( sBackupPath, pszBackupPath);
- }
-
- if( pszPassword)
- {
- pEnv->ReleaseStringUTFChars( sPassword, pszPassword);
- }
-
if (pClient)
{
pClient->Release();
@@ -319,35 +349,3 @@ Exit:
return;
}
-/****************************************************************************
-Desc:
-****************************************************************************/
-JNIEXPORT jlong JNICALL Java_xflaim_Backup__1getBackupTransId(
- JNIEnv *, // pEnv,
- jobject, // obj,
- jlong lThis)
-{
- return( THIS_BACKUP()->getBackupTransId());
-}
-
-/****************************************************************************
-Desc:
-****************************************************************************/
-JNIEXPORT jlong JNICALL Java_xflaim_Backup__1getLastBackupTransId(
- JNIEnv *, // pEnv,
- jobject, // obj,
- jlong lThis)
-{
- return( THIS_BACKUP()->getLastBackupTransId());
-}
-
-/****************************************************************************
-Desc:
-****************************************************************************/
-JNIEXPORT void JNICALL Java_xflaim_Backup__1release(
- JNIEnv *, // pEnv,
- jobject, // obj,
- jlong lThis)
-{
- THIS_BACKUP()->Release();
-}
diff --git a/xflaim/java/jni/xflaim_Backup.h b/xflaim/java/jni/xflaim_Backup.h
index fdb774a..18feaf2 100644
--- a/xflaim/java/jni/xflaim_Backup.h
+++ b/xflaim/java/jni/xflaim_Backup.h
@@ -9,18 +9,10 @@ extern "C" {
#endif
/*
* Class: xflaim_Backup
- * Method: _backup
- * Signature: (JLjava/lang/String;Ljava/lang/String;Lxflaim/BackupClient;Lxflaim/BackupStatus;)J
- */
-JNIEXPORT jlong JNICALL Java_xflaim_Backup__1backup
- (JNIEnv *, jobject, jlong, jstring, jstring, jobject, jobject);
-
-/*
- * Class: xflaim_Backup
- * Method: _endBackup
+ * Method: _release
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_xflaim_Backup__1endBackup
+JNIEXPORT void JNICALL Java_xflaim_Backup__1release
(JNIEnv *, jobject, jlong);
/*
@@ -41,10 +33,18 @@ JNIEXPORT jlong JNICALL Java_xflaim_Backup__1getLastBackupTransId
/*
* Class: xflaim_Backup
- * Method: _release
+ * Method: _backup
+ * Signature: (JLjava/lang/String;Ljava/lang/String;Lxflaim/BackupClient;Lxflaim/BackupStatus;)J
+ */
+JNIEXPORT jlong JNICALL Java_xflaim_Backup__1backup
+ (JNIEnv *, jobject, jlong, jstring, jstring, jobject, jobject);
+
+/*
+ * Class: xflaim_Backup
+ * Method: _endBackup
* Signature: (J)V
*/
-JNIEXPORT void JNICALL Java_xflaim_Backup__1release
+JNIEXPORT void JNICALL Java_xflaim_Backup__1endBackup
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
diff --git a/xflaim/java/xflaim/Backup.java b/xflaim/java/xflaim/Backup.java
index 5f71254..cb867b2 100644
--- a/xflaim/java/xflaim/Backup.java
+++ b/xflaim/java/xflaim/Backup.java
@@ -59,7 +59,7 @@ public class Backup
}
/**
- * Get the transaction ID for this backup operation
+ * Get the transaction ID for this backup operation.
* @return Returns the transaction ID for this backup operation.
*/
public long getBackupTransId()
@@ -69,8 +69,8 @@ public class Backup
/**
* Gets the transaction ID for the last backup job run on this database.
- * @return returns the transaction ID for the last backup job run on this
- * database.
+ * @return Returns the transaction ID for the last backup job run on the
+ * database associated with this Backup object.
*/
public long getLastBackupTransId()
{
@@ -79,16 +79,16 @@ public class Backup
/**
* Performs the backup operation. sBackupPath and
- * Client are mutually exclusive. If Client is null,
+ * backupClient are mutually exclusive. If backupClient is null,
* then an instance of DefaultBackupClient will be created
* and sBackupPath passed into its constructor. If
* Client is non-null, sBackupPath is ignored.
* @param sBackupPath Optional. The full pathname of a file to store the
* backed up data.
- * @param Client Optional. If non-null, then it will be used as the backup
+ * @param backupClient Optional. If non-null, then it will be used as the backup
* client.
- * @param Status Optional. If non-null, then Status.backupStatus
- * will be called periodicly to inform the application about the
+ * @param backupStatus Optional. If non-null, then backupStatus.backupStatus
+ * will be called periodically to inform the application about the
* progress of the backup operation.
* @return Returns the sequence number of this backup. (This is for
* informational purposes only; for instance, users can use it to label
@@ -98,16 +98,16 @@ public class Backup
public long backup(
String sBackupPath,
String sPassword,
- BackupClient Client,
- BackupStatus Status) throws XFlaimException
+ BackupClient backupClient,
+ BackupStatus backupStatus) throws XFlaimException
{
- BackupClient BackupClient;
+ BackupClient backClient;
- if (Client == null)
+ if (backupClient == null)
{
try
{
- BackupClient = new DefaultBackupClient( sBackupPath);
+ backClient = new DefaultBackupClient( sBackupPath);
}
catch (FileNotFoundException e)
{
@@ -118,14 +118,15 @@ public class Backup
}
else
{
- BackupClient = Client;
+ backClient = backupClient;
}
- return _backup( m_this, sBackupPath, sPassword, BackupClient, Status);
+ return _backup( m_this, sBackupPath, sPassword, backClient, backupStatus);
}
/**
- * Desc:
+ * Ends the backup operation.
+ * @throws XFlaimException
*/
public void endBackup() throws XFlaimException
{
@@ -148,17 +149,22 @@ public class Backup
m_jdb = jdb;
}
- /**
- * Desc:
- */
long getRef()
{
return m_this;
}
- /**
- * Desc:
- */
+// PRIVATE METHODS
+
+ private native void _release(
+ long lThis);
+
+ private native long _getBackupTransId(
+ long lThis);
+
+ private native long _getLastBackupTransId(
+ long lThis);
+
private native long _backup(
long lThis,
String sBackupPath,
@@ -166,30 +172,10 @@ public class Backup
BackupClient Client,
BackupStatus Status) throws XFlaimException;
- /**
- * Desc:
- */
private native void _endBackup(
long lThis) throws XFlaimException;
- /**
- * Desc:
- */
- private native long _getBackupTransId(
- long lThis);
-
- /**
- * Desc:
- */
- private native long _getLastBackupTransId(
- long lThis);
-
- /**
- * Desc:
- */
- private native void _release(
- long lThis);
-
private long m_this;
private Db m_jdb;
}
+