2014-03-07 37 views
-1

我想要得到的网状通道做一些@DELETE的功能:RestEasy如何获得Netty频道?

@DELETE

@Path( “/文件/ {PATH}”)

@Produces(“应用/ JSON;字符集= UTF-8" )

公共响应DELETEFILE(

@PathParam("path") String path, 

@QueryParam(value = "access") String access, 

@Context HttpResponse httpResponse) 

{

//i want to get the netty channel to do something. 

}

,但不能得到。 只见RestEasy的的资源代码:

公共对象的invoke(HttpRequest的要求,HttpResponse对象HttpResponse对象,对象资源)抛出故障,ApplicationException的

{

Object[] args = injectArguments(request, httpResponse); 

    GeneralValidator validator = GeneralValidator.class.cast(request.getAttribute(GeneralValidator.class.getName())); 
    if (validator != null) 
    { 
    validator.validateAllParameters(request, resource, method.getMethod(), args); 
    } 

    Method invokedMethod = method.getMethod(); 
    if (!invokedMethod.getDeclaringClass().isAssignableFrom(resource.getClass())) 
    { 
    // invokedMethod is for when the target object might be a proxy and 
    // resteasy is getting the bean class to introspect. 
    // In other words ResourceMethod.getMethod() does not have the same declared class as the proxy: 
    // An example is a proxied Spring bean that is a resource 
    // interface ProxiedInterface { String get(); } 
    // @Path("resource") class MyResource implements ProxiedInterface { 
    //  @GET String get() {...} 
    // } 
    // 
    invokedMethod = interfaceBasedMethod; 
    } 

    Object result = null; 
    try 
    { 
    result = invokedMethod.invoke(resource, args); 
    } 
    catch (IllegalAccessException e) 
    { 
    throw new InternalServerErrorException("Not allowed to reflect on method: " + method.toString(), e); 
    } 

的HttpResponse类HTTPResponse的参数表是一个NettyHttpResponse对象,所以我可以通过它获得通道。
那么我怎样才能获得频道?

回答

0

你不能得到Netty的通道,因为它是一个实现细节

+0

好吧,我修改的HttpResponse的实现细节,因此这个频道的成功,得益于诺曼·毛雷尔。 – zhongcy