-1

I need to build a Java app to run like a daemon on UNIX (FreeBSD). The app would need to start up just like any UNIX process. After starting, it sits there and wait for commands from the master host/server. Commands are fed to this app via RESTful web services calls - so it needs to listen for network connections at a particular port. At the same time, it needs to access resouces at external hosts/websites by making outgoing http calls.

What is the best approach for writing such app? I am thinking of writing a standalone app and include Grizzly and Jersey libraries. Is this the right approach? Is there a better approach?

(Also, I don't think I should write a normal web application - war file - to be deployed in GlassFish or some sort of Java container.)

ikevin8me
  • 4,253
  • 5
  • 44
  • 84
  • 2
    Stackoverflow is for asking about problems in code, _showing_ code. You need general assistance for designing your application which belongs on Programmers, where it will most likely be closed due to be to vague. – Thorbjørn Ravn Andersen Aug 18 '12 at 13:44
  • No matter what you do, it will be a process. Nothing can run on a UNIX system besides the kernel that isn't a process. Even `init` is just a normal process. – Linuxios Aug 18 '12 at 17:45

2 Answers2

2

What is the best approach for writing such app?

There is no single best approach.

I am thinking of writing a standalone app and include Grizzly and Jersey libraries. Is this the right approach?

It will work, assuming that you follow the relevant documentation.

Is there a better approach?

Possibly.

(Also, I don't think I should write a normal web application - war file - to be deployed in GlassFish or some sort of Java container.)

That is another approach.

Another would be to use a light-weight container like Jetty.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • I'd would appreciate if you could explain why do I need to use Jetty if I can listen to HTTP connections using Grizzly, as written in this article:http://stackoverflow.com/questions/6050407/grizzly-jersey-listening-only-on-localhost – ikevin8me Aug 18 '12 at 15:13
  • You don't have to use Jetty. Grizzly and Jetty are alternatives. The whole point of my answer is that there are alternatives, and YOU need to weigh up the pros and cons FOR YOUR APPLICATION. – Stephen C Aug 19 '12 at 00:36
0

If you want your application to run all the time and accept RESTful web service calls, then in my opinion your best option is to have a normal web application running under some web web server that contains all of the methods your application needs (Tomcat, Glassfish, etc.).

HeatfanJohn
  • 7,143
  • 2
  • 35
  • 41