On 11-12-13 04:18 PM, mck wrote:

For example in AbstractClientRequest you're thinking of replacing

         ContextResolver resolver = 
ApplicationAccess.getContextResolver(applicationContext);
         return resolver.getContext(this, scope);

with what?

I could do it if you want, but the idea is:

- for AbstractClientRequest (i.e. ServletRequest and PortletRequest) there is no wrapping, so: * getContext(scope) just maps the methods getRequestScope(), getSessionScope() and getApplicationScope(). This can be implemented just as easily by hand.
  * getAvailableScopes() simply returns getNativeScopes()!

- for RequestWrapper (i.e. JspRequest, VelocityRequest, FreemarkerRequest):
* getContext(scope) calls the ReflexionContextResolver to map the method getPageScope() and the methods of the wrapped request. This can be implemented as:
     if("page".equals(scope)) return getPageScope();
     else return super.getContext(scope);
* getAvailableScopes() concatenates getNativeScopes() with the getAvailableScopes() of the wrapped request.

It just means you have to either implement getContext(scope) for every view request, or declare an abstract method getPageScope() in an abstract class somewhere (perhaps AbstractViewRequest).

Of course this is true only for ReflexionContextResolver, and we could arguably create a different implementation. But I think the current behaviour and set of scopes are so widely used that they're unlikely to change at any time. Eventually more scopes might appear for new request implementations (if we're interfacing with Seam or Webflow for instance). But between subclassing and wrapping, I believe we have enough flexibility to add as many scopes as we want.

Discussing it makes me realize that, without ContextResolver, we might even be able to remove getNativeScopes(). Applications would want to call getAvailableScopes() anyway.

Perhaps we should also take the opportunity to expand the
package-level javadoc.

Absolutely, but i think you have a better grasp here and can come up
with a far better overview description. I can help flesh out the class
docs then.

OK, I'll do that sometime this week hopefully :)

Nick

Reply via email to