oop - Generic interface inheritance Java -
first of show code. have generic interface:
basewebservicecool:
public interface basewebservicecool<i extends sessionpeticionbasebean, o extends wsrespuestabasebean> { o create(i wsrequest); o read(i wsrequest); o update(i wsrequest); void delete(i wsrequest); }
sessionpeticionbean:
public class sessionpeticionbasebean implements serializable { private string token; private string uuidusuariologado; }
wsrespuestabean:
public class wsrespuestabasebean implements serializable { private string codigorespuesta; private string mensajerespuesta; private boolean error; private map<string, string> errors; }
getters , setters skipped. have specific interface extends above base interface that: wspersonasinterface:
public interface wspersonasinterface<i extends sessionpeticionbasebean, o extends wsrespuestabasebean> extends basewebservicecool<i, o> { }
the point web controller must implement base interface method through specific interface (wspersonasinterface). in controller im doing that:
public class personascontroller extends basecontroller implements basewebservicecool<sessionpeticionbasebean, wsrespuestabasebean> { @rolesallowed({ "role_user" }) @requestmapping(value = "/create/", method = { requestmethod.post }, headers = "accept=application/xml, application/json") @override public createpersonawsrespuestabean create( @requestbody @valid createpersonawspeticionbean createpersonapeticionbean) { return personasbusiness.createpersona(createpersonapeticionbean); } @override public @responsebody personawsrespuestabean read( @requestbody @valid readpersonawspeticionbean readpersonawspeticionbean) { return personasbusiness.readpersona(readpersonawspeticionbean); }
for brevity skipped remaining methods. implementation/overriding fails..
i controller, createpersonawsrespuestabean , personawsrespuestabean classes inherits wsrespuestabean , createpersonawspeticionbean , readpersonawspeticionbean inherits sessionpeticionbasebean.
there surely design problem, smart mind cand give tips?
change signature of controller's methods respect contract (your interface basewebservicecool
) implement:
public class personascontroller extends basecontroller implements basewebservicecool<sessionpeticionbasebean, wsrespuestabasebean> { @rolesallowed({ "role_user" }) @requestmapping(value = "/create/", method = { requestmethod.post }, headers = "accept=application/xml, application/json") @override public wsrespuestabasebean create( @requestbody @valid sessionpeticionbasebean createpersonapeticionbean) { return personasbusiness.createpersona(createpersonapeticionbean); } @override public @responsebody wsrespuestabasebean read( @requestbody @valid sessionpeticionbasebean readpersonawspeticionbean) { return personasbusiness.readpersona(readpersonawspeticionbean); }
Comments
Post a Comment