On Tue, 21 Aug 2012 00:27:38 -0300, George Christman
<gchrist...@cardaddy.com> wrote:
Hello, in my DMSServiceLocator.class, I have a method called getParser()
with a return type called Parser. I'm trying to return a service called
AutoMateParser with an Impl that extends Parser, however I'm' getting a
compiling error saying Parser is required, found AutoMateParser. When I
return new AutoMateServiceImpl() rather than my service interface, I
receive
no compiling errors. It doesn't appear my getParser() method realizes
autoMateParser is of the same type. I tried casting AutoMateParser with
Parser, "return (Parser) autoMateParser;" which resolved compiling
errors, but received a cast exception.
This is not a compiler error, but an exception instead. In addition, when
you bind a service based on an interface, the instance of it you get is a
proxy to the implementation class, not an instance of the service
implementation, so this ClassCastException is expected. Why do you need to
do this cast? This looks like a bad implementation decision in your code.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org