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/13 06:09:10 UTC

[JXPATH] Difference in introspection

Hi,

Any reason why Interfaces are introspected differently Objects ?

When an Interface is introspected "PropertyDescriptors" are created only for
methods defined on the Interface and not for inherited methods.  This is not
the case when an Object is introspected.

Is this expected? I feel it is inconsistent and prevents me from extending
Interfaces.

Steve.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [JXPATH] Difference in introspection

Posted by Dmitri Plotnikov <dm...@apache.org>.
Steve,

> > The idea of writing a custom JXPathBeanInfo is not that bad.
> > On the other
> > hand, I don't see why I could not update the introspector to
> > recursively
> > acquire property descriptors for all those parent interfaces.
>
> Yep, this would be nice. I wonder why the java.beans.Introspector()
doesn't
> provide this?  At this stage I have chosen to write a custom
JXPathBeanInfo
> that uses reflection to get a list of methods and then constructs a
> PropertyDescriptor for each.
I will do a similar thing tonight and check it in, because others may need
this functionality too.

> > The only issue with the use of the JXPathBeanInfo for the
> > interface is that
> > the _only_ properties available via the XPaths will be those on the
> > interface.  Any additional properties declared by the class
> > directly will be
> > inaccessible.
>
> I know. This is exactly what I want. I don't want to expose my entire
> internal API to the client, just a subset of it to ease maintenance and
> provide the client with a simplified more specific API. I control this in
a
> NOdePointerFactory impl - it checks the given Bean ojbect for a well-known
> XPath Interface (about 6 in total) and then uses the methods on the
matching
> XPath interface to create a BeanPointer. A little bit of work but worth
the
> effort.
Definitely makes sense to me now.  Very cool.

> Do you think this use-case of applying an "XPath API" could be applicable
to
> other developers? Definitely high on my list of requirements.
I don't know.  So far, you are the first.  If we hear the same requirement
from others, we should incorporate this solution into JXPath.

> steve.

- Dmitri

>
> >
> > Would it be possible to get JXPathBeanInfo for the object's
> > class, not the
> > interface?
> >
> > - Dmitri
> >
> > ----- Original Message -----
> > From: "Stephen Bartlett" <sb...@versata.com.au>
> > To: "'Jakarta Commons Developers List'"
> > <co...@jakarta.apache.org>
> > Sent: Thursday, June 13, 2002 7:32 PM
> > Subject: RE: [JXPATH] Difference in introspection
> >
> >
> > > Dmitri,
> > >
> > > I have a NodePointerFactory impl that uses the JXPathIntrospector to
> > create
> > > a JXPathBeanInfo object for an Interface. I take it this is
> > incorrect
> > > usage??
> > >
> > > Looking at the code
> > JXPathBasicBeanInfo.getPropertyDEscriptors() tests for
> > > an Interface but the BeanInfo object returned by
> > > java.beans.Introspector.getBeanInfo() doesn't  recognizes
> > methods from
> > super
> > > interfaces even without a 'stop' class.
> > >
> > > I guess I could implement my own JXPathBeanInfo class that
> > uses reflection
> > > instead of JavaBeans to create PropertyDescriptors ?
> > >
> > > cheers,
> > > steve.
> > >
> > > > -----Original Message-----
> > > > From: Dmitri Plotnikov [mailto:dmitri@apache.org]
> > > > Sent: Thursday, 13 June 2002 10:42 PM
> > > > To: Jakarta Commons Developers List
> > > > Subject: Re: [JXPATH] Difference in introspection
> > > >
> > > >
> > > > Stephen,
> > > >
> > > > > Any reason why Interfaces are introspected differently Objects ?
> > > > >
> > > > > When an Interface is introspected "PropertyDescriptors" are
> > > > created only
> > > > for
> > > > > methods defined on the Interface and not for inherited
> > > > methods.  This is
> > > > not
> > > > > the case when an Object is introspected.
> > > > >
> > > > > Is this expected? I feel it is inconsistent and prevents me
> > > > from extending
> > > > > Interfaces.
> > > > JXPath is not supposed to introspect interfaces - just
> > > > JavaBeans.  How did
> > > > you get it to introspect an interface?
> > > >
> > > > Thanks,
> > > >
> > > > >
> > > > > Steve.
> > > >
> > > > - Dmitri
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [JXPATH] Difference in introspection

Posted by Stephen Bartlett <sb...@versata.com.au>.
Dmitri,

>
> The idea of writing a custom JXPathBeanInfo is not that bad.
> On the other
> hand, I don't see why I could not update the introspector to
> recursively
> acquire property descriptors for all those parent interfaces.

Yep, this would be nice. I wonder why the java.beans.Introspector() doesn't
provide this?  At this stage I have chosen to write a custom JXPathBeanInfo
that uses reflection to get a list of methods and then constructs a
PropertyDescriptor for each.

>
> The only issue with the use of the JXPathBeanInfo for the
> interface is that
> the _only_ properties available via the XPaths will be those on the
> interface.  Any additional properties declared by the class
> directly will be
> inaccessible.

I know. This is exactly what I want. I don't want to expose my entire
internal API to the client, just a subset of it to ease maintenance and
provide the client with a simplified more specific API. I control this in a
NOdePointerFactory impl - it checks the given Bean ojbect for a well-known
XPath Interface (about 6 in total) and then uses the methods on the matching
XPath interface to create a BeanPointer. A little bit of work but worth the
effort.

Do you think this use-case of applying an "XPath API" could be applicable to
other developers? Definitely high on my list of requirements.

steve.

>
> Would it be possible to get JXPathBeanInfo for the object's
> class, not the
> interface?
>
> - Dmitri
>
> ----- Original Message -----
> From: "Stephen Bartlett" <sb...@versata.com.au>
> To: "'Jakarta Commons Developers List'"
> <co...@jakarta.apache.org>
> Sent: Thursday, June 13, 2002 7:32 PM
> Subject: RE: [JXPATH] Difference in introspection
>
>
> > Dmitri,
> >
> > I have a NodePointerFactory impl that uses the JXPathIntrospector to
> create
> > a JXPathBeanInfo object for an Interface. I take it this is
> incorrect
> > usage??
> >
> > Looking at the code
> JXPathBasicBeanInfo.getPropertyDEscriptors() tests for
> > an Interface but the BeanInfo object returned by
> > java.beans.Introspector.getBeanInfo() doesn't  recognizes
> methods from
> super
> > interfaces even without a 'stop' class.
> >
> > I guess I could implement my own JXPathBeanInfo class that
> uses reflection
> > instead of JavaBeans to create PropertyDescriptors ?
> >
> > cheers,
> > steve.
> >
> > > -----Original Message-----
> > > From: Dmitri Plotnikov [mailto:dmitri@apache.org]
> > > Sent: Thursday, 13 June 2002 10:42 PM
> > > To: Jakarta Commons Developers List
> > > Subject: Re: [JXPATH] Difference in introspection
> > >
> > >
> > > Stephen,
> > >
> > > > Any reason why Interfaces are introspected differently Objects ?
> > > >
> > > > When an Interface is introspected "PropertyDescriptors" are
> > > created only
> > > for
> > > > methods defined on the Interface and not for inherited
> > > methods.  This is
> > > not
> > > > the case when an Object is introspected.
> > > >
> > > > Is this expected? I feel it is inconsistent and prevents me
> > > from extending
> > > > Interfaces.
> > > JXPath is not supposed to introspect interfaces - just
> > > JavaBeans.  How did
> > > you get it to introspect an interface?
> > >
> > > Thanks,
> > >
> > > >
> > > > Steve.
> > >
> > > - Dmitri
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [JXPATH] Difference in introspection

Posted by Dmitri Plotnikov <dm...@apache.org>.
Steve,

The idea of writing a custom JXPathBeanInfo is not that bad.  On the other
hand, I don't see why I could not update the introspector to recursively
acquire property descriptors for all those parent interfaces.

The only issue with the use of the JXPathBeanInfo for the interface is that
the _only_ properties available via the XPaths will be those on the
interface.  Any additional properties declared by the class directly will be
inaccessible.

Would it be possible to get JXPathBeanInfo for the object's class, not the
interface?

- Dmitri

----- Original Message -----
From: "Stephen Bartlett" <sb...@versata.com.au>
To: "'Jakarta Commons Developers List'" <co...@jakarta.apache.org>
Sent: Thursday, June 13, 2002 7:32 PM
Subject: RE: [JXPATH] Difference in introspection


> Dmitri,
>
> I have a NodePointerFactory impl that uses the JXPathIntrospector to
create
> a JXPathBeanInfo object for an Interface. I take it this is incorrect
> usage??
>
> Looking at the code JXPathBasicBeanInfo.getPropertyDEscriptors() tests for
> an Interface but the BeanInfo object returned by
> java.beans.Introspector.getBeanInfo() doesn't  recognizes methods from
super
> interfaces even without a 'stop' class.
>
> I guess I could implement my own JXPathBeanInfo class that uses reflection
> instead of JavaBeans to create PropertyDescriptors ?
>
> cheers,
> steve.
>
> > -----Original Message-----
> > From: Dmitri Plotnikov [mailto:dmitri@apache.org]
> > Sent: Thursday, 13 June 2002 10:42 PM
> > To: Jakarta Commons Developers List
> > Subject: Re: [JXPATH] Difference in introspection
> >
> >
> > Stephen,
> >
> > > Any reason why Interfaces are introspected differently Objects ?
> > >
> > > When an Interface is introspected "PropertyDescriptors" are
> > created only
> > for
> > > methods defined on the Interface and not for inherited
> > methods.  This is
> > not
> > > the case when an Object is introspected.
> > >
> > > Is this expected? I feel it is inconsistent and prevents me
> > from extending
> > > Interfaces.
> > JXPath is not supposed to introspect interfaces - just
> > JavaBeans.  How did
> > you get it to introspect an interface?
> >
> > Thanks,
> >
> > >
> > > Steve.
> >
> > - Dmitri
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [JXPATH] Difference in introspection

Posted by Stephen Bartlett <sb...@versata.com.au>.
Dmitri,

I have a NodePointerFactory impl that uses the JXPathIntrospector to create
a JXPathBeanInfo object for an Interface. I take it this is incorrect
usage??

Looking at the code JXPathBasicBeanInfo.getPropertyDEscriptors() tests for
an Interface but the BeanInfo object returned by
java.beans.Introspector.getBeanInfo() doesn't  recognizes methods from super
interfaces even without a 'stop' class.

I guess I could implement my own JXPathBeanInfo class that uses reflection
instead of JavaBeans to create PropertyDescriptors ?

cheers,
steve.

> -----Original Message-----
> From: Dmitri Plotnikov [mailto:dmitri@apache.org]
> Sent: Thursday, 13 June 2002 10:42 PM
> To: Jakarta Commons Developers List
> Subject: Re: [JXPATH] Difference in introspection
>
>
> Stephen,
>
> > Any reason why Interfaces are introspected differently Objects ?
> >
> > When an Interface is introspected "PropertyDescriptors" are
> created only
> for
> > methods defined on the Interface and not for inherited
> methods.  This is
> not
> > the case when an Object is introspected.
> >
> > Is this expected? I feel it is inconsistent and prevents me
> from extending
> > Interfaces.
> JXPath is not supposed to introspect interfaces - just
> JavaBeans.  How did
> you get it to introspect an interface?
>
> Thanks,
>
> >
> > Steve.
>
> - Dmitri
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [JXPATH] Difference in introspection

Posted by Dmitri Plotnikov <dm...@apache.org>.
Stephen,

> Any reason why Interfaces are introspected differently Objects ?
>
> When an Interface is introspected "PropertyDescriptors" are created only
for
> methods defined on the Interface and not for inherited methods.  This is
not
> the case when an Object is introspected.
>
> Is this expected? I feel it is inconsistent and prevents me from extending
> Interfaces.
JXPath is not supposed to introspect interfaces - just JavaBeans.  How did
you get it to introspect an interface?

Thanks,

>
> Steve.

- Dmitri


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>