You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/06/14 03:28:11 UTC
svn commit: r1492924 - in
/subversion/branches/javahl-ra/subversion/bindings/javahl: native/
src/org/apache/subversion/javahl/
Author: brane
Date: Fri Jun 14 01:28:11 2013
New Revision: 1492924
URL: http://svn.apache.org/r1492924
Log:
On the javahl-ra branch:
Refactor the remote session framework so that SVNClient object can create
RemoteSession instances that inherit the SVNClient's configuration.
[in subversion/bindings/javahl/native]
* RemoteSession.h (RemoteSession::open): New; factory method that accepts
parameters as JNI object references, converting them for the constructor.
(RemoteSession::RemoteSession): Change parameters from JNI object
references to native types, so that the constructor can be more easily
called from other native code.
* RemoteSession.cpp (RemoteSession::open): Implement.
(RemoteSession::RemoteSession): Rewrite to new prototype.
Move RA layer initialisation here out of the RemoteFactory JNI wrapper.
* RemoteSessionContext.h (RemoteSessionContext::RemoteSessionContext):
Change constructor to accept native typed parameters instead of
JNI object references.
* RemoteSessionContext.cpp (RemoteSessionContext::RemoteSessionContext):
rewrite to new prototype.
* Prompter.cpp (Prompter::Prompter): Don't leave a member uninitialised.
* org_apache_subversion_javahl_remote_RemoteFactory.cpp
(Java_org_apache_subversion_javahl_remote_RemoteFactory_open):
Call RemoteSession::open instead of constructing the object directly,
and remove the RA layer initialisation since it has moved elsewhere.
* org_apache_subversion_javahl_SVNClient.cpp
(Java_org_apache_subversion_javahl_SVNClient_openRemoteSession):
New; native implementation of SVNClient.openRemoteSession.
[in subversion/bindings/javahl/src/org/apache/subversion/javahl]
* ISVNClient.java, SVNClient.java (ISVNClient.openRemoteSession):
New RemoteSession factory method.
Modified:
subversion/branches/javahl-ra/subversion/bindings/javahl/native/Prompter.cpp
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.cpp
subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.h
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/Prompter.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/Prompter.cpp?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/Prompter.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/Prompter.cpp Fri Jun 14 01:28:11 2013
@@ -40,9 +40,9 @@
* @param jprompter a global reference to the Java callback object
*/
Prompter::Prompter(jobject jprompter)
-{
- m_prompter = jprompter;
-}
+ : m_prompter(jprompter),
+ m_maySave(false)
+{}
Prompter::~Prompter()
{
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.cpp Fri Jun 14 01:28:11 2013
@@ -31,6 +31,8 @@
#include "CreateJ.h"
#include "EnumMapper.h"
+#include "Prompter.h"
+#include "Revision.h"
#include "RemoteSession.h"
#include "svn_private_config.h"
@@ -46,26 +48,78 @@ RemoteSession::getCppObject(jobject jthi
return (cppAddr == 0 ? NULL : reinterpret_cast<RemoteSession *>(cppAddr));
}
-RemoteSession::RemoteSession(jobject *jthis_out, jstring jurl, jstring juuid,
- jstring jconfigDirectory,
- jstring jusername, jstring jpassword,
- jobject jprompter, jobject jprogress)
+RemoteSession*
+RemoteSession::open(jobject* jthis_out, jstring jurl, jstring juuid,
+ jstring jconfigDirectory,
+ jstring jusername, jstring jpassword,
+ jobject jprompter, jobject jprogress)
{
JNIEnv *env = JNIUtil::getEnv();
JNIStringHolder url(jurl);
if (JNIUtil::isExceptionThrown())
- {
- return;
- }
+ return NULL;
+ env->DeleteLocalRef(jurl);
JNIStringHolder uuid(juuid);
if (JNIUtil::isExceptionThrown())
+ return NULL;
+ env->DeleteLocalRef(juuid);
+
+ JNIStringHolder configDirectory(jconfigDirectory);
+ if (JNIUtil::isExceptionThrown())
+ return NULL;
+ env->DeleteLocalRef(jconfigDirectory);
+
+ JNIStringHolder usernameStr(jusername);
+ if (JNIUtil::isExceptionThrown())
+ return NULL;
+ env->DeleteLocalRef(jusername);
+
+ JNIStringHolder passwordStr(jpassword);
+ if (JNIUtil::isExceptionThrown())
+ return NULL;
+ env->DeleteLocalRef(jpassword);
+
+ Prompter *prompter = NULL;
+ if (jprompter != NULL)
{
- return;
+ prompter = Prompter::makeCPrompter(jprompter);
+ if (JNIUtil::isExceptionThrown())
+ return NULL;
+ }
+
+ RemoteSession* session = new RemoteSession(
+ jthis_out, url, uuid, configDirectory,
+ usernameStr, passwordStr, prompter, jprogress);
+ if (JNIUtil::isJavaExceptionThrown())
+ {
+ delete session;
+ delete prompter;
+ session = NULL;
+ }
+ return session;
+}
+
+RemoteSession::RemoteSession(jobject* jthis_out,
+ const char* url, const char* uuid,
+ const char* configDirectory,
+ const char* username, const char* password,
+ Prompter* prompter, jobject jprogress)
+{
+ /*
+ * Initialize ra layer if we have not done so yet
+ */
+ static bool initialized = false;
+ if (!initialized)
+ {
+ SVN_JNI_ERR(svn_ra_initialize(JNIUtil::getPool()), );
+ initialized = true;
}
// Create java session object
+ JNIEnv *env = JNIUtil::getEnv();
+
jclass clazz = env->FindClass(JAVA_CLASS_REMOTE_SESSION);
if (JNIUtil::isJavaExceptionThrown())
return;
@@ -84,11 +138,9 @@ RemoteSession::RemoteSession(jobject *jt
if (JNIUtil::isJavaExceptionThrown())
return;
- *jthis_out = jremoteSession;
-
m_context = new RemoteSessionContext(
- jremoteSession, pool, jconfigDirectory,
- jusername, jpassword, jprompter, jprogress);
+ jremoteSession, pool, configDirectory,
+ username, password, prompter, jprogress);
if (JNIUtil::isJavaExceptionThrown())
return;
@@ -98,6 +150,7 @@ RemoteSession::RemoteSession(jobject *jt
m_context->getCallbackBaton(), m_context->getConfigData(),
pool.getPool()),
);
+ *jthis_out = jremoteSession;
}
RemoteSession::~RemoteSession()
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSession.h Fri Jun 14 01:28:11 2013
@@ -33,11 +33,7 @@
#include "SVNBase.h"
#include "RemoteSessionContext.h"
-#include "Revision.h"
-
-#include <set>
-
-class SVNEditor;
+#include "Prompter.h"
/*
* This class wraps Ra based operations from svn_ra.h
@@ -46,10 +42,15 @@ class RemoteSession : public SVNBase
{
public:
static RemoteSession* getCppObject(jobject jthis);
- RemoteSession(jobject*, jstring jurl, jstring juuid,
- jstring jconfigDirectory,
- jstring jusername, jstring jpassword,
- jobject jprompter, jobject jprogress);
+ static RemoteSession* open(jobject*, jstring jurl, jstring juuid,
+ jstring jconfigDirectory,
+ jstring jusername, jstring jpassword,
+ jobject jprompter, jobject jprogress);
+ RemoteSession(jobject*, const char* url, const char* uuid,
+ const char* configDirectory,
+ const char* username, const char* password,
+ Prompter* prompter, jobject jprogress);
+
~RemoteSession();
jlong getLatestRevision();
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.cpp?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.cpp Fri Jun 14 01:28:11 2013
@@ -32,51 +32,19 @@
#define STRING_RETURN_SIGNATURE "()Ljava/lang/String;"
RemoteSessionContext::RemoteSessionContext(
- jobject contextHolder, SVN::Pool &pool, jstring jconfigDirectory,
- jstring jusername, jstring jpassword, jobject jprompter, jobject jprogress)
+ jobject contextHolder, SVN::Pool &pool, const char* configDirectory,
+ const char* usernameStr, const char* passwordStr,
+ Prompter* prompter, jobject jprogress)
: OperationContext(pool), m_raCallbacks(NULL)
{
- /*
- * Extract config properties
- */
- JNIEnv *env = JNIUtil::getEnv();
-
- JNIStringHolder configDirectory(jconfigDirectory);
- if (JNIUtil::isExceptionThrown())
- return;
-
setConfigDirectory(configDirectory);
- env->DeleteLocalRef(jconfigDirectory);
+ if (usernameStr != NULL)
+ username(usernameStr);
+
+ if (passwordStr != NULL)
+ password(passwordStr);
- if (jusername != NULL)
- {
- JNIStringHolder usernameStr(jusername);
- if (JNIUtil::isExceptionThrown())
- return;
-
- username(usernameStr);
- env->DeleteLocalRef(jusername);
- }
-
- if (jpassword != NULL)
- {
- JNIStringHolder passwordStr(jpassword);
- if (JNIUtil::isExceptionThrown())
- return;
-
- password(passwordStr);
- env->DeleteLocalRef(jpassword);
- }
-
- if (jprompter != NULL)
- {
- Prompter *prompter = Prompter::makeCPrompter(jprompter);
- if (JNIUtil::isExceptionThrown())
- return;
-
- setPrompt(prompter);
- env->DeleteLocalRef(jprompter);
- }
+ setPrompt(prompter);
/*
* Attach session context java object
@@ -89,6 +57,8 @@ RemoteSessionContext::RemoteSessionConte
/*
* Set the progress callback
*/
+ JNIEnv *env = JNIUtil::getEnv();
+
jclass clazz = env->GetObjectClass(m_jctx);
if (JNIUtil::isJavaExceptionThrown())
return;
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.h
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.h?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.h (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/RemoteSessionContext.h Fri Jun 14 01:28:11 2013
@@ -35,15 +35,15 @@ class RemoteSessionContext : public Oper
{
public:
RemoteSessionContext(jobject contextHolder, SVN::Pool &pool,
- jstring jconfigDirectory,
- jstring jusername, jstring jpassword,
- jobject jprompter, jobject jprogress);
+ const char* jconfigDirectory,
+ const char* jusername, const char* jpassword,
+ Prompter* prompter, jobject jprogress);
virtual ~RemoteSessionContext();
void * getCallbackBaton();
- svn_ra_callbacks2_t * getCallbacks();
+ svn_ra_callbacks2_t* getCallbacks();
private:
- svn_ra_callbacks2_t * m_raCallbacks;
+ svn_ra_callbacks2_t* m_raCallbacks;
};
#endif /* JAVAHL_REMOTE_SESSION_CONTEXT_H */
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_SVNClient.cpp Fri Jun 14 01:28:11 2013
@@ -1851,3 +1851,24 @@ Java_org_apache_subversion_javahl_SVNCli
jreverse ? true : false, jignoreWhitespace ? true : false,
jremoveTempfiles ? true : false, &callback);
}
+
+JNIEXPORT jobject JNICALL
+Java_org_apache_subversion_javahl_SVNClient_openRemoteSession
+(JNIEnv *env, jobject jthis, jstring jpath)
+{
+ JNIEntry(SVNClient, openRemoteSession);
+ SVNClient *cl = SVNClient::getCppObject(jthis);
+ if (cl == NULL)
+ {
+ JNIUtil::throwError("bad C++ this");
+ return NULL;
+ }
+
+ // TODO: convert path to URL
+ JNIStringHolder url(jpath);
+ if (JNIUtil::isJavaExceptionThrown())
+ return NULL;
+
+ //return cl->openRemoteSession(url);
+ return NULL;
+}
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/native/org_apache_subversion_javahl_remote_RemoteFactory.cpp Fri Jun 14 01:28:11 2013
@@ -45,24 +45,14 @@ Java_org_apache_subversion_javahl_remote
JNIEntry(Remotefactory, open);
/*
- * Initialize ra layer if we have not done so yet
- */
- static bool initialized = false;
- if (!initialized)
- {
- SVN_JNI_ERR(svn_ra_initialize(JNIUtil::getPool()), NULL);
- initialized = true;
- }
-
- /*
* Create RemoteSession C++ object and return its java wrapper to the caller
*/
jobject jremoteSession = NULL;
- RemoteSession* session = new RemoteSession(
+ RemoteSession* session = RemoteSession::open(
&jremoteSession, jurl, juuid, jconfigDirectory,
jusername, jpassword, jprompter, jprogress);
- if (JNIUtil::isJavaExceptionThrown())
+ if (JNIUtil::isJavaExceptionThrown() || !session)
{
delete session;
return NULL;
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/ISVNClient.java Fri Jun 14 01:28:11 2013
@@ -1145,4 +1145,16 @@ public interface ISVNClient
int stripCount, boolean reverse, boolean ignoreWhitespace,
boolean removeTempfiles, PatchCallback callback)
throws ClientException;
+
+ /**
+ * Open a persistent session to a repository.
+ * @param path A path in a working copy from which the
+ * session URL is derived.
+ * @throws ClientException
+ * @note The session object inherits the progress callback,
+ * configuration directory and authentication info.
+ * @since 1.9
+ */
+ ISVNRemote openRemoteSession(String path)
+ throws ClientException;
}
Modified: subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java?rev=1492924&r1=1492923&r2=1492924&view=diff
==============================================================================
--- subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java (original)
+++ subversion/branches/javahl-ra/subversion/bindings/javahl/src/org/apache/subversion/javahl/SVNClient.java Fri Jun 14 01:28:11 2013
@@ -661,6 +661,9 @@ public class SVNClient implements ISVNCl
PatchCallback callback)
throws ClientException;
+ public native ISVNRemote openRemoteSession(String path)
+ throws ClientException;
+
/**
* A private class to hold the contextual information required to
* persist in this object, such as notification handlers.