Ejemplo n.º 1
0
void TestProcess::terminate (void)
{
	DBG_PRINT(("TestProcess::terminate()"));

	JNIEnv*		env		= getCurrentThreadEnv();
	jboolean	res		= env->CallBooleanMethod(m_remote, m_kill);
	checkJniException(env, __FILE__, __LINE__);
	DE_UNREF(res); // Failure to kill process is ignored.
}
Ejemplo n.º 2
0
void TestProcess::start (const char* name, const char* params, const char* workingDir, const char* caseList)
{
	DBG_PRINT(("TestProcess::start(%s, %s, %s, ...)", name, params, workingDir));

	JNIEnv* env			= getCurrentThreadEnv();
	jstring	nameStr		= 0;
	jstring	paramsStr	= 0;
	jstring caseListStr	= 0;

	DE_UNREF(workingDir);

	// Remove old log file if such exists.
	if (deFileExists(LOG_FILE_NAME))
	{
		if (!deDeleteFile(LOG_FILE_NAME) || deFileExists(LOG_FILE_NAME))
			throw xs::TestProcessException(std::string("Failed to remove '") + LOG_FILE_NAME + "'");
	}

	try
	{
		nameStr = env->NewStringUTF(name);
		JNI_CHECK(nameStr);

		paramsStr = env->NewStringUTF(params);
		JNI_CHECK(paramsStr);

		caseListStr = env->NewStringUTF(caseList);
		JNI_CHECK(caseListStr);

		jboolean res = env->CallBooleanMethod(m_remote, m_start, nameStr, paramsStr, caseListStr);
		checkJniException(env, __FILE__, __LINE__);

		if (res == JNI_FALSE)
			throw xs::TestProcessException("Failed to launch activity");

		m_launchTime		= deGetMicroseconds();
		m_lastQueryTime		= m_launchTime;
		m_lastRunningStatus	= true;
	}
	catch (...)
	{
		if (nameStr)
			env->DeleteLocalRef(nameStr);
		if (paramsStr)
			env->DeleteLocalRef(paramsStr);
		if (caseListStr)
			env->DeleteLocalRef(caseListStr);
		throw;
	}

	env->DeleteLocalRef(nameStr);
	env->DeleteLocalRef(paramsStr);
	env->DeleteLocalRef(caseListStr);
}
Ejemplo n.º 3
0
void JniManager::cleanup()
{
    JNIEnv* env = getEnv();

    assert(env);
    env->DeleteGlobalRef(exceptionClazz);

    //typeConverter->cleanup(env);

    checkJniException();
}
Ejemplo n.º 4
0
void JniManager::init()
{
    JNIEnv* env = getEnv();

    assert(env);

    // Exception class
    jclass exceptionClazzTemp = env->FindClass("java/lang/Exception");

    if (exceptionClazzTemp == NULL)
    {
        checkJniException();
    }

    exceptionClazz = (jclass)env->NewGlobalRef(exceptionClazzTemp);

    env->DeleteLocalRef(exceptionClazzTemp);

    checkJniException();
}
Ejemplo n.º 5
0
bool TestProcess::isRunning (void)
{
	deUint64 curTime = deGetMicroseconds();

	// On Android process launch is asynchronous so we don't want to poll for process until after some time.
	if (curTime-m_launchTime < PROCESS_START_TIMEOUT ||
		curTime-m_lastQueryTime < PROCESS_QUERY_INTERVAL)
		return m_lastRunningStatus;

	JNIEnv*		env		= getCurrentThreadEnv();
	jboolean	res		= env->CallBooleanMethod(m_remote, m_isRunning);
	checkJniException(env, __FILE__, __LINE__);

	DBG_PRINT(("TestProcess::isRunning(): %s", res == JNI_TRUE ? "true" : "false"));
	m_lastQueryTime		= curTime;
	m_lastRunningStatus	= res == JNI_TRUE;

	return m_lastRunningStatus;
}
Ejemplo n.º 6
0
void JniManager::init()
{
    JNIEnv* env = getEnv();

    assert(env);

    typeConverter = new TypeConverter();
    typeConverter->init(env);

    // Exception class
    jclass exceptionClazzTemp = env->FindClass("java/lang/Exception");

    if (exceptionClazzTemp == NULL)
    {
            checkJniException();
    }

    exceptionClazz = (jclass)env->NewGlobalRef(exceptionClazzTemp);

    env->DeleteLocalRef(exceptionClazzTemp);
    /*
    // org/mule/api/jniRouter
    jclass routerClazzTmp = env->FindClass("org/mule/api/jni/Bridge");

    checkJniException();

    logMethod = env->GetMethodID(routerClazzTmp, "log", "(Ljava/lang/String;)V");

    checkJniException();

    instrumentMethod = env->GetMethodID(routerClazzTmp, "instrument", "(Ljava/lang/String;I)V");

    checkJniException();

    env->DeleteLocalRef(routerClazzTmp);
    */
    // org/mule/api/jni/Response
    jclass responseClazzTmp = env->FindClass("org/mule/api/jni/Response");

    checkJniException();

    responseClazz = (jclass)env->NewGlobalRef(responseClazzTmp);
    env->DeleteLocalRef(responseClazzTmp);

    responseCtor = env->GetMethodID(responseClazz, "<init>", "()V");

    checkJniException();

    setPayloadMethod = env->GetMethodID(responseClazz, "setPayload", "(Ljava/lang/Object;)V");

    checkJniException();

    setInvocationProperties = env->GetMethodID(responseClazz, "setInvocationProperties", "(Ljava/util/Map;)V");

    checkJniException();

    setSessionProperties = env->GetMethodID(responseClazz, "setSessionProperties", "(Ljava/util/Map;)V");

    checkJniException();

    setOutboundProperties = env->GetMethodID(responseClazz, "setOutboundProperties", "(Ljava/util/Map;)V");

    checkJniException();

    // org/mule/api/jni/Request

    jclass processRequestClazz = env->FindClass("org/mule/api/jni/Request");

    checkJniException();

    getAssemblyName = env->GetMethodID(processRequestClazz, "getAssemblyName", "()Ljava/lang/String;");

    checkJniException();

    getAssemblyPath = env->GetMethodID(processRequestClazz, "getAssemblyPath", "()Ljava/lang/String;");

    checkJniException();

    getMethodName = env->GetMethodID(processRequestClazz, "getMethodName", "()Ljava/lang/String;");

    checkJniException();

    getLog = env->GetMethodID(processRequestClazz, "getLog", "()Z");

    checkJniException();

    getNotifyEvents = env->GetMethodID(processRequestClazz, "getNotifyEvents", "()Z");

    checkJniException();

    getFullTrust = env->GetMethodID(processRequestClazz, "getFullTrust", "()Z");

    checkJniException();

    getIsSingleton = env->GetMethodID(processRequestClazz, "getIsSingleton", "()Z");

    checkJniException();

    getInboundProperties = env->GetMethodID(processRequestClazz, "getInboundProperties", "()Ljava/util/Map;");

    checkJniException();

    getMethodArguments = env->GetMethodID(processRequestClazz, "getMethodArguments", "()Ljava/util/Map;");

    checkJniException();

    getInvocationProperties = env->GetMethodID(processRequestClazz, "getInvocationProperties", "()Ljava/util/Map;");

    checkJniException();

    getSessionProperties = env->GetMethodID(processRequestClazz, "getSessionProperties", "()Ljava/util/Map;");

    checkJniException();

    getOutboundProperties = env->GetMethodID(processRequestClazz, "getOutboundProperties", "()Ljava/util/Map;");

    checkJniException();
}