jeudi 19 février 2015

Resolver with SimpleUrlHandlerMapping

Am trying to use a Resolver with a SimpleUrlHandlerMapping and runnign into issues. It build and runs but everytime I call the url, I have a NULL/NULL for controller/action


Am I misunderstanding how to use these together??



public PropertiesMethodNameResolver methodMapping(String entryPoint, String controllerName, List actions){
PropertiesMethodNameResolver resolver = new PropertiesMethodNameResolver();

Properties mappings = new Properties();
actions.each(){ it ->
mappings.put("/"+entryPoint+"/"+controllerName+"/"+it+"/**", "${it}".toString());
}
resolver.setMappings(mappings);
return resolver
}

@Bean
public SimpleUrlHandlerMapping urlMapping(ApplicationContext context) {
String apiName = this.apiName.toString()
String apiVersion = this.version.toString()
String entryPoint = (apiName)?"${apiName}_v${apiVersion}".toString():"v${apiVersion}".toString()

//apiCacheService.deleteAll();
LinkedHashMap urlList = populateCache()

SimpleUrlHandlerMapping ret = new SimpleUrlHandlerMapping();

//HandlerInterceptor hi = new HandlerInterceptor()[ apiInterceptor() ]
ApiInterceptor apiInterceptor = apiInterceptor()
ret.setInterceptors(apiInterceptor);

ret.setOrder(Integer.MAX_VALUE-2);

String[] controllers = context.getBeanNamesForType(MultiActionController.class)

Properties mappings = new Properties();
urlList.each{ controller, actions ->
String controllerName = "${controller}Controller".toString()
if(controllers.contains(controllerName)){
PropertiesMethodNameResolver resolver = methodMapping(entryPoint,controllerName,actions)
MultiActionController cont = context.getBean(controllerName)
cont.setMethodNameResolver(resolver);

actions.each{ action ->
mappings.put("/"+entryPoint+"/"+controller+"/"+action+"/**", cont);
}
ret.setUrlMap(mappings);
}
}
//ret.setMappings(mappings);

return ret;
}

Aucun commentaire:

Enregistrer un commentaire