Re: Annotation based configuration – performance

Splash Forums PrettyFaces Users Annotation based configuration – performance Re: Annotation based configuration – performance

#22301

Petter Helset
Participant

Solved this by implementing a custom ConfigurationProvider and disabling both “com.ocpsoft.pretty.SCAN_LIB_DIRECTORY” and “com.ocpsoft.pretty.BASE_PACKAGES”.

@Override

public PrettyConfig loadConfiguration(ServletContext servletContext)

{

final ListableBeanFactory listableBeanFactory = WebApplicationContextUtils.getWebApplicationContext(servletContext);

final Map<String, Object> controllers = listableBeanFactory.getBeansWithAnnotation(Controller.class);

final LazyBeanNameFinder beanNameFinder = new LazyBeanNameFinder(servletContext);

final PrettyAnnotationHandler annotationHandler = new PrettyAnnotationHandler(beanNameFinder);

for (Object o : controllers.values())

{

annotationHandler.processClass(o.getClass());

}

final PrettyConfigBuilder builder = new PrettyConfigBuilder();

annotationHandler.build(builder);

return builder.build();

}

This ConfigurationProvider finds all beans annotated with @Controller and processes PrettyFaces annotations with PrettyAnnotationHandler.