This code is wrong if you have caching on and resource is the method and you have more than one method it will fail.