我想让netty频道在@DELETE函数中执行某些操作:
@DELETE
@Path( “/文件/ {路径}”)
@Produces( “应用程序/ JSON;字符集= UTF-8”)
public Response deleteFile(
@PathParam("path") String path,
@QueryParam(value = "access") String access,
@Context HttpResponse httpResponse)
{
//i want to get the netty channel to do something.
}
但无法得到。 我看到了RestEasy的资源代码:
public Object invoke(HttpRequest request,HttpResponse httpResponse,Object resource)抛出Failure,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的args是一个NettyHttpResponse对象,所以我可以通过它得到频道。
那么我怎样才能获得频道?
答案 0 :(得分:0)
您无法获取Netty频道,因为它是一个实施细节