Re: java.lang.AbstractMethodError - 5.1.0.5

2009-12-11 Thread Thiago H. de Paula Figueiredo
Em Fri, 11 Dec 2009 10:23:11 -0200, Jim O'Callaghan  
jc1000...@yahoo.co.uk escreveu:



Hi,


Hi!

I have a service bound to an interface in the ioc registry.  The  
interface extends another interface and duplicates a method name and  
parameter list
however the return type in the overridden method is a concrete class  
rather than an implementing interface, as specified in the super  
interface ex.:


Tapestry-IoC create proxies around your service implementations, so, when  
you @Inject UserEntityManager, the object your receive is proxy that  
implements UserEntityManager, not BaseEntityManager. This means that the  
proxy will invoke a method that returns IPersistentObject, not User.



This is to reduce the need for explicit casting around the application.


This doesn't seem right to me. You shouldn't rely on an specific  
implementation of a given interface. If you need, why return an interface  
in first place?


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.

http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



RE: java.lang.AbstractMethodError - 5.1.0.5

2009-12-11 Thread Jim O'Callaghan
Hi Thiago,

Thanks for the response - comments below.

Tapestry-IoC create proxies around your service implementations, so, when
you @Inject UserEntityManager, the object your receive is proxy that
implements UserEntityManager, not BaseEntityManager. This means that the
proxy will invoke a method that returns IPersistentObject, not User.

This is the nub of the problem - the proxy implements UserEntityManager,
which by definition returns a User object for this particular method - not
explicitly a IPersistentObject as in your example, though the returned
object does implement IPersistentObject.  I thought that the StackTrace
might indicate that there is an exception in the ioc registry area that is
not being caught / reported properly. If the java.lang.AbstractMethodError
had a message that contained something indicating an unexpected return type
/ class cast issue etc. it would have been easier to pin down.

 This is to reduce the need for explicit casting around the application.

This doesn't seem right to me. You shouldn't rely on an specific
implementation of a given interface. If you need, why return an interface
in first place?

Agreed - this is just for convenience in a very context relevant area of the
system (user CRUD and other ops) - in other areas of the system the
IPersistentObject interface is used as a matter of course in place of Users
and other domain objects.

Regards,
Jim.



-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com]
Sent: 11 December 2009 12:39
To: Tapestry users
Subject: Re: java.lang.AbstractMethodError - 5.1.0.5


Em Fri, 11 Dec 2009 10:23:11 -0200, Jim O'Callaghan
jc1000...@yahoo.co.uk escreveu:

 Hi,

Hi!

 I have a service bound to an interface in the ioc registry.  The
 interface extends another interface and duplicates a method name and
 parameter list
 however the return type in the overridden method is a concrete class
 rather than an implementing interface, as specified in the super
 interface ex.:

Tapestry-IoC create proxies around your service implementations, so, when
you @Inject UserEntityManager, the object your receive is proxy that
implements UserEntityManager, not BaseEntityManager. This means that the
proxy will invoke a method that returns IPersistentObject, not User.

 This is to reduce the need for explicit casting around the application.

This doesn't seem right to me. You shouldn't rely on an specific
implementation of a given interface. If you need, why return an interface
in first place?

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org