Inheritance for controller and service classes in a spring project -


in current spring project, controller , service classes have similar structures. want create base class both of them, used base other controller , service classes. can tell me if possible?

the basic structure classes (the term <> vary):

controller

@controller @requestmapping(value="<<name>>") public class <<name>>controler {      @autowired     private <<name>>service <<name>>;      @requestmapping(value="cadastra.htm", method=requestmethod.post)     @responsebody     @preauthorize("haspermission(#user, 'cadastra_<<name>>')")     public string cadastra(httpservletrequest request, httpservletresponse response) {         if(<<name>>.cadastra(request, response))             return "yes";         else             return "not";     }      @requestmapping(value="altera.htm", method=requestmethod.post)     @responsebody     @preauthorize("haspermission(#user, 'altera_<<name>>')")     public string altera(httpservletrequest request, httpservletresponse response) {         if(<<name>>.altera(request, response))             return "yes";         else             return "not";     }      @requestmapping(value="remove.htm", method=requestmethod.post)     @responsebody     @preauthorize("haspermission(#user, 'remove_<<name>>')")     public string remove(httpservletrequest request, httpservletresponse response) {         if(<<name>>.remove(request, response))             return "yes";         else             return "not";     }  } 

service

@service public class <<name>>service {      @autowired     private <<name>>dao <<name>>;      public boolean cadastra(httpservletrequest request, httpservletresponse response) {         return <<name>>.persist(null);     }      public boolean altera(httpservletrequest request, httpservletresponse response) {         return <<name>>.merge(null);     }      public boolean remove(httpservletrequest request, httpservletresponse response) {         return <<name>>.remove(null);     } } 


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -