@ApplicationScope @Component public class Sequencial { private int numero = 0; public synchronized int proximo() { numero = (numero+1)%100000; return numero; } }
/** * Redirect to index.jsf SPA. * * @author Marcelo Fernandes */ @Component @ApplicationScope public class RedirectToIndexConfigurationProvider extends HttpConfigurationProvider { @Override public Configuration getConfiguration(ServletContext t) { return ConfigurationBuilder.begin() .addRule() .when(Direction.isInbound().and(Path.matches("/"))) .perform(Redirect.temporary("/starter.jsf")); } @Override public int priority() { return 10; } }
/** * Freemarker utitily class to merge map and templates. * * @author Marcelo Fernandes */ @Component @ApplicationScope public class FreemarkerUtils { @Autowired private Configuration configuration; /** * Generates the document as string using the map and templateName. * @param map map of objects * @param templateName name of template * @return merged string * @throws IOException io exception * @throws TemplateException template exception */ public String mergeTemplate(Map<String, Object> map, String templateName) throws TemplateException, IOException { Template template = this.configuration.getTemplate(templateName, "UTF-8"); return FreeMarkerTemplateUtils.processTemplateIntoString(template, map); } }
@Bean(name = "contextManager") @ApplicationScope protected ContextManager createContextManager() { return ContextManagerImpl.getInstance(); }
@ApplicationScope @Getter public class JoinFacesStarterService {