spring - How to get mvc RequestMappingHandlerMapping reference in a service? -


my application need aware mapped url's since username, or other resource types dynamically mapped.

even been able current mapping, can on controller:

@autowired requestmappinghandlermapping handlermapping;  public void showhandlersmapping() {     map<requestmappinginfo,handlermethod> map = handlermapping.gethandlermethods();     iterator<?> = map.entryset().iterator();     while (it.hasnext()) {         map.entry pairs = (map.entry)it.next();         system.out.println(pairs.getkey() + " = " + pairs.getvalue());     }        }  

but have reference in root-context other bean query against it.

how accomplish once mvc context gets loaded after root-context?

my solution (till now):

added @postconstruct controller call apiservice.registerhandlersmapping(handlermapping);

i'm not sure drawbacks approach appreciate advice.

i can't think of different solution other approach have mentioned of injecting in mappings web layer services layer. there few design issues here, have noted - services layer being dependent on web layer, , can think of few ways mitigate this:

  1. extract essence of require handlermappings (say simple map<string, string> , inject alone services tier, way atleast dependencies reduced little.

  2. move specific services web tier, way web related dependencies remain in web tier.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -