本文是因启动的提示信息而写,以下为启动时的实时信息,这里会附上一些解释
D:\apache-tomcat-7.0.53\bin\catalina.bat run
对于这句请参考:http://blog.csdn.net/zgmzyr/article/details/6871858 里面有关于catalina.bat足够详细的解释。
[2015-08-26 09:59:27,422] Artifact spring-websocket-portfolio:war exploded: Server is not connected.
这句里的“spring-websocket-portfolio:war exploded”是我idea(一款IDE)生成的一个Artifact包。这里提示说“服务器没有连接”。
Deploy is not available.
部署不可用
Using CATALINA_BASE: "C:\Users\Administrator\.IntelliJIdea13\system\tomcat\Unnamed_spring-websocket-portfolio_2"
调用CATALINA_BASE下的目录地址,这里是我本地的地址,我建议大家也进入自己的本地目录中去看一下,并且这里提供一个博客供了解:http://blog.csdn.net/xiaohai0504/article/details/7631014
Using CATALINA_HOME: "D:\apache-tomcat-7.0.53"
调用CATALINA_HOME下的目录地址,不觉得他们很像一个东西吗?对了,就是环境变量。
Using CATALINA_TMPDIR: "D:\apache-tomcat-7.0.53\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_45"
Using CLASSPATH: "D:\apache-tomcat-7.0.53\bin\bootstrap.jar;D:\apache-tomcat-7.0.53\bin\tomcat-juli.jar"
Connected to the target VM, address: '127.0.0.1:50071', transport: 'socket'.
连接到目标虚拟机,地址为 '127.0.0.1:50071',传输方式 'socket'
八月 26, 2015 9:59:28 上午 org.apache.catalina.core.AprLifecycleListener init
时间。初始化AprLifecycleListener监听器。“Apr Lifecycle Listener“从这里可以看出是APR生命周期监听器。关于APR,这里附带一篇关于APR的博客:http://zxbear.iteye.com/blog/666578 用于了解一下APR
信息: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8.
这里是加载APR的library1.1.29,以及版本为1.4.8的APR
八月 26, 2015 9:59:28 上午 org.apache.catalina.core.AprLifecycleListener init
再次提示启动AprLifecycleListener监听器,没看到源码,不知道为何重复提示
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
虽然我没有对此查询,不过看样子是APR容器的配置信息
八月 26, 2015 9:59:29 上午 org.apache.catalina.core.AprLifecycleListener initializeSSL
AprLifecycleListener 初始化SSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013)
OpenSSL 成功初始化,还附带了OpenSSL版本
八月 26, 2015 9:59:29 上午 org.apache.coyote.AbstractProtocol init
AbstractProtocol 初始化
信息: Initializing ProtocolHandler ["http-apr-8080"]
初始化 ProtocolHandler 协议处理程序 ["http-apr-8080"]
八月 26, 2015 9:59:29 上午 org.apache.coyote.AbstractProtocol init
AbstractProtocol 初始化,重复提示,看到这里,我有点了解为什么会有这样重复的初始化的提示了。你明白了吗?如果不想承认被写文章的我智商压制的话,就再仔细看一看,想一想吧
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
八月 26, 2015 9:59:29 上午 org.apache.catalina.startup.Catalina load
Catalina(一个servlet容器,处理servlet) 启动加载
信息: Initialization processed in 1781 ms
初始化处理,用时1781毫秒=1.781秒
八月 26, 2015 9:59:29 上午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
启动Catalina服务
八月 26, 2015 9:59:29 上午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.53
启动Servlet引擎: Apache Tomcat/7.0.53
八月 26, 2015 9:59:29 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-8080"]
八月 26, 2015 9:59:29 上午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
八月 26, 2015 9:59:29 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 76 ms
服务器启动,用时76毫秒
Connected to server
连接到服务器
[2015-08-26 09:59:30,120] Artifact spring-websocket-portfolio:war exploded: Artifact is being deployed, please wait...
spring-websocket-portfolio:war exploded这个Artifact包被部署(其实就是war包),请等待
DispatcherServletInitializer : super.onStartup(ServletContext servletContext)
DispatcherServletInitializer是我创建的类,继承了AbstractAnnotationConfigDispatcherServletInitializer,这句话是我打印出来的,代表程序运行到这了
八月 26, 2015 12:11:53 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\apache-tomcat-7.0.53\webapps\manager
部署web应用到D:\apache-tomcat-7.0.53\webapps\manager路径下
DispatcherServletInitializer : customizeRegistration(Dynamic registration)
这句话是我打印出来的,代表程序运行到这了
12:29:35 [RMI TCP Connection(3)-127.0.0.1] context.ContextLoader - Root WebApplicationContext: initialization started
12:29:35 [RMI TCP Connection(3)-127.0.0.1] support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Aug 26 12:29:35 CST 2015]; root of context hierarchy
12:29:35 [RMI TCP Connection(3)-127.0.0.1] support.AnnotationConfigWebApplicationContext - Registering annotated classes: [class org.springframework.samples.portfolio.config.WebSecurityConfig]
WebSecurityConfig是我创建的类,自定义了Spring安全配置。
WebSecurityConfig : configure(AuthenticationManagerBuilder auth)
这里是我打印出来的,这里配置了帐号和密码
WebSecurityConfig : configure(HttpSecurity http)
这里是我打印出来的,这里配置了URL
12:43:48 [RMI TCP Connection(3)-127.0.0.1] context.ContextLoader - Root WebApplicationContext: initialization completed in 853584 ms
WebApplicationContext的初始化完成,用时...。很长,因为我打了断点,所以一直处于等待中
12:43:49 [RMI TCP Connection(3)-127.0.0.1] servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started
DispatcherServlet开始初始化
12:43:49 [RMI TCP Connection(3)-127.0.0.1] support.AnnotationConfigWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Aug 26 12:43:49 CST 2015]; parent: Root WebApplicationContext
12:43:49 [RMI TCP Connection(3)-127.0.0.1] support.AnnotationConfigWebApplicationContext - Registering annotated classes: [class org.springframework.samples.portfolio.config.WebConfig,class org.springframework.samples.portfolio.config.WebSocketConfig]
注册注解类,WebConfig和WebSocketConfig,这两个类都是我创建的类
WebSocketConfig : configureClientOutboundChannel(ChannelRegistration registration)
这里是我打印出来的,注册客户端输出通道
WebSocketConfig : configureMessageBroker(MessageBrokerRegistry registry)
这里是我打印出来的,注册MessageBroker,MessageBroker可实现WebSocket广播
WebConfig : configurer.enable()
这里是我打印出来的,DefaultServletHandlerConfigurer类调用了enable方法,于是有了下面这行信息
12:54:03 [RMI TCP Connection(3)-127.0.0.1] handler.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
这段信息里注意一下“handler.SimpleUrlHandlerMapping - Mapped URL path [/**] ”。这里我说一下,Spring里有不少的Adapter和Handler,如果我没记错,以前看源码的时候它的流程是先到Adapter(适配器),再到Handler(处理器)的,由适配器来分配处理器来处理,而其中一种Handler就叫HandlerMapping就是这条信息里的“SimpleUrlHandlerMapping”,我记得是处理外部映射URL和内部URL的,就是通过处理请求中的访问地址来找到程序内部的具体处理类或者方法的。
12:54:03 [RMI TCP Connection(3)-127.0.0.1] annotation.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Aug 26 12:43:49 CST 2015]; parent: Root WebApplicationContext
这条信息好有趣,“RequestMappingHandlerAdapter”简单翻译就是‘请求映射处理器适配器’,然后寻找@ControllerAdvice:Web应用环境(也可以说web应用上下文)对于命名空间'dispatcher-servlet':启动日期...,看到这里就可以了
WebSocketConfig : registerStompEndpoints(StompEndpointRegistry registry)
我打印的,注册WebSocket端点
13:16:15 [RMI TCP Connection(3)-127.0.0.1] support.WebSocketHandlerMapping - Mapped URL path [/portfolio/**] onto handler of type [class org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler]
这里注意,这跟之前的HandlerMapping有点类似,但这次调用Handler是“SockJsHttpRequestHandler”,以及它所映射的是“Mapped URL path [/portfolio/**] ”
13:16:15 [RMI TCP Connection(3)-127.0.0.1] messaging.WebSocketAnnotationMethodMessageHandler - Mapped "{[/trade],messageType=[MESSAGE]}" onto public void org.springframework.samples.portfolio.web.PortfolioController.executeTrade(org.springframework.samples.portfolio.vo.Trade,java.security.Principal)
这段有点长,但是这里有个类“WebSocketAnnotationMethodMessageHandler”,WebSocket注解方法消息处理器,它映射了[/trade],并且消息类型为“MESSAGE”,并且将该映射指向PortfolioController类的executeTrade方法(连方法的属性、类型、参数都有)
看到这里,大家有没有觉得里面的弯弯绕绕很多,但是却很详细呢?反正我信了
13:16:15 [RMI TCP Connection(3)-127.0.0.1] messaging.WebSocketAnnotationMethodMessageHandler - Mapped "{[/positions],messageType=[SUBSCRIBE]}" onto public org.springframework.samples.portfolio.model.Portfolio org.springframework.samples.portfolio.web.PortfolioController.getPositions(java.security.Principal) throws java.lang.Exception
跟上一条类似
13:16:15 [RMI TCP Connection(3)-127.0.0.1] broker.SimpleBrokerMessageHandler - Starting...
SimpleBrokerMessageHandler 简单中间消息处理器 - 启动中
13:16:15 [RMI TCP Connection(3)-127.0.0.1] broker.SimpleBrokerMessageHandler - BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
13:16:15 [RMI TCP Connection(3)-127.0.0.1] broker.SimpleBrokerMessageHandler - Started.
SimpleBrokerMessageHandler 简单中间消息处理器 - 启动成功
13:16:15 [RMI TCP Connection(3)-127.0.0.1] servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 1946889 ms
DispatcherServlet初始化完成,由于我处于断点中,所以这个初始化时间很长。
[2015-08-26 01:16:15,927] Artifact spring-websocket-portfolio:war exploded: Artifact is deployed successfully
Artifact包部署成功
[2015-08-26 01:16:15,928] Artifact spring-websocket-portfolio:war exploded: Deploy took 11,805,808 milliseconds
部署消耗时间 ... ... 不用去看了
13:16:15 [MessageBroker-1] service.QuoteService - Sending quote end
13:16:18 [MessageBroker-1] service.QuoteService - Sending quote end
13:16:21 [MessageBroker-2] service.QuoteService - Sending quote end
这里是socket开启以后处于等待中,是调用了我的service后logger打印的
...
...
...
13:17:15 [MessageBroker-3] config.WebSocketMessageBrokerStats - WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannelpool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 4, active threads = 1, queued tasks = 2, completed tasks = 60]
这段信息好理解,开头就描述清楚了,是消息中间件打印出来的报告
文章到此结束,因为服务器已经启动了,本文是在调研WebSocket时下载的一个demo,启动时的信息。服务自己也是服务大家,这里是其博客:http://blog.csdn.net/sl543001/article/details/19343005
该博客中坦言:
“我试着下载了spring官方的demo (地址:https://github.com/rstoyanchev/spring-websocket-test)
跑起来看到里面有点小bug,自己修改了一下,顺便阅读修改并注释了主要代码。修改后的源码在:http://git.oschina.net/sybn/webSocketDemo.git”
而我是用git下载了对方修改过的代码并运行的