Commit 2e3e9f9e authored by Liang Ding's avatar Liang Ding

🎨 请求计时

parent 4d409ffb
......@@ -73,7 +73,7 @@
</scm>
<properties>
<org.b3log.latke.version>3.0.5</org.b3log.latke.version>
<org.b3log.latke.version>3.0.8-SNAPSHOT</org.b3log.latke.version>
<slf4j.version>1.7.28</slf4j.version>
<jsoup.version>1.12.1</jsoup.version>
......
......@@ -23,8 +23,6 @@ import org.b3log.latke.Latkes;
import org.b3log.latke.event.EventManager;
import org.b3log.latke.http.BaseServer;
import org.b3log.latke.http.Dispatcher;
import org.b3log.latke.http.handler.StopwatchEndHandler;
import org.b3log.latke.http.handler.StopwatchStartHandler;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
......@@ -37,10 +35,7 @@ import org.b3log.solo.event.B3ArticleSender;
import org.b3log.solo.event.B3ArticleUpdater;
import org.b3log.solo.event.B3CommentSender;
import org.b3log.solo.event.PluginRefresher;
import org.b3log.solo.processor.ErrorProcessor;
import org.b3log.solo.processor.InitCheckHandler;
import org.b3log.solo.processor.PermalinkHandler;
import org.b3log.solo.processor.SkinHandler;
import org.b3log.solo.processor.*;
import org.b3log.solo.processor.console.*;
import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.service.*;
......@@ -185,11 +180,11 @@ public final class Server extends BaseServer {
Markdowns.LUTE_AVAILABLE = true;
}
Dispatcher.HANDLERS.add(0, new StopwatchStartHandler());
Dispatcher.startRequestHandler = new BeforeRequestHandler();
Dispatcher.HANDLERS.add(1, new SkinHandler());
Dispatcher.HANDLERS.add(2, new InitCheckHandler());
Dispatcher.HANDLERS.add(3, new PermalinkHandler());
Dispatcher.HANDLERS.add(new StopwatchEndHandler());
Dispatcher.endRequestHandler = new AfterRequestHandler();
routeConsoleProcessors();
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.processor;
import org.b3log.latke.http.RequestContext;
import org.b3log.latke.http.handler.Handler;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.jdbc.JdbcRepository;
import org.b3log.latke.util.Stopwatchs;
import org.b3log.latke.util.Strings;
/**
* After request handler.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Nov 3, 2019
* @since 3.6.7
*/
public class AfterRequestHandler implements Handler {
private static final Logger LOGGER = Logger.getLogger(AfterRequestHandler.class);
@Override
public void handle(final RequestContext context) {
JdbcRepository.dispose();
Stopwatchs.end();
LOGGER.log(Level.TRACE, "Stopwatch: {0}{1}", Strings.LINE_SEPARATOR, Stopwatchs.getTimingStat());
Stopwatchs.release();
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.processor;
import org.b3log.latke.http.RequestContext;
import org.b3log.latke.http.handler.Handler;
import org.b3log.latke.util.Stopwatchs;
/**
* Before request handler.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Nov 3, 2019
* @since 3.6.7
*/
public class BeforeRequestHandler implements Handler {
@Override
public void handle(final RequestContext context) {
Stopwatchs.start("Request Initialized [requestURI=" + context.requestURI() + "]");
}
}
......@@ -4,4 +4,3 @@ Disallow: /start
Disallow: /logout
Disallow: /authors/*
Disallow: /console/*
Disallow: /error/*
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment