"ข้าแต่พระยาห์เวห์ พระราชกิจของพระองค์มีมากมายเพียงใด! พระองค์ทรงสร้างสิ่งทั้งปวงด้วยพระปัญญา แผ่นดินโลกเต็มไปด้วยสิ่งที่พระองค์ทรงสร้าง"
สดุดี 104:24
Language: English | Português (Brasil) | 简体中文 | 繁體中文 | 日本語 | 한국어 | Türkçe | Русский | Tiếng Việt | ไทย | Deutsch | Español
เฟรมเวิร์กที่เรียบง่ายสำหรับการพัฒนา Java แนวคิดเรียบง่าย ออกแบบดีขึ้น ใช้งานง่าย และมีประสิทธิภาพดี
- Java Development Kit (JDK) 17 หรือสูงกว่า
- Maven สำหรับจัดการ dependencies
- Text editor หรือ IDE เช่น IntelliJ IDEA, Eclipse หรือ VS Code
คุณสามารถใช้ archetype นี้เพื่อสร้างโปรเจกต์ที่ใช้ tinystruct ได้อย่างรวดเร็ว: https://github.com/tinystruct/tinystruct-archetype
- เพิ่ม dependency ใน pom.xml
<dependency>
<groupId>org.tinystruct</groupId>
<artifactId>tinystruct</artifactId>
<version>1.7.27</version>
<classifier>jar-with-dependencies</classifier> <!-- ไม่บังคับ -->
</dependency>- Extend AbstractApplication ใน Java:
package tinystruct.examples;
import org.tinystruct.AbstractApplication;
import org.tinystruct.ApplicationException;
import org.tinystruct.system.annotation.Action;
public class example extends AbstractApplication {
@Override
public void init() {
// TODO Auto-generated method stub
}
@Override
public String version() {
return "1.0";
}
@Action("praise")
public String praise() {
return "Praise the Lord!";
}
@Action("say")
public String say() throws ApplicationException {
if (null != getContext().getAttribute("--words"))
return getContext().getAttribute("--words").toString();
throw new ApplicationException("Could not find the parameter <i>words</i>.");
}
@Action("say")
public String say(String words) {
return words;
}
@Action(value = "hello", mode = Mode.HTTP_GET)
public String helloGet() {
return "GET";
}
@Action(value = "hello", mode = Mode.HTTP_POST)
public String helloPost() {
return "POST";
}
}Smalltalk: https://github.com/tinystruct/smalltalk
$ bin/dispatcher --version
_/ ' _ _/ _ _ _/
/ / /) (/ _) / / (/ ( / 1.7.27
/$ bin/dispatcher --help
Usage: bin/dispatcher COMMAND [OPTIONS]
A command line tool for tinystruct framework
Commands:
download Download a resource from other servers
exec To execute native command(s)
generate POJO object generator
install Install a package
maven-wrapper Extract Maven Wrapper
open Start a default browser to open the specific URL
say Output words
set Set system property
sql-execute Executes the given SQL statement, which may be an INSERT, UPDATE, DELETE, or DDL statement
sql-query Executes the given SQL statement, which returns a single ResultSet object
update Update for latest version
Options:
--allow-remote-access Allow to be accessed remotely
--help Help command
--host Host name / IP
--import Import application
--logo Print logo
--settings Print settings
--version Print version
Run 'bin/dispatcher COMMAND --help' for more information on a command.$ bin/dispatcher say/"Praise the Lord"
Praise the Lord$ bin/dispatcher say --words Hello --import tinystruct.examples.example
Hello# bin/dispatcher start --import org.tinystruct.system.HttpServer คุณสามารถเข้าถึง URL ต่อไปนี้:
$ wrk -t12 -c400 -d30s "http://127.0.0.1:8080/?q=say/Praise the Lord!"
Running 30s test @ http://127.0.0.1:8080/?q=say/Praise the Lord!
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 17.44ms 33.42ms 377.73ms 88.98%
Req/Sec 7.27k 1.66k 13.55k 69.94%
2604473 requests in 30.02s, 524.09MB read
Requests/sec: 86753.98
Transfer/sec: 17.46MBการรองรับมากกว่า 86,000 requests ต่อวินาที พร้อมค่า latency เฉลี่ยต่ำประมาณ 17.44ms แสดงว่า endpoint มีประสิทธิภาพสูงภายใต้โหลดหนัก สิ่งนี้แสดงพลังและประสิทธิภาพของ tinystruct framework แต่ไม่ใช่แค่ตัวเลขเท่านั้น ยังเกี่ยวกับ ปรัชญา เบื้องหลังด้วย
-
ไม่ต้องมีเมธอด
main()แอปพลิเคชันสามารถเริ่มได้โดยตรงผ่านคำสั่ง CLI เช่นbin/dispatcher -
ออกแบบรวมกันสำหรับ CLI และ Web tinystruct ให้ความสำคัญกับ CLI และ Web อย่างเท่าเทียม เหมาะกับงาน AI, script automation และแอปพลิเคชันแบบ hybrid
-
มี HTTP server แบบ lightweight ในตัว ไม่ว่าจะใช้ Netty หรือ Tomcat, tinystruct รวม lifecycle ของ server ไว้ใน framework
-
แนวคิด configuration ขั้นต่ำ Configuration ถูกจำกัดไว้เฉพาะส่วนจำเป็น ไม่ต้องมี beans, XML หรือ YAML มากเกินไป
-
Routing ด้วย annotation
@Actionให้กลไก routing ที่ชัดเจนและเข้าใจง่าย -
สถาปัตยกรรมที่ให้ความสำคัญกับ performance Overhead ต่ำมาก ไม่มี reflection-based bean scanning และไม่มี interceptor ที่ไม่จำเป็น
-
ให้อิสระกับนักพัฒนาโดยไม่เพิ่มความซับซ้อน tinystruct ช่วยให้นักพัฒนาโฟกัสกับ business logic จริง และออกแบบให้ โปร่งใส, คาดเดาได้, และ ขยายได้
Licensed under the Apache License, Version 2.0. คุณไม่สามารถใช้ไฟล์นี้ได้ เว้นแต่จะเป็นไปตาม license. สามารถดูสำเนา license ได้ที่:
http://www.apache.org/licenses/LICENSE-2.0
เว้นแต่กฎหมายที่เกี่ยวข้องกำหนดไว้หรือมีข้อตกลงเป็นลายลักษณ์อักษร ซอฟต์แวร์ที่แจกจ่ายภายใต้ license นี้ให้มาแบบ "AS IS" โดยไม่มีการรับประกันหรือเงื่อนไขใด ๆ
