The IDE suggest the cast because the AutoMateParser is not a sub-type of Parser, only AutoMateParserImpl is. Just not sure how to make that work. Any thoughts? Still new to binding, but should I be binding AutoMateParserImpl to a Parser interface?
On Tue, Aug 21, 2012 at 8:02 AM, Thiago H de Paula Figueiredo [via Tapestry] <ml-node+s1045711n5715660...@n5.nabble.com> wrote: > On Tue, 21 Aug 2012 00:27:38 -0300, George Christman > <[hidden email] <http://user/SendEmail.jtp?type=node&node=5715660&i=0>> > 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: [hidden > email]<http://user/SendEmail.jtp?type=node&node=5715660&i=1> > For additional commands, e-mail: [hidden > email]<http://user/SendEmail.jtp?type=node&node=5715660&i=2> > > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://tapestry.1045711.n5.nabble.com/Compiling-error-returning-service-interface-in-service-locator-method-tp5715645p5715660.html > To unsubscribe from Compiling error returning service interface in > service locator method, click > here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5715645&code=Z2NocmlzdG1hbkBjYXJkYWRkeS5jb218NTcxNTY0NXwxNjMyOTYxMjA3> > . > NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York -- View this message in context: http://tapestry.1045711.n5.nabble.com/Compiling-error-returning-service-interface-in-service-locator-method-tp5715645p5715662.html Sent from the Tapestry - User mailing list archive at Nabble.com.