You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Bartlett <sb...@versata.com.au> on 2002/06/05 07:14:14 UTC
[JXPATH] best approch for customization
Hi, all,
I have a question regarding the best approach for customizing JXPath. I
looked at providing a NodePointer implementation but was not convinced this
was the right course and also deterred by the large interface.
I like what JXPath provides out-of-the-box with regards to JavaBean support,
but instead of allowing clients unvetted access to the whole of my API I
would prefer to restrict access.
The initial idea was to provide a new JXPathIntospector implementation that
hands off to a 'GuardHandler' if the context object implements a well-known
tag interface, otherwise it would follow the normal JavaBean resolution.
The 'GuardHandler' (implemtation of DynamicPropertyHandler) guards against
using any methods not defined for the given bean.
I then realised the JXPathIntrospector is not configurable which lead me to
the NodePointer. I'm now wondering the best approach. Any guidance would be
much appreciated.
cheers,
steve.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [JXPATH] best approch for customization
Posted by Dmitri Plotnikov <dm...@apache.org>.
Steve,
You don't actually need to implement NodePointer. All you need to implement
is a NodePointerFactory, which is a very simple interface.
Try the following:
1. Create a class implementing NodePointerFactory. In the
createNodePointer() methods (two implementations are required) check for the
token interface.
2. If the object passed to the factory implements the token interface,
return a DynamicPointer a la DynamicPointerFactory
3. If the object does not implement the token interface, return null -
that'll let other factories to do their usual job.
4. Very importantly, make the getOrder() method return a number that is less
than BeanPointerFactory.BEAN_POINTER_FACTORY_ORDER, so it would take
precedence over that one.
5. Register the new factory with JXPathContextReferenceImpl
I hope this helps.
- Dmitri
----- Original Message -----
From: "Stephen Bartlett" <sb...@versata.com.au>
To: "Jakarta Commons Developers List (E-mail)"
<co...@jakarta.apache.org>
Sent: Wednesday, June 05, 2002 1:14 AM
Subject: [JXPATH] best approch for customization
> Hi, all,
>
> I have a question regarding the best approach for customizing JXPath. I
> looked at providing a NodePointer implementation but was not convinced
this
> was the right course and also deterred by the large interface.
>
> I like what JXPath provides out-of-the-box with regards to JavaBean
support,
> but instead of allowing clients unvetted access to the whole of my API I
> would prefer to restrict access.
>
> The initial idea was to provide a new JXPathIntospector implementation
that
> hands off to a 'GuardHandler' if the context object implements a
well-known
> tag interface, otherwise it would follow the normal JavaBean resolution.
>
> The 'GuardHandler' (implemtation of DynamicPropertyHandler) guards against
> using any methods not defined for the given bean.
>
> I then realised the JXPathIntrospector is not configurable which lead me
to
> the NodePointer. I'm now wondering the best approach. Any guidance would
be
> much appreciated.
>
> cheers,
> steve.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>