DefaultInterceptorHandlerFactory implements InterceptorHandlerFactory { public InterceptorHandler handlerFor(Class<? extends Interceptor> type) { if (type.isAnnotationPresent(Lazy.class)) { InterceptorHandler handler = cachedHandlers.get(type); if (handler == null) { LazyInterceptorHandler value = new LazyInterceptorHandler(container, type); cachedHandlers.putIfAbsent(type, value); return value; } else { return handler; } } return new ToInstantiateInterceptorHandler(container, type); } DefaultInterceptorHandlerFactory(Container container); InterceptorHandler handlerFor(Class<? extends Interceptor> type);  }
@Test public void handlerForRegularInterceptorsShouldBeDynamic() throws Exception { assertThat(factory.handlerFor(RegularInterceptor.class), is(instanceOf(ToInstantiateInterceptorHandler.class))); }
@Test public void handlerForStaticInterceptorsShouldBeStatic() throws Exception { assertThat(factory.handlerFor(ALazyInterceptor.class), is(instanceOf(LazyInterceptorHandler.class))); }
@Test public void staticHandlersShouldBeCached() throws Exception { InterceptorHandler handler = factory.handlerFor(ALazyInterceptor.class); assertThat(factory.handlerFor(ALazyInterceptor.class), is(sameInstance(handler))); }