沒有 HTTP 的 Java 應用服務器 (Java application server without HTTP)


問題描述

沒有 HTTP 的 Java 應用服務器 (Java application server without HTTP)

我有一個用 C++/C# 編寫的客戶端軟件和一個數據庫。現在不想讓客戶端直接訪問數據庫,於是想到了在中間放一個應用服務器。這應該從客戶端得到一個簡短的請求,向數據庫請求新數據,進行一些過濾(在 sql 中無法完成),然後將數據返回給客戶端。

我的搜索這種軟件把我帶到了 Glassfish 或 Tomcat,但我理解的問題是,這些軟件總是想用 html/jsp 來談 http。因為無論如何我的大部分數據都是加密的,所以我不需要這樣的純文本協議,並且對只需要字節流的東西完全滿意。另一方面,讓服務器為我處理線程池會很好(不想從頭開始實現所有這些)。<


參考解法

方法 1:

Jetty and Tomcat are so called servlet container and thus primarly targeted at HTTP exchanges. Glassfish is an application server that uses a servlet container as one of its modules. I would stop thinking in that direction ‑ that's all more like web applications and web services ‑ some levels too high what you are asking for.

I think you should more look into sth. like Netty which is merley a "high performance protocol" server. Take a look at the documentation here (even some sort of tutorial there which might fit your use case).

方法 2:

GlassFish is an "enterprise application server", targeting the Java EJB specification. That's surely overdone for your purpose. You can give Tomcat a try. It is a "servlet container", targeting Java Servlet specification. Servlets have one purpose: listening to an incoming URL (request), executing Java code and returning a response, usually over HTTP.

For sure, you may start your own (plain) ServerSocket, for example using a ServletContextListener (which will be started once your application starts). But you should go for a higher protocol to send the data, like Hessian and Burlap, which is implemented in both, Java and C++ and easy to set up.

(by Daniel SchulzespaStefan)

參考文件

  1. Java application server without HTTP (CC BY‑SA 2.5/3.0/4.0)

#java #tomcat #bytestream #glassfish






相關問題

電子郵件地址中帶有 + 字符的 Java 郵件 (Java mail with + character in email address)

如何快速原型化 Java 代碼? (How to quickly prototype Java code?)

如何使用 Maven 在目標(SVN-)服務器上創建 Javadoc? (How to create Javadoc on the target (SVN-) server using Maven?)

為什麼檢查二叉樹有效性的解決方案不起作用? (Why the solution for checking the validity of binary tree is not working?)

Selenium webdriver通過第一個數字找到texy (Selenium webdriver find texy by first digits)

setOnClickListener 沒有在圖像視圖上被調用 (setOnClickListener is not getting called on image view)

繪製多邊形:找不到錯誤 (Drawing Polygon : unable to find error)

半透明 JButton:對像出現在背景中 (Semi-Transparent JButton: Objects appear in Background)

比較同一數組的元素 (Compare elements of the same array)

Java 屏幕截圖小程序 (Java screen capture applet)

Minecraft 1.8.9 Forge Modding 的Java 開發工具包,需要什麼JDK/JRE,代碼是否正確? (Java Development Kit with Minecraft 1.8.9 Forge Modding, What JDK/JRE Is Needed, Is Code Correct?)

java while (resultset.next()) 不返回同一列中的所有數據 (java while (resultset.next()) does not return all data in the same column)







留言討論