From 5065ebbdd501aea0f4ada9d8bcf7a2fd34155955 Mon Sep 17 00:00:00 2001 From: ZhangXushuo <3508242435.com> Date: Tue, 31 Oct 2023 23:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 38 ++++++ .idea/.gitignore | 8 ++ .idea/encodings.xml | 10 ++ .idea/kotlinc.xml | 6 + .idea/misc.xml | 14 +++ .idea/vcs.xml | 6 + maven/.gitignore | 38 ++++++ maven/pom.xml | 20 +++ pom.xml | 115 ++++++++++++++++++ src/main/java/com/pool/Main.java | 7 ++ .../java/com/pool/Service/MyRedisPool.java | 27 ++++ src/main/java/com/pool/Service/RedisPool.java | 8 ++ src/main/java/webapp/WEB-INF/web.xml | 14 +++ src/main/java/webapp/index.jsp | 5 + 14 files changed, 316 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/encodings.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 maven/.gitignore create mode 100644 maven/pom.xml create mode 100644 pom.xml create mode 100644 src/main/java/com/pool/Main.java create mode 100644 src/main/java/com/pool/Service/MyRedisPool.java create mode 100644 src/main/java/com/pool/Service/RedisPool.java create mode 100644 src/main/java/webapp/WEB-INF/web.xml create mode 100644 src/main/java/webapp/index.jsp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..10d6311 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..0dd4b35 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..82dbec8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/maven/.gitignore b/maven/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/maven/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/maven/pom.xml b/maven/pom.xml new file mode 100644 index 0000000..426fa33 --- /dev/null +++ b/maven/pom.xml @@ -0,0 +1,20 @@ + + + 4.0.0 + + com.pool + write-pool + 1.0-SNAPSHOT + + + maven + + + 17 + 17 + UTF-8 + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6c336c1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + + com.pool + write-pool + 1.0-SNAPSHOT + pom + + + maven + + + + 17 + 17 + UTF-8 + + + com.pool Maven Webapp + http://www.example.com + + + + org.slf4j + jul-to-slf4j + 2.0.9 + test + + + org.apache.tomcat.embed + tomcat-embed-core + 9.0.76 + + + org.springframework.boot + spring-boot-autoconfigure + 2.7.13 + + + org.springframework.boot + spring-boot-test + 2.7.8 + test + + + org.springframework + spring-test + 5.3.28 + test + + + redis.clients + jedis + 3.7.1 + + + com.pool + write-pool + 1.0-SNAPSHOT + + + org.springframework + spring-context + 5.3.28 + + + junit + junit + 4.12 + test + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + + com.mavenKuang + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-war-plugin + 3.2.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + + diff --git a/src/main/java/com/pool/Main.java b/src/main/java/com/pool/Main.java new file mode 100644 index 0000000..b910535 --- /dev/null +++ b/src/main/java/com/pool/Main.java @@ -0,0 +1,7 @@ +package com.pool; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/src/main/java/com/pool/Service/MyRedisPool.java b/src/main/java/com/pool/Service/MyRedisPool.java new file mode 100644 index 0000000..e00cd6b --- /dev/null +++ b/src/main/java/com/pool/Service/MyRedisPool.java @@ -0,0 +1,27 @@ +package com.pool.Service; + +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.atomic.AtomicInteger; + +@Component +public class MyRedisPool implements RedisPool{ + private final AtomicInteger count =new AtomicInteger(); + private int maxTotal; + private long maxWaitMillis; + private LinkedBlockingDequeidleObjects=null; + private LinkedBlockingDeque activeObjects=null; + @Override + public void init(int maxTotal, long maxWaitMillis) { + this.maxTotal=maxTotal; + this.maxWaitMillis=maxWaitMillis; + idleObjects = new LinkedBlockingDeque<>(maxTotal); + activeObjects =new LinkedBlockingDeque<>(maxTotal); + } + + @Override + public void release(redis.clients.Jedis jedis) { + if (activeObjects.remove(jedis)){ + idleObjects.offer(jedis); + } + } +} diff --git a/src/main/java/com/pool/Service/RedisPool.java b/src/main/java/com/pool/Service/RedisPool.java new file mode 100644 index 0000000..2e80116 --- /dev/null +++ b/src/main/java/com/pool/Service/RedisPool.java @@ -0,0 +1,8 @@ +package com.pool.Service; +import redis.clients.jedis.Jedis; +public interface RedisPool { + public void init(int maxTotal,long maxWaitMillis); + public Jedis getResource() throws Exception; + public void release(Jedis jedis); + +} diff --git a/src/main/java/webapp/WEB-INF/web.xml b/src/main/java/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..6e97a6e --- /dev/null +++ b/src/main/java/webapp/WEB-INF/web.xml @@ -0,0 +1,14 @@ + + + + + + + Title + + + + Archetype Created Web Application + + + diff --git a/src/main/java/webapp/index.jsp b/src/main/java/webapp/index.jsp new file mode 100644 index 0000000..0211f03 --- /dev/null +++ b/src/main/java/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hell World!

+ +