config-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/DispatchType.java
@SuppressWarnings("unchecked")
   private List<DispatcherTypeProvider> getDispatcherTypeProviders(HttpServletRewrite event)
   {
      List<DispatcherTypeProvider> providers = (List<DispatcherTypeProvider>)
               event.getRequest().getAttribute(PROVIDER_KEY);
      if (providers == null) {
         providers = Iterators.asList(ServiceLoader.loadTypesafe(DispatcherTypeProvider.class).iterator());
         Collections.sort(providers, new WeightedComparator());
         event.getRequest().setAttribute(PROVIDER_KEY, providers);
      }
      return providers;
   }
@SuppressWarnings("unchecked")
   private List<DispatcherTypeProvider> getDispatcherTypeProviders(HttpServletRewrite event)
   {
      List<DispatcherTypeProvider> providers = (List<DispatcherTypeProvider>)
               event.getRequest().getAttribute(PROVIDER_KEY);
      if (providers == null) {
         providers = Iterators.asList(ServiceLoader.loadTypesafe(DispatcherTypeProvider.class).iterator());
         Collections.sort(providers, new WeightedComparator());
         event.getRequest().setAttribute(PROVIDER_KEY, providers);
      }
      return providers;
   }
@ SuppressWarnings ( "unchecked" ) private List < DispatcherTypeProvider > getDispatcherTypeProviders ( HttpServletRewrite event ) { List < DispatcherTypeProvider > providers = ( List < DispatcherTypeProvider > ) event . getRequest ( ) . getAttribute ( PROVIDER_KEY ) ; if ( providers == null ) { providers = Iterators . asList ( ServiceLoader . loadTypesafe ( DispatcherTypeProvider . class ) . iterator ( ) ) ; Collections . sort ( providers , new WeightedComparator ( ) ) ; event . getRequest ( ) . setAttribute ( PROVIDER_KEY , providers ) ; } return providers ; }
Simple caching mechanism for the providers on a per request basis
Simple caching mechanism for the providers on a per request basis