Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
efcd5656
提交
efcd5656
authored
11月 01, 2012
作者:
Brian West
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-4743 --resolve
上级
b4502078
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
35 行增加
和
15 行删除
+35
-15
modjava.c
src/mod/languages/mod_java/modjava.c
+35
-15
没有找到文件。
src/mod/languages/mod_java/modjava.c
浏览文件 @
efcd5656
...
...
@@ -38,7 +38,7 @@ static switch_memory_pool_t *memoryPool = NULL;
static
switch_dso_handle_t
*
javaVMHandle
=
NULL
;
JavaVM
*
javaVM
=
NULL
;
jclass
launcherClass
=
NULL
;
SWITCH_MODULE_LOAD_FUNCTION
(
mod_java_load
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_java_shutdown
);
...
...
@@ -62,19 +62,16 @@ static vm_control_t vmControl;
static
void
launch_java
(
switch_core_session_t
*
session
,
const
char
*
data
,
JNIEnv
*
env
)
{
jclass
Launcher
=
NULL
;
jmethodID
launch
=
NULL
;
jstring
uuid
=
NULL
;
jstring
args
=
NULL
;
Launcher
=
(
*
env
)
->
FindClass
(
env
,
"org/freeswitch/Launcher"
);
if
(
Launcher
==
NULL
)
if
(
launcherClass
==
NULL
)
{
(
*
env
)
->
ExceptionDescribe
(
env
);
goto
done
;
}
launch
=
(
*
env
)
->
GetStaticMethodID
(
env
,
Launcher
,
"launch"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
launch
=
(
*
env
)
->
GetStaticMethodID
(
env
,
launcherClass
,
"launch"
,
"(Ljava/lang/String;Ljava/lang/String;)V"
);
if
(
launch
==
NULL
)
{
(
*
env
)
->
ExceptionDescribe
(
env
);
...
...
@@ -95,7 +92,7 @@ static void launch_java(switch_core_session_t *session, const char *data, JNIEnv
goto
done
;
}
(
*
env
)
->
CallStaticVoidMethod
(
env
,
Launcher
,
launch
,
uuid
,
args
);
(
*
env
)
->
CallStaticVoidMethod
(
env
,
launcherClass
,
launch
,
uuid
,
args
);
if
((
*
env
)
->
ExceptionOccurred
(
env
))
(
*
env
)
->
ExceptionDescribe
(
env
);
...
...
@@ -104,8 +101,6 @@ done:
(
*
env
)
->
DeleteLocalRef
(
env
,
args
);
if
(
uuid
!=
NULL
)
(
*
env
)
->
DeleteLocalRef
(
env
,
uuid
);
if
(
Launcher
!=
NULL
)
(
*
env
)
->
DeleteLocalRef
(
env
,
Launcher
);
}
static
switch_status_t
exec_user_method
(
user_method_t
*
userMethod
)
{
...
...
@@ -145,6 +140,7 @@ static switch_status_t exec_user_method(user_method_t * userMethod) {
goto
done
;
}
if
(
userMethod
->
arg
!=
NULL
)
{
arg
=
(
*
env
)
->
NewStringUTF
(
env
,
userMethod
->
arg
);
if
(
arg
==
NULL
)
{
...
...
@@ -152,6 +148,7 @@ static switch_status_t exec_user_method(user_method_t * userMethod) {
status
=
SWITCH_STATUS_FALSE
;
goto
done
;
}
}
(
*
env
)
->
CallStaticVoidMethod
(
env
,
class
,
method
,
arg
);
...
...
@@ -311,9 +308,32 @@ static switch_status_t create_java_vm(JavaVMOption *options, int optionCount, vm
res
=
pJNI_CreateJavaVM
(
&
javaVM
,
(
void
*
)
&
env
,
&
initArgs
);
if
(
res
==
JNI_OK
)
{
(
*
javaVM
)
->
DetachCurrentThread
(
javaVM
);
// call FindClass here already so that the Java VM executes the static
// initializer (@see org.freeswitch.Launcher) which loads the jni library
// so we can use jni functions right away (for example in the startup method)
launcherClass
=
(
*
env
)
->
FindClass
(
env
,
"org/freeswitch/Launcher"
);
if
(
launcherClass
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unable to find 'org.freeswitch.Launcher' class!
\n
"
);
(
*
env
)
->
ExceptionDescribe
(
env
);
status
=
SWITCH_STATUS_FALSE
;
}
// store a global reference for use in the launch_java() function
launcherClass
=
(
*
env
)
->
NewGlobalRef
(
env
,
launcherClass
);
if
(
launcherClass
==
NULL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Out of memory!
\n
"
);
(
*
env
)
->
ExceptionDescribe
(
env
);
status
=
SWITCH_STATUS_FALSE
;
}
else
{
status
=
SWITCH_STATUS_SUCCESS
;
}
(
*
javaVM
)
->
DetachCurrentThread
(
javaVM
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Error creating Java VM!
\n
"
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论