Hi All,
Hope all is well!
We all know that Avalon has super cool lifecycle management offering a way
to construct arbitrary components in defined manner. One limitation by
this though is the requirement of a zero argument constructor.
This requirement is ok for many components but sometimes I miss this
especially when writing components that need some external data dynamically
before they can be considered valid.
For the lack of a better example, think of a Date component that needs
to be given a real date value before it can be used. Outside of Avalon one
might write:
MyDate date = new MyDate("20030607");
When using Avalon however, after creation through the normal lifecycle we
must set the date on the component with some set* method.
MyDate date = (MyDate) m_manager.lookup(MyDate.ROLE);
date.setDate("20030725");
This means however that the component is not valid though until an external
(meaning non-lifecycle method) has been invoked on it, which we can't
enforce -> meaning we have to document somewhere that a user must
call the set* before calling any other method.
It also means, if we're being proactive that in all of the other methods we
have to watch for the case when the user doesn't invoke the set* method,
and throw an appropriate exception, etc.
A possible way to fix this could be to offer Parameterized lookups,
something like:
interface ServiceManager {
Object lookup(String role, Object[] parameters);
}
where 'parameters' specifies arbitrary number of parameters that can be
passed through to the component manager and given to the object to be
constructed somehow (eg. lifecycle extension, matching parameter constructor,
component handler, new lifecycle stage, etc).
This would let us do something like:
MyDate today = (MyDate) m_manager.lookup(MyDate.ROLE, { "20030725" } );
Thoughts anyone? Perhaps there's an even better solution out there ?
Cheers,
Marcus
--
.....
,,$$$$$$$$$, Marcus Crafter
;$' '$$$$: Computer Systems Engineer
$: $$$$: ManageSoft GmbH
$ o_)$$$: 82-84 Mainzer Landstrasse
;$, _/\ &&:' 60327 Frankfurt Germany
' /( &&&
\_&&&&'
&&&&.
&&&&&&&:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]