users@glassfish.java.net

Re: Sb know a way of execution external program on GF?

From: Markus KARG <markus.karg_at_gmx.net>
Date: Sat, 12 Apr 2008 09:07:51 +0200

The "official" way to run external programs from within a Java EE
enterprise application is to put your call of Runtime.exe() into the
outbound interface of a simple resource adapter. You could e. g. use
RAFC (to be found on source force) to set up such a RA in a few minutes.
The trick with putting that code into the RA and putting the RA into the
EAR is that RAs are allowed to call external programs by the spec,
because the call is not done by "your" code, but by the server, and the
server can be configured by the administrator regarding local file
access rights (not possible with "your" code, since not covered by the
spec, so it would be a security risk). RAs are intended to incorporate
an "dirty code", even native code!

The usage of such a RA is as easy as:
* inject a reference on it in the place of usage
* call the outbound's interface

:-)

Have Fun
Markus

glassfish_at_javadesktop.org schrieb:
> Hi there
> Sorry for silly question
> But i was wondering whether Glassfish AS has a convenient way to execute external program?
> Simply i really need to execute unix bash script in my EJB module running on glassfish, but everyone says that Runtime.exec() inside server is [b]bad[/b], cause in documentation we can read:
>
> [i]An enterprise bean must not use thread synchronization primitives to synchronize execution of multiple instances.
> ...
> The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt to start, stop, suspend, or resume a thread, or to change a thread s priority or name. The enterprise bean must not attempt to manage thread groups.[/i]
> [Message sent by forum member 'gregory_d3' (gregory_d3)]
>
> http://forums.java.net/jive/thread.jspa?messageID=268850
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
http://www.xing.com/go/invita/58469