I-Jetty or Jetty

2019-04-01 03:13发布

I have a web application to be hosted on android device. I am currently using the emulator available with android sdk. My application will serve both static as well as dynamic data. I am currently using jetty version 6.1.22. I wanted to ask what will be a better option to be used. 1. Jetty webserver with stripped off code. 2. I-Jetty.

My application uses following features-

  • ResourceHandler to serve static resources.
  • A Generic servlet to serve synchronous data requests.
  • An extension to CometServlet to serve asynchronous data requests.

I am looking forward to following criteria for comparison.

  • Application size. Size of apk which will contain the code.
  • Memory and CPU usage under a maximum load of 30 requests/sec. These are short bursts which occur very few times in app-life cycle. The average load would be approximately 5 requests/sec.
  • Ease of maintenance. Including important upgrades of Jetty in application.
  • Any other side-effects which I probably am missing out at.

4条回答
仙女界的扛把子
2楼-- · 2019-04-01 03:54

There are good reasons for embedding a web server in your app. May not be the best way but you have to do it when Android ties your hands. An example is when you want to decrypt video on the fly at runtime and use the media player to play it. Android media player does not allow me to feed it an in-memory stream as would come from a decryption pipe.

In this case, one solution (help me think of others please!) is to embed a web server that would serve up the stream - because Android does accept a stream from a URL!!

The other solution would be port some native library over and write a JNI interface to it. Too much work and unstable at best.

The point is, there are valid enough reasons out there.

查看更多
Evening l夕情丶
3楼-- · 2019-04-01 04:08

I have a web application to be hosted on android device.

Why? It won't be usable, except maybe on a WiFi LAN. It won't be able to run terribly long, because services cannot run forever. Etc.

Whatever technical problem you think you're solving by using a Web server on Android can be better solved by other means.

I wanted to ask what will be a better option to be used. 1. Jetty webserver with stripped off code. 2. I-Jetty.

Arguably "neither", not only due to the technical issues, but that Greg Wilkins (creator of Jetty) does not like Android much. Of the two, though, i-jetty is at least regularly tested on Android.

Memory and CPU usage under a maximum load of 30 requests/sec. These are short bursts which occur very few times in app-life cycle. The average load would be approximately 5 requests/sec.

While running, battery life will suck, because you are going to keep the CPU and WiFi running all of the time to support the Web server, let alone the load.

查看更多
三岁会撩人
4楼-- · 2019-04-01 04:15

I too have been searching for information on embedding the i-Jetty server in an application. Like the original poster, I need to serve both static and dynamic resources. I found the following post to be a helpful start:

http://puregeekjoy.blogspot.com/2011/06/running-embedded-jetty-in-android-app.html

I notice that in searching for answers about embedding a web server in an Android app that many responders, rather than providing a helpful answer, chide the original poster for wanting to do such a thing "in a phone". They then proceed to give all the reasons not to. There are more Android devices out there than just phones. My project involves just such a device. Thanks for all the helpful answers on this and other sites that guided me in my efforts. I hope the link I provided helps other searchers.

查看更多
神经病院院长
5楼-- · 2019-04-01 04:16

It you need to decrypt video or serve content, you might consider just writing a simple web server yourself that can specifically handle your application's needs without any bloat. Adding an existing web server or web container might be more than you need. It very much depends on your application's needs though.

查看更多
登录 后发表回答