From 02478994a3aa6a3c1ee966bd9f060e78ad5d7f30 Mon Sep 17 00:00:00 2001 From: openeuler_bot Date: Sun, 17 Aug 2025 02:48:15 +0000 Subject: [PATCH] 24.03-lts-sp1 update netty to 4.2.4.Final --- .../4.2.4.Final/24.03-lts-sp1/Dockerfile | 36 +++++++++++ .../4.2.4.Final/24.03-lts-sp1/NettyDemo.java | 60 +++++++++++++++++++ .../24.03-lts-sp1/pom.xml.template | 40 +++++++++++++ Others/netty/meta.yml | 3 + 4 files changed, 139 insertions(+) create mode 100644 Others/netty/4.2.4.Final/24.03-lts-sp1/Dockerfile create mode 100644 Others/netty/4.2.4.Final/24.03-lts-sp1/NettyDemo.java create mode 100644 Others/netty/4.2.4.Final/24.03-lts-sp1/pom.xml.template diff --git a/Others/netty/4.2.4.Final/24.03-lts-sp1/Dockerfile b/Others/netty/4.2.4.Final/24.03-lts-sp1/Dockerfile new file mode 100644 index 00000000..3866ec3b --- /dev/null +++ b/Others/netty/4.2.4.Final/24.03-lts-sp1/Dockerfile @@ -0,0 +1,36 @@ +ARG BASE=openeuler/openeuler:24.03-lts-sp1 +FROM ${BASE} as BUILDER +ARG TARGETARCH +ARG BUILDARCH +ARG VERSION=4.2.4.Final +ARG JDK_VERSION=17.0.12 + +RUN dnf update -y \ + && dnf install -y wget maven gettext \ + && dnf clean all \ + && rm -rf /var/cache/dnf + +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + BUILDARCH="x64"; \ + elif [ "$TARGETARCH" = "arm64" ]; then \ + BUILDARCH="aarch64"; \ + fi \ + && cd / \ + && wget https://download.oracle.com/java/17/archive/jdk-${JDK_VERSION}_linux-${BUILDARCH}_bin.tar.gz \ + && tar -zxvf jdk-${JDK_VERSION}_linux-${BUILDARCH}_bin.tar.gz \ + && rm -f jdk-${JDK_VERSION}_linux-${BUILDARCH}_bin.tar.gz + +ENV JAVA_HOME=/jdk-17.0.12 +ENV PATH=/jdk-17.0.12/bin:$PATH + +WORKDIR /opt/netty + +COPY NettyDemo.java src/main/java/demo/NettyDemo.java +COPY pom.xml.template pom.xml.template + +ENV NETTY_VERSION=${VERSION}.Final + +RUN envsubst < pom.xml.template > pom.xml \ + && mvn clean package -Dfile.encoding=UTF-8 + +CMD ["java", "-cp", "target/netty-demo-1.0-SNAPSHOT.jar", "demo.NettyDemo"] diff --git a/Others/netty/4.2.4.Final/24.03-lts-sp1/NettyDemo.java b/Others/netty/4.2.4.Final/24.03-lts-sp1/NettyDemo.java new file mode 100644 index 00000000..fca4dfd8 --- /dev/null +++ b/Others/netty/4.2.4.Final/24.03-lts-sp1/NettyDemo.java @@ -0,0 +1,60 @@ +package demo; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.*; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioServerSocketChannel; + +public class NettyDemo { + private final int port; + + public NettyDemo(int port) { + this.port = port; + } + + public void start() throws InterruptedException { + EventLoopGroup bossGroup = new NioEventLoopGroup(1); + EventLoopGroup workerGroup = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new ChannelInitializer() { + @Override + public void initChannel(SocketChannel ch) { + ch.pipeline().addLast(new NettyHandler()); + } + }); + + ChannelFuture f = b.bind(port).sync(); + System.out.println("Echo server started on port " + port); + f.channel().closeFuture().sync(); + } finally { + bossGroup.shutdownGracefully(); + workerGroup.shutdownGracefully(); + } + } + + public static void main(String[] args) throws InterruptedException { + new NettyDemo(8080).start(); + } +} + +class NettyHandler extends ChannelInboundHandlerAdapter { + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) { + ctx.write(msg); + } + + @Override + public void channelReadComplete(ChannelHandlerContext ctx) { + ctx.flush(); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { + cause.printStackTrace(); + ctx.close(); + } +} diff --git a/Others/netty/4.2.4.Final/24.03-lts-sp1/pom.xml.template b/Others/netty/4.2.4.Final/24.03-lts-sp1/pom.xml.template new file mode 100644 index 00000000..f34be971 --- /dev/null +++ b/Others/netty/4.2.4.Final/24.03-lts-sp1/pom.xml.template @@ -0,0 +1,40 @@ + + 4.0.0 + + org.example + netty-demo + 1.0-SNAPSHOT + + + UTF-8 + 17 + 17 + + + + + io.netty + netty-all + ${NETTY_VERSION} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + shade + + + + + + + diff --git a/Others/netty/meta.yml b/Others/netty/meta.yml index 14e6a7d8..756aa8bb 100644 --- a/Others/netty/meta.yml +++ b/Others/netty/meta.yml @@ -1,3 +1,6 @@ 4.2.1-oe2403sp1: path: 4.2.1/24.03-lts-sp1/Dockerfile + +4.2.4.Final-oe2403sp1: + path: 4.2.4.Final/24.03-lts-sp1/Dockerfile \ No newline at end of file -- Gitee