Netty入门与实践
NettyNetty 是一个异步的、基于事件驱动的网络应用框架,用于快速开发可维护、高性能的网络服务器和客户端
Netty的异步还是基于多路复用的,并没有实现真正意义上的异步IO
Hello world
服务端代码
123456789101112131415161718192021222324252627282930public class HelloServer { public static void main(String[] args) { // 1.启动器 负责组装netty组件 启动服务器 new ServerBootstrap() // 2.BossEventLoop WorkerEventLoop(selector, thread) 组成NioEventLoop .group(new NioEventLoopGroup()) // 3.选择服务器ServerSocketChannel的实现 .ch ...
Non-blocking I/O
ByteBufferJava NIO系统的核心在于:通道(Channel)和缓冲区(Buffer)。通道表示打开到 IO 设备(例如:文件、套接字)的连接。若需要使用 NIO 系统,需要获取用于连接 IO 设备的通道以及用于容纳数据的缓冲区。然后操作缓冲区,对数据进行处理
ByteBuffer入门案例首先我们创建一个txt文件,其内容为:
11234567890abc
接着编写代码获取文件内容
1234567891011121314151617181920212223242526@Slf4jpublic class TestByteBuffer { public static void main(String[] args) { // 获取Channel 这里获取的是FileChannel try (FileChannel channel = new FileInputStream("data.txt").getChannel()) { // 准备缓冲区 B ...
Spring小记
Spring 小记摘抄自 Spring揭秘
BeanFactoryProcessor
PropertyPlaceholderConfiguration: 帮助解析xml文件中的数据源配置内容
123456<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"></property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.username}& ...






