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

WriteProtectable and ReadOnly are not really part of the container-component contract: a container does not tell a hosted component to become "readonly". The container doesn't care; this kind of behaviour can be configured using a configuration or perhaps metadata.


In avalon, the currently existing makeReadOnly() calls are not made on things which classify as "avalon components" and/or "avalon services", rather, they are implementation-specific.

As such, a WriteProtectable would fit roughly the same role inside avalon-framework as, for example, CascadingThrowable currently does. Just like in an indeal world we would replace CascadingThrowable with Nestable inside commons-lang, WriteProtectable might live there as well.

What we have here is a *generic aspect*: "read/write capability" of a generic java class. Here's a grid which one might fill in any way:

       |yes | no | configurable (once) | configurable n times
-------------------------------------------------------------
read   |    |    |                     |
write  |    |    |                     |
-------------------------------------------------------------

where for a particular component there is one type of "read" behaviour and one type of "write" behaviour.

You could model as follows:

interface Readable {}
interface ReadProtectable extends Readable { void disableRead() }
interface ReadConfigurable extends Writeable { void enableRead() }

interface Writeable {}
interface WriteProtectable extends Writeable { void disableWrite() }
interface WriteConfigurable extends WriteProtectable {
                void enableWrite() }

where you pick one from both lists, and for a class failing to do that a sensible default is decided upon.

For these interfaces to make most sense, they should probably live in java.lang, and be universally adopted early on. Doing this for lots of concerns means you get lots and lots of tiny interfaces, some of which might not be used.

Which really doesn't work so well. Consider the amount of ServiceManager implementations in existence which expose a makeReadOnly() method but do not implement WriteProtectable, for example.

A "language extension" of some kind is in order:

class MyBean [Readable,Writeable] { /* ... */ }

of course, language extensions usually are problematic (despite the success of AspectJ, which is just not quite successful enough), so there's various ways to do the same thing. Naming conventions perhaps (use introspection to search for "makeReadOnly()" and/or "makeWriteable()" methods for example, in place of instanceof), or a MyBeanBeanInfo class describing the behaviour for example, or an .xprofile xml descriptor file doing the same, or information stored inside the class definition based on javadoc tags

/** @bean readable="true" writeable="configurable" */
 class MyBean { /* ... */ }

Using any of those options helps keep the codebase leaner and meaner and scales better with the addition of different aspects. So in conclusion I think that the interfaces you propose might make sense to include in java.lang (failing that, commons-lang :D), that they should not live in avalon-framework as they are more generic than the rest of avalon-framework and have nothing to do with the container-component, but that, given the fact that they would be added as an afterthought which would require source code modification for any existing implementations of the behaviour, are probably better modelled in a different way.

And the "different way" we currently are all most happy with here @ avalon seems to be meta tags transformed into xml :D

Also, I bet that answer's longer than you expected! 8-)

greetz!

- Leo



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



Reply via email to