小编rua*_*bua的帖子

Jersey RESTful Web服务gradle设置

我坚持使用jersey库为RESTful Web服务创建gradle项目.项目配置应该能够在jetty应用程序服务器中启动服务.我已经找到了一个资源:https://github.com/ziroby/jetty-gradle-hello-world

我的解决方案的问题是,它使用了过时的球衣版本.我至少需要2版(最新的2.14版).我试图在maven central上搜索新版本,但在版本2中,很多工件名称发生了变化,我无法正确配置它.

编辑:我在项目中并不特别需要Jetty服务器.它可以是任何应用程序服务器,适用于测试和调试我的应用程序.我也在生产中使用码头,所以使用码头会很不错.

编辑 :(通过peeskillet) - 链接代码

建立

apply plugin: 'java'
apply plugin: 'jetty'

repositories {
    mavenCentral()
}
dependencies {
    testCompile 'junit:junit:4.11'
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    testCompile 'com.sun.jersey:jersey-client:1.17.1'
    testCompile 'com.sun.jersey:jersey-core:1.17.1'
    compile 'com.sun.jersey:jersey-core:1.17.1'
    compile 'com.sun.jersey:jersey-server:1.17.1'
    compile 'com.sun.jersey:jersey-servlet:1.17.1'
}
test {
    exclude '**/*IntegrationTest*'
}

task integrationTest(type: Test) {
    include '**/*IntegrationTest*'
    doFirst {
        jettyRun.httpPort = 8080    // Port for test
        jettyRun.daemon = true
        jettyRun.execute()
    }
    doLast {
        jettyStop.stopPort = 8091   // Port for stop signal
        jettyStop.stopKey = 'stopKey'
        jettyStop.execute()
    } …
Run Code Online (Sandbox Code Playgroud)

java rest jersey gradle jersey-2.0

21
推荐指数
1
解决办法
2万
查看次数

在C++中动态创建函数调用

大家好,我希望你帮我解决这个问题:

我目前正在为脚本语言实现一个解释器.该语言需要一个C函数的本机调用接口,比如java有JNI.我的问题是,我想调用原始的C函数而不编写包装函数,它将我的脚本语言的调用堆栈转换为C调用堆栈.这意味着,我需要一种方法,在运行时生成C函数的参数列表.例:

void a(int a, int b) {
    printf("function a called %d", a + b);
}

void b(double a, int b, double c) {
    printf("function b called %f", a * b + c);
}

interpreter.registerNativeFunction("a", a);
interpreter.registerNativeFunction("b", b);
Run Code Online (Sandbox Code Playgroud)

解释器应该能够调用函数,只知道我的脚本语言的函数原型:native void a(int a, int b);native void b(double a, int b, double c);

有没有办法在C++中生成C函数调用堆栈,或者我必须使用汇编程序来完成此任务.汇编程序是一个问题,因为解释器应该几乎可以在任何平台上运行.

编辑:解决方案是使用libffi,一个库,处理许多不同平台和操作系统的调用堆栈创建.libffi也被一些着名的语言实现使用,如cpython和openjdk.

编辑:@MatsPetersson我的代码中有一个方法,我有一个方法:

void CInterpreter::CallNativeFunction(string name, vector<IValue> arguments, IReturnReference ret) {
    // Call here correct native C function.
    // this.nativeFunctions is a map which contains the …
Run Code Online (Sandbox Code Playgroud)

c c++ callstack runtime function

5
推荐指数
1
解决办法
4720
查看次数

标签 统计

c ×1

c++ ×1

callstack ×1

function ×1

gradle ×1

java ×1

jersey ×1

jersey-2.0 ×1

rest ×1

runtime ×1