I would like to know if it is possible to start a main method of sample java application on the glassfishV3 server. Is it possible to start main? I would like to bind to socket in it to receive data from another clients applications using my custom protocol. Then send the data over the JMS to another components. I wouldnt like to use Web services because I dont need to send "long" xml files, just a little package of data, but I need it has to be fast. Thanks.
1 Answers
I think you have to be more specific here. A main method is nothing but a regular static method. You can invoke from where ever you want (of course its class has to be on the classpath)...
Do you want to invoke it from a webapplication? An ejb-module? A packaged enterprise application? Which version of glassfish are we talking about? If you're using Java EE 6 compliant version maybe you should have a look at @Singleton and @Startup as described in Oracle's Java EE 6 Tutorial http://docs.oracle.com/javaee/6/tutorial/doc/gipvi.html
I know that you didnt ask for it, but generally I think it's not a good idea starting the static main method from glassfish. Maybe you should have a look at JCA and this stackoverflow thread: an EAR (Java EE) application which listen to a socket request