At the risk of possibly stating the obvious...

It is possible to import classes at the top of your script e.g.
importClass(com.yourcompany.blah.blah.YourClass);

Inside script would be
var myClass = new Packages.com.yourcompany.blah.blah.YourClass();

For native java 
var bigDec = new java.math.BigDecimal(someIntVal);

For Avalong Components
var dao =
cocoon.getComponent(Packages.com.yourcompany.dao.DataAccessObject.ROLE);

Static method
var xml = Packages.com.yourcompany.util.SOAPController.call(params);

-----Original Message-----
From: Joerg Heinicke [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 25 May 2004 9:35 AM
To: [EMAIL PROTECTED]
Subject: Re: Calling java from flowscripts: best practices?

On 24.05.2004 09:02, Thomas Kjeldahl Nilsson wrote:

> The "official" cocoon doc is somewhat short on info best practices in 
> flowscript->java situations. My current impression is "you can 
> instantiate classes, call static methods without instantiating, or
wrap 
> your code into Avalon components that may or may not give you 
> performance benefits." :-)

It's a new technology and there are not many people having so much 
experience for providing best practices. I did it with an Avalon 
component, but I can't imagine that this solution is faster than 
instantiating a plain java object as you have to assign the Avalon 
lifecycle (I use Cocoon logging in my class). Even pooling will not elp 
much as a lookup often takes more time than an instantiation. But this 
depends obviously heavily on the class to instantiate of course. If you 
need heavy calculation for it, remote lookups, etc. it will be probably 
better to pool it. Otherwise not.

All IMO.

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to