java - CGLib Proxy for Integer (Final class) in Spring MVC -


i need such usage:

for each request want inject userid democontroller because of being final class without empty constructor can not inject it. best practice in such cases? service request scope fine?

@configuration public class cityfactory{     @bean(name = {"currentuserid")    @scope(value = webapplicationcontext.scope_request,proxymode = scopedproxymode.target_class)    @autowired    public integer getuserid(httpservletrequest request) {        return userutil.getcurrentuserid(request.getservername());    } }   @requestmapping("/demo") @controller public class democontroller {      @autowired     ingeter userid;      @requestmapping(value = "/hello/{name}", method = requestmethod.get)     public modelandview helloworld(@pathvariable("name") string name, model model) {         map<string, object> mymodel = new hashmap<string, object>();         model.addattribute("user", userid);         return new modelandview("v3/test", "m", model);     } } 

your best bet create explicit class called userid, in turn contains integer. not play nicer cglib's proxying, clarifies design.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -