我如何协商将调用哪种post方法?

时间:2015-04-24 11:25:33

标签: api rest jax-rs resteasy

我正在尝试使用不同的方法签名实现Post方法。我怎么能这样做,我试图用MessageBodyReader做它,但它似乎只调用一种类型的postMapper,如果我有一个带有签名ObjectMapper作为参数的post方法。

    @POST
    class SomeResource {
        Response post(ObjectMapper obj){
          ...
        }
       Response post(Document doc) {
          ...
        }
    }

问题是调用MessageBodyReader,但类型总是用于ObjectMapper。有什么想法吗?

我得到的错误是

传递给org.jboss.resteasy.spi.metadata.ResourceMethod@7408b962的错误参数(javax.xml.transform.stream.StreamSource javax.xml.transform.stream.StreamSource@df21c92)

1 个答案:

答案 0 :(得分:0)

我想我已经使用了两个不同的MessageBodyReaders

04-24 12:31:27.463: I/dalvikvm-heap(1136): Grow heap (frag case) to 20.725MB for 4021256-byte allocation
04-24 12:31:28.063: D/dalvikvm(1136): GC_FOR_ALLOC freed 2618K, 34% free 18530K/27816K, paused 536ms, total 536ms
04-24 12:31:28.063: I/dalvikvm-heap(1136): Grow heap (frag case) to 22.003MB for 4021256-byte allocation
04-24 12:31:37.813: D/dalvikvm(1136): GC_FOR_ALLOC freed 2618K, 29% free 19839K/27816K, paused 708ms, total 708ms
04-24 12:31:37.813: I/dalvikvm-heap(1136): Forcing collection of SoftReferences for 6031876-byte allocation
04-24 12:31:38.553: D/dalvikvm(1136): GC_BEFORE_OOM freed 9K, 29% free 19829K/27816K, paused 730ms, total 732ms

    04-24 12:31:38.553: E/dalvikvm-heap(1136): Out of memory on a 6031876-byte allocation.


04-24 08:56:04.143: E/AndroidRuntime(2853): FATAL EXCEPTION: main
04-24 08:56:04.143: E/AndroidRuntime(2853): Process: com.vardhan.android.navigationdrawerexample, PID: 2853
04-24 08:56:04.143: E/AndroidRuntime(2853): java.lang.OutOfMemoryError
04-24 08:56:04.143: E/AndroidRuntime(2853):     at java.util.ArrayList.add(ArrayList.java:118)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at com.vardhan.android.navigationdrawerexample.BillingProductListView$1$13.onClick(BillingProductListView.java:349)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.view.View.performClick(View.java:4438)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.view.View$PerformClick.run(View.java:18422)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.os.Handler.handleCallback(Handler.java:733)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.os.Handler.dispatchMessage(Handler.java:95)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.os.Looper.loop(Looper.java:136)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at java.lang.reflect.Method.invokeNative(Native Method)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at java.lang.reflect.Method.invoke(Method.java:515)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-24 08:56:04.143: E/AndroidRuntime(2853):     at dalvik.system.NativeStart.main(Native Method)