Can you be a bit more elaborate when you say "run plain java classes in a server instead of a JVM"
can you be specific on "server" here. Because a server is just an application that responds to incoming requests and thus serving the clients. That server application can be a java class.
To run a java class, you need 'java' interpretter that needs jvm to execute.
even your server might be running under a jvm.
Joined: Jun 12, 2004
Let me elaborate..
For a certain requirement, a plain java class running in a JVM wud suffice but my architect is insistent on deploying it in a server. So, I need the pros & cons of running this class in a server so as to argue for / against this design.
I like this definition of server: A process that accepts connections from clients. This kind of environment is necessary if you want the code to run on another machine or a separate process on your own machine. You connect, send your request, it does the work, sends a response.
Your architect may just want to run one copy of the code on some machine so that you or any other user can connect and have it do some work. Talk it over see what reasons they have ... better sharing, central deployment, central management for start & stop, etc. And see how they define "server". It might be ok for your POJO to open a socket and act as a server itself, or they might have reason to run within a container like a servlet or EJB engine.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I also same kind of requirement. I have plain simple java class where class has its own main method, which I wanted to run in JBoss 3.2.6 so any user can use that class. To be specific I have JMS class which just send and receive messages to server. I created destination within JBoss so my JMS class has to send message to registered destination in JBoss. Could anybody enlighten me on this I know that JBoss support deployment of POJOs. Thanks
Joined: Jan 29, 2003
Ah, you've added the special sauce that the previous part of the thread didn't have ... the JMS listener! You should be in great shape. Your listener can call methods on a POJO like String, so it can call methods on your class just as well. It can even invoke main() since main is a perfectly normal public static method.
MyClass.main( args );
I personally know zip about deployment, but you should be able to put your POJO in a "utility jar" (is that a common EJB term or just WebSphere?) or the same package & jar as your listener.
I'm a little curious what this thing is going to do. If you run main() you won't get any return value. If it just does a little work and doesn't need to report back, it should be fine, tho.
Sorry if that start out a bit smart-a** in tone. It's neat to realize how little magic there is in the world. Running inside a server is not that big a deal in many ways, and main() has no voodoo at all - it just happens to be the method that java.exe likes to call.
Let me know if all that works out for you! [ June 10, 2005: Message edited by: Stan James ]