@Override
  public void contextInitialized(final ServletContextEvent servletContextEvent) {
    Stopwatchs.start("Context Initialized");

    super.contextInitialized(servletContextEvent);

    Skins.loadSkin();

    final LatkeBeanManager beanManager = Lifecycle.getBeanManager();

    // Register event listeners
    final EventManager eventManager = beanManager.getReference(EventManager.class);
    eventManager.registerListener(new ArticleSender());
    eventManager.registerListener(new ArticleUpdater());
    eventManager.registerListener(new CommentSender());

    final CommentNotifier commentNotifier = beanManager.getReference(CommentNotifier.class);
    eventManager.registerListener(commentNotifier);

    final ArticleNotifier articleNotifier = beanManager.getReference(ArticleNotifier.class);
    eventManager.registerListener(articleNotifier);

    LOGGER.info("Initialized the context");

    Stopwatchs.end();
    LOGGER.log(
        Level.DEBUG,
        "Stopwatch: {0}{1}",
        new Object[] {Strings.LINE_SEPARATOR, Stopwatchs.getTimingStat()});
    Stopwatchs.release();
  }
Esempio n. 2
0
  /**
   * Test method for {@linkplain Markdowns#toHTML(java.lang.String)}.
   *
   * @throws Exception exception
   */
  @Test
  public void toHTML() throws Exception {
    String markdownText = "";
    String html = Markdowns.toHTML(markdownText);

    Assert.assertNull(html);

    markdownText = "# Solo Markdown Editor";
    html = Markdowns.toHTML(markdownText);

    System.out.println(html);

    System.out.println(MarkdownsTestCase.class.getResource("/"));
    final URL testFile = MarkdownsTestCase.class.getResource("/markdown_syntax.text");
    final String path = URLDecoder.decode(testFile.getPath(), "UTF-8");
    System.out.println(path);

    final StringBuilder markdownTextBuilder = new StringBuilder();
    @SuppressWarnings("unchecked")
    final List<String> lines = IOUtils.readLines(new FileInputStream(path));

    for (final String line : lines) {
      markdownTextBuilder.append(line).append(Strings.LINE_SEPARATOR);
    }

    markdownText = markdownTextBuilder.toString();
    System.out.println(markdownText);

    Stopwatchs.start("Markdowning");
    html = Markdowns.toHTML(markdownText);
    Stopwatchs.end();

    System.out.println(html);

    System.out.println("Stopwatch: ");
    System.out.println(Stopwatchs.getTimingStat());

    // HTML entity test
    markdownText = "The first: &#39; <br/> The second: &AElig;";
    html = Markdowns.toHTML(markdownText);

    System.out.println(html);
  }
 @Override
 public void requestDestroyed(final ServletRequestEvent servletRequestEvent) {
   super.requestDestroyed(servletRequestEvent);
   Stopwatchs.release();
 }
 @Override
 public void doAdvice(final HTTPRequestContext context, final Map<String, Object> args)
     throws RequestProcessAdviceException {
   final String requestURI = context.getRequest().getRequestURI();
   Stopwatchs.start("Request URI [" + requestURI + ']');
 }