Logs:
in fact, a tool categories:
logging framework Speaking of tall, but in reality is to import a jar package.
Log4J log bundle of use:
Import jar package: log4j
Specifies the log level TRACE: provide for different levels of information is not the same when output.
Common log level: ALL (any information that can be output) TRACE (heap, stack information (used before e.printtrace)), BUG, INFO, WARN, ERROR, FATAL (more serious information) to go down more and more the finer
Before the debug information will be output
off will not be any output.
Not back to levels lower than his output, only output higher than their level.
console: the prescribed format in the console output.
f1 represented here in a file (file) inside output
during the testing phase less than basic file output, are in the console i see
The top console f1 These are user-defined
Parameters more important. General parameters are provided for your reference specification reference.
test:
Journaling technology, with the method of logging configuration logs
to a bytecode object, usually the current class
Themselves to define different messages to different levels
At this time if you do not want to export the configuration file which can be changed to off
it will be a lot easier than syso, without having to own a comment.
Create log files in the d disk, print it out
d tray will have this information console
After their program by adding the log output to replace syso output.
Source learning behind the framework has a lot of log output information. We add a jar package and configuration files you can see the information in the output of the frame.
在Servlet里面加日志jar包和配置文件 控制台没有输出的时候,说明Servlet里面没有
这些代码。
动态代理
MyBatis和Spring 框架的底层都有。
框架的底层:反射(核心),动态代理。
增强一个类的功能的方法:
之前用过:继承、重写:被增强的对象不能变,被增强的功能可以变。
==装饰者模式:==被增强的对象可以变,但是被增强的功能不能变。
动态代理: 被增强的对象可以变,被增强的功能可以变。
动态代理的实现:
Proxy:JDK 自带的动态代理:
cglib:
Java字节码增强:
实现:
得到目标对象的接口,接口里面的方法就是要被增强的方法
Proxy增强要求目标对象必须要有接口。
使用动态代理来创建代理对象
三种动态代理的条件:
注解:
以后写框架 要么用注解,要么用配置。
注解可以替换配置
Servlet 2.5只支持配置,不支持注解。
Servlet3.0都支持。
注解的属性必须加小括号,不是方法,就叫属性。
判断当前类是否有注解,有的话可以获取这个注解
注解属性的数据类型:
常用的八种:
String
enum(枚举)
Class反射类型
8种基本类型
注解类型
以上所有类型的一维数组。
JAVA里面的工厂:
简单工厂:
应用场景:一个父类,若干个子类,工厂创建子类对象。
To write an abstract product.
Writing product parent,
and then construct the plant.
Factory Method
A parent class (abstract products)
a number of subclasses (solid product).
A parent plant (abstract factory)
number of sub-class (physical plant)
Abstract Factory
A plurality of parent classes
several sub-class of each parent.
It is equivalent to