"Daniel L. Rall" wrote:
 
> Is it okay for a Service to call it's own init() method (say, in its
> ctor)?

It looks like you misuderstood my conception. I believe that some
changes you made need to be reversed. Here is bit of explanation how
this works.

----------------------------------------------------------------------
Life cycle of a Service.

A Service (or any other Initable, if we had any) is not supposed 
to do much in it's constructor. Especialy it should not allocate
any costly resources like large memory structures, DB or network
connections and the like. It may well happen that the service
is sitting in the config file, but the application does not 
need it, so allocating all resources at system startup might
be a loss.

Early initialization is similar to the constructor. It is used
to pass some information that the Service will need in it's
future operation. For example WebMacro service uses ServletConfig
object to process it's own configuration options: getRealPath()
method is used to convert paths to WebMacro.properties and 
templates from relative to webapp root to absolute paths.
UniqueId service uses the HttpRequest object from the first Turbine
invocation to determine URL this instance is runnign under, to 
generate instance ID.
Early initialization method should process the configuration, store
some values, but NOT allocate resources. There is still a chance
that the service will not be used.
(Actually WebMacroService does this wrong, because it triggers 
it's late initailization inside early initialization. This needs
to be fixed sometime) 
If the service is ready to work, i.e. does not need any more objects
being sent to it, and does not to allocate any resources during
late initialization, they can change the internal state so that
getInit() returns true.

Late initialization happens when the Service is requested by the
application for the first time. It should allocate any resources
needed and chnge the state so that getInit() returns ture.
If getInit() returns false after init() being executed, it is
considered a malfunction of the service.

After late initialization service is ready to perform actions
on behalf of the application.

When service is no longer needed (this usually happens when 
system is shutting down) the shutdown() method is called.
It should deallocate all resources. If any error conditions
occur they are ignored.
-----------------------------------------------------------------------

Maybe we should put this into overview.html inside services package?

Rafal


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to