3
* ====================================================================
4
* Copyright (c) 2003 CollabNet. All rights reserved.
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
18
* @file MessageReceiver.cpp
19
* @brief Implementation of the class MessageReceiver
22
#include "MessageReceiver.h"
25
* create a new object and store the local reference to the java object
27
MessageReceiver::MessageReceiver(jobject jthis)
34
MessageReceiver::~MessageReceiver()
36
// the m_callback does not need to be destroyed, because it is the passed
37
// in parameter to the java method.
40
* send a message to the java object
41
* @param message the message to be send
43
void MessageReceiver::receiveMessage(const char *message)
45
JNIEnv *env = JNIUtil::getEnv();
46
static jmethodID mid = 0; // the method id will not change during
47
// the time this library is loaded, so
51
jclass clazz = env->FindClass(JAVA_PACKAGE"/SVNAdmin$MessageReceiver");
52
if(JNIUtil::isJavaExceptionThrown())
56
mid = env->GetMethodID(clazz, "receiveMessageLine",
57
"(Ljava/lang/String;)V");
58
if(JNIUtil::isJavaExceptionThrown() || mid == 0)
62
env->DeleteLocalRef(clazz);
63
if(JNIUtil::isJavaExceptionThrown())
68
// convert the message to a java string
69
jstring jmsg = JNIUtil::makeJString(message);
70
if(JNIUtil::isJavaExceptionThrown())
75
// call the java method
76
env->CallVoidMethod(m_jthis, mid);
77
if(JNIUtil::isJavaExceptionThrown())
82
// delete the java string
83
env->DeleteLocalRef(jmsg);
84
if(JNIUtil::isJavaExceptionThrown())