guanpengchn / guanpengchn/guanpengchn.github.io
源代码阅读笔记
- Dominant language
- HTML
- Stars
- 18
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
- [SPI](https://www.cnkirito.moe/spi/)
以JDBC为例,本质就是将mysql或者postgresql注册到`java.sql.DriverManager`的`java.util.ServiceLoader`中,注册过程中在`java.sql.DriverManager`的`loadInitialDrivers`函数里调用了Class.forName(),之后每次判断是哪个驱动的时候就去遍历,源代码如下
```java
private static void loadInitialDrivers() {
String drivers;
try {
drivers = AccessController.doPrivileged(new PrivilegedAction() {
public String run() {
return System.getProperty("jdbc.drivers");
}
});
} catch (Exception ex) {
drivers = null;
}
AccessController.doPrivileged(new PrivilegedAction() {
public Void run() {
ServiceLoader loadedDrivers = ServiceLoader.load(Driver.class);
Iterator driversIterator = loadedDrivers.iterator();
try{
while(driversIterator.hasNext()) {
driversIterator.next();
}
} catch(Throwable t) {
// Do nothing
}
return null;
}
});
println("DriverManager.initialize: jdbc.drivers = " + drivers);
if (drivers == null || drivers.equals("")) {
return;
}
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {
try {
println("DriverManager.Initialize: loading " + aDriver);
Class.forName(aDriver, true,
ClassLoader.getSystemClassLoader());
} catch (Exception ex) {
println("DriverManager.Initialize: load failed: " + ex);
}
}
}
```
- [Spring揭秘--寻找遗失的web.xml](https://www.cnkirito.moe/servlet-explore/)
- JSP Model 2 具备了使用MVC模式实现的Web应用架构的雏形
- [java注解是怎么实现的?](https://www.zhihu.com/question/24401191)
- [Spring SimpleFormController in 3.0 not found](https://stackoverflow.com/questions/4734259/spring-simpleformcontroller-in-3-0)
找不到SimpleFormController类似的Controller类了,原因是都被注解替换掉了
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue contains source-reading notes about Java SPI, JDBC, Spring, and servlet topics, plus links to external references, but names no repository file or concrete change. Start by reviewing the issue body and linked resources; a contribution is done only when the intended note structure and target location are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mysql, postgresql, spring
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100