Hello Leo,
Tuesday, June 10, 2003, 4:11:07 PM, you wrote:
LS> Anton Tagunov wrote:
>> This mail is on introduction of WriteProtectable/ReadOnly.
>> Do you think it's a good idea to put them somewhere to the
>> framework
LS> WriteProtectable and ReadOnly are not really part of the
LS> container-component contract: a container does not tell a hosted
LS> component to become "readonly". The container doesn't care; this kind of
LS> behaviour can be configured using a configuration or perhaps metadata.
LS> In avalon, the currently existing makeReadOnly() calls are not made on
LS> things which classify as "avalon components" and/or "avalon services",
LS> rather, they are implementation-specific.
LS> As such, a WriteProtectable would fit roughly the same role inside
LS> avalon-framework as, for example, CascadingThrowable currently does.
LS> Just like in an indeal world we would replace CascadingThrowable with
LS> Nestable inside commons-lang, WriteProtectable might live there as well.
LS> What we have here is a *generic aspect*: "read/write capability" of a
LS> generic java class. Here's a grid which one might fill in any way:
LS> |yes | no | configurable (once) | configurable n times
LS> -------------------------------------------------------------
LS> read | | | |
LS> write | | | |
LS> -------------------------------------------------------------
LS> where for a particular component there is one type of "read" behaviour
LS> and one type of "write" behaviour.
LS> You could model as follows:
LS> interface Readable {}
LS> interface ReadProtectable extends Readable { void disableRead() }
LS> interface ReadConfigurable extends Writeable { void enableRead() }
LS> interface Writeable {}
LS> interface WriteProtectable extends Writeable { void disableWrite() }
LS> interface WriteConfigurable extends WriteProtectable {
LS> void enableWrite() }
LS> where you pick one from both lists, and for a class failing to do that a
LS> sensible default is decided upon.
LS> For these interfaces to make most sense, they should probably live in
LS> java.lang, and be universally adopted early on. Doing this for lots of
LS> concerns means you get lots and lots of tiny interfaces, some of which
LS> might not be used.
LS> Which really doesn't work so well. Consider the amount of ServiceManager
LS> implementations in existence which expose a makeReadOnly() method but do
LS> not implement WriteProtectable, for example.
LS> A "language extension" of some kind is in order:
LS> class MyBean [Readable,Writeable] { /* ... */ }
LS> of course, language extensions usually are problematic (despite the
LS> success of AspectJ, which is just not quite successful enough), so
LS> there's various ways to do the same thing. Naming conventions perhaps
LS> (use introspection to search for "makeReadOnly()" and/or
LS> "makeWriteable()" methods for example, in place of instanceof), or a
LS> MyBeanBeanInfo class describing the behaviour for example, or an
LS> .xprofile xml descriptor file doing the same, or information stored
LS> inside the class definition based on javadoc tags
LS> /** @bean readable="true" writeable="configurable" */
LS> class MyBean { /* ... */ }
LS> Using any of those options helps keep the codebase leaner and meaner and
LS> scales better with the addition of different aspects. So in conclusion I
LS> think that the interfaces you propose might make sense to include in
LS> java.lang (failing that, commons-lang :D), that they should not live in
LS> avalon-framework as they are more generic than the rest of
LS> avalon-framework and have nothing to do with the container-component,
LS> but that,
I will try to reply to bits of your mail
out of order, please let this not confuse you.
LS> Also, I bet that answer's longer than you expected! 8-)
Absolutely! I win the bet ;-)
For one, Berin has already made me understand
that only one class would be enough for what
I want. And ReadOnly marker interface would
be an evil as a derived class might already
be quite read-write while not being able
to remove the "implements ReadOnly" from itself.
LS> |yes | no | configurable (once) | configurable n times
LS> -------------------------------------------------------------
LS> read | | | |
LS> write | | | |
LS> -------------------------------------------------------------
yes, this looks like being most generic, but
for what I'm speaking about (see my mail to Niclas)
"augmenting factory method" pattern, a WriteProtecteable
would be enough (with a no-op implementation for
what we have called ReadOnly objects).
LS> As such, a WriteProtectable would fit roughly the same role inside
LS> avalon-framework as, for example, CascadingThrowable currently does.
LS> Just like in an indeal world we would replace CascadingThrowable with
LS> Nestable inside commons-lang, WriteProtectable might live there as well.
Absolutely!
LS> given the fact that they would be added as an afterthought
LS> which would require source code modification for any existing
LS> implementations of the behaviour, are probably better modelled in a
LS> different way.
yes and no here, see bellow...
LS> Consider the amount of ServiceManager
LS> implementations in existence which expose a makeReadOnly() method but do
LS> not implement WriteProtectable, for example.
It's even worse. I want to oblidge _every_ implementation of
ServiceManager that would be possible to be return from the
fortress/impl/AbstractContainer.java|provideServiceManager()
method to implement WriteProtectable. (Before I wanted it to be
either WP or RO, but as we have just nuked RO only WP remains).
But it's also better then what you describe.
I want only objects returnable from
fortress/impl/AbstractContainer.java|provideServiceManager()
fortress/impl/AbstractContainer.java|provideComponentContext()
methods to be oblidged to implement WriteProtectable.
That's not that bad. I do not want _all_ the ServiceManager-s
in the world to implement this, but only those returnable
from _new_ methods.
(Well, the fact that Fortress has been released a little spoils
this beautifull picture, but still it is not that bad yet,
if a new release is rolled out soon, then probably not too
many people will implement these methods
fortress/impl/AbstractContainer.java|provideServiceManager()
fortress/impl/AbstractContainer.java|provideComponentContext()
So I want WP only for objects returned from _new_ methods,
and that's not that bad.
In fact I want
fortress/impl/AbstractContainer.java|provideServiceManager()
to return a ServiceManager that _also_ implements WriteProtectable.
<uneasily-shrugging>
Maybe introduce a new ServiceManager, WPServiceManager for this case?
</uneasily-shrugging>
LS> And the "different way" we currently are all most happy with here @
LS> avalon seems to be meta tags transformed into xml :D
Excellent and beautifull! But makes me feel a little worried
on how heavy-weight it is: it's ok for components but I'm speaking
on a level much lower. I think would personally prefer smth
lightweight there..
Thoughts?
- Anton
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]