启动日志
15:19:05.342 INFO [main] cn.note.swing.ViewApplication (ViewApplication.java:36) : start time
15:19:05.534 DEBUG [main] o.s.c.a.AnnotationConfigApplicationContext (AbstractApplicationContext.java:629) : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@77cd7a0
15:19:05.546 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
15:19:05.628 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-core\target\classes\cn\note\swing\core\util\core\SpringContext.class]
15:19:05.631 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-single\target\classes\cn\note\swing\formatter\CodeFormatterView.class]
15:19:05.634 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-single\target\classes\cn\note\swing\single\SingleAutoHelper.class]
15:19:05.705 INFO [AWT-EventQueue-0] cn.note.swing.ViewApplication (ViewApplication.java:66) : show gui application
15:19:05.760 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
15:19:05.759 INFO [AWT-EventQueue-0] c.n.s.config.SpringBeanConfig (SpringBeanConfig.java:47) : 异步注册: @Component&ItemView==>CodeFormatterView
15:19:05.761 INFO [AWT-EventQueue-0] c.n.s.config.SpringBeanConfig (SpringBeanConfig.java:47) : 异步注册: @Component&ItemView==>SingleAutoHelper
15:19:05.769 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
15:19:05.770 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
15:19:05.772 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
15:19:05.781 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'springBeanConfig'
15:19:05.785 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'springContext'
15:19:05.786 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'codeFormatterView'
15:19:06.047 INFO [AWT-EventQueue-0] cn.note.swing.ViewApplication (ViewApplication.java:69) : slider menu load complete
register==>JSON
15:19:06.200 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'singleAutoHelper'
15:19:06.927 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'application'
15:19:07.000 INFO [main] cn.note.swing.ViewApplication (ViewApplication.java:55) : gui launch milli time:1659 15:19:05.342 INFO [main] cn.note.swing.ViewApplication (ViewApplication.java:36) : start time
15:19:05.534 DEBUG [main] o.s.c.a.AnnotationConfigApplicationContext (AbstractApplicationContext.java:629) : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@77cd7a0
15:19:05.546 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
15:19:05.628 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-core\target\classes\cn\note\swing\core\util\core\SpringContext.class]
15:19:05.631 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-single\target\classes\cn\note\swing\formatter\CodeFormatterView.class]
15:19:05.634 DEBUG [main] o.s.c.a.ClassPathBeanDefinitionScanner (ClassPathScanningCandidateComponentProvider.java:435) : Identified candidate component class: file [\note-swing-single\target\classes\cn\note\swing\single\SingleAutoHelper.class]
15:19:05.705 INFO [AWT-EventQueue-0] cn.note.swing.ViewApplication (ViewApplication.java:66) : show gui application
15:19:05.760 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
15:19:05.759 INFO [AWT-EventQueue-0] c.n.s.config.SpringBeanConfig (SpringBeanConfig.java:47) : 异步注册: @Component&ItemView==>CodeFormatterView
15:19:05.761 INFO [AWT-EventQueue-0] c.n.s.config.SpringBeanConfig (SpringBeanConfig.java:47) : 异步注册: @Component&ItemView==>SingleAutoHelper
15:19:05.769 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
15:19:05.770 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
15:19:05.772 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
15:19:05.781 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'springBeanConfig'
15:19:05.785 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'springContext'
15:19:05.786 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'codeFormatterView'
15:19:06.047 INFO [AWT-EventQueue-0] cn.note.swing.ViewApplication (ViewApplication.java:69) : slider menu load complete
register==>JSON
15:19:06.200 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'singleAutoHelper'
15:19:06.927 DEBUG [main] o.s.b.f.s.DefaultListableBeanFactory (DefaultSingletonBeanRegistry.java:225) : Creating shared instance of singleton bean 'application'
15:19:07.000 INFO [main] cn.note.swing.ViewApplication (ViewApplication.java:55) : gui launch milli time:1659
优化一: main线程不要阻塞UI线程
spring的扫描bean时不要阻塞gui的渲染.
优化二: UI应该更早的显示
在使用UI框架渲染完成时,可以将JFrame立刻显示出来,
- 在上图日志中大概只有0.4s, 此时看到的了GUI的外科轮廓
- 这时GUI已经加载好了内置的UIManager
- 此时spring还没有扫描bean完成
优化三: 框架应该与业务合理的解耦
左侧菜单为@Compoent注解的菜单项, 如何获取更多的菜单信息
-
自定义注解,实现图标/ 分组 /描述等功能 -
此时可以有好多好处 1. spring内置的IOC使该业务可以解耦, 既可以作为独立应用测试, 也可以作为子应用注册.把控权在业务. 2. 如果该业务不想作为左侧菜单项时, 可以直接去除@ItemView注解,UI上的解耦 -
左侧菜单可以只扫描部分注解, 理论上肯定比spring加载快,因为spring还需要加载默认注解 -
因为左侧菜单使用AWT 线程加载, spring在MAIN线程加载, 所以spring加载完成时, 需要判断左侧视图是否加载完成, 加载完成再去激活第一个视图
优化四: 适当的使用缓存
当左侧菜单加载完成时,可以去激活第一个视图, 此时左侧的菜单的图形UI已经显示
- 通过建立SpringUtil上下文管理工具, 直接动态获取bean的名称,可以实现右侧视图的动态渲染
- 每次渲染的视图 和他的class 类路径 可以分别作为缓存Map的value和key
优化的目的: 更快的看到,更快的更新,更快的切换
那么你的Swing小工具的速度 可以faster faster faster
|