I was wondering if anyone could enlighten me as to the best way to call runtime.exec() from an ejb. Now, I know that the spec disallows it and really I would prefer to adheer to the spec.
So, is the only other option setting up a Corba service and running it that way ? If anyone has any experience with this or any ideas I would really like to hear them.
I think you can call it directly from the EJB as long as you really know what you are doing. (Like breaking the spec.)
And you should know that the Java code depends on the operating system. However, this can be solved with some variant of the Abstract Factory pattern (together with a Singleton) where you define an interface for the abstract factory and put the implementation's implementing class as configuration. Then you have to implement and test one class for every new oåerating system.
Examples of similar things in the Java API are the JDBC driver and the DOM API for XML. And the most obvious example should be the InitialContext!
Thanks for the interesting reply, do you not mean the Factory Method pattern though (as opposed to the Abstract Factory Pattern) ?
Actually that is a big no-no. EJBs are not allowed to use any thread mechanisms or OS commands. What exactly are you tryign to do?
Issuing an OS call from an EJB is a potential security hole. Do not do this. Consider making that other service available online and access it as a web service. Without knowing specifically what you're trying to do, it's difficult to make further suggestions.
Thanks for all the suggestions,
What we need to do is to be able to run an executable from our ejb's. However, I do reckognise the problems associated with this and what the spec states.
I think the way forward is to make the executable available as a web service (as suggested) and use it that way. In fact we are currently looking at IBM's BPWS4J for web services integration, it seems to work very well .... so far.
I'm glad that you found my suggestion helpful. I wish you the best of luck with the design choice you've made. It should work well for you.