pkpk1234 / beggarservletcontainer Goto Github PK
View Code? Open in Web Editor NEW乞丐版servlet容器
乞丐版servlet容器
ServerFactory只应该根据传入的config信息构造Server,而不是每次都去改工厂
使用责任链模式编写BodyParser:用于支持多种类型的Body
NIOEventListener中莫名其妙出现了SelectionKey
NIOEchoEventHandler也不应该和SelectionKey强耦合
如果是返回文件内容的功能,那样的话,大段大段的文件读写代码是完全无法复用的
public static Server getServer(ServerConfig serverConfig) {
List connectorList = new ArrayList<>();
SocketEventListener socketEventListener =
new SocketEventListener(new FileEventHandler(System.getProperty("user.dir")));
ConnectorFactory connectorFactory =
new SocketConnectorFactory(new SocketConnectorConfig(serverConfig.getPort()), socketEventListener);
connectorList.add(connectorFactory.getConnector());
return new SimpleServer(serverConfig, connectorList);
}
一个Connector只能绑定一端口,这段代码不能扩展,因为端口指定给Server了:
即无法同时监听18080、18443了——在外部将Connector和端口绑定,传入Server中。
一直在看,写的很不错,问下之后是否考虑使用netty重构通信的部分?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.