[
https://issues.apache.org/jira/browse/WINK-284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12869620#action_12869620
]
Bryant Luk commented on WINK-284:
---------------------------------
Here's what should be happening in Wink 1.1 (no changes to code). If you're
encountering an exception or something else, can you please post the error?
{quote}1. The wink handlers are executed and set attributes in the message
context
2. The method parameters array is created loading entities, attributes... from
the message context
{quote}
For 2) if the parameter is a @Context FooInterface and there is no
FooInterface attribute on this message context, then a proxy that implements
FooInterface is created and put into the method parameters array. See
org.apache.wink.common.internal.registry.ContextAccessor#getContextFromAccessor.
{quote}
3. The users handlers are executed, and here:
if I want to override one of the default wink attributes, like the
LinkBuilders, I need to hack the searchResult. (PERHAPS IS JUST A CORNER CASE)
{quote}
The above is correct.
{quote}
I can add attributes to the context, with setAttribute, but they won't be ever
in the parameters array, because the array was already created, so I need to
get the messageContext in my resource and use the method getAttribute
{quote}
If the attribute key was an interface, then I don't believe you need to get the
message context. A proxy was created and put into the parameters array (since
the real attribute does not exist yet). When the resource method starts
executing, you should be able to just make the interface method calls to the
FooInterface parameter. The proxy object that is passed into your resource
method will then 1) get the real attribute off the message context, and 2)
invoke the real method on the real attribute.
If you really want to change the way that the handlers are executed, you can
extend to a new DeploymentConfiguration class and override the request user
handler chain like you want. Then, in the RestServlet servlet definition in
your web.xml pass an init-param of "deploymentConfiguration" and the value as
the fully qualified class name. See
org.apache.wink.server.internal.servletRestServlet#createDeploymentConfiguration.
The reason why I'm opposed to changing the handler chain ordering is that you
mainly lose the ability to modify the parameter list which others could be
expecting. Some user handlers could be modifying passed in parameters (for
instance, "correcting" an old request parameter query value with a new valid
one for all resource methods).
> User handlers can't add context attributes to get them in resources invocation
> ------------------------------------------------------------------------------
>
> Key: WINK-284
> URL: https://issues.apache.org/jira/browse/WINK-284
> Project: Wink
> Issue Type: Bug
> Components: Server
> Affects Versions: 1.1
> Reporter: David Calavera
> Attachments: deploymentConfiguration.patch, UserHandlersTest.java
>
>
> The creation of the invocation parameters occurs before executing the user
> handlers, so it's not be able to add context attributes to use in the
> resources later.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.