Hi, All!
I think that we have got one more interface
crystalized in our works:
public interface WriteProtectable
{
void makeReadOnly();
}
As I will show later it also needs a twin
marker interface ReadOnly:
public interface ReadOnly
{
}
For instance DefaultServiceManager is WriteProtectable
while FortressServiceManager is ReadOnly.
-------------
This interfaces are proposed to have a XXXUtil.makeReadOnly()
method to operate them: (a sketch)
public void makeReadOnly( Object obj )
{
if ( obj instanceof WriteProtectable )
{
((WriteProtectable)obj).makeReadOnly();
}
else if ( obj instanceof ReadOnly )
{
//do nothing
}
else
{
throw new IllegalArgumentException( "..." );
}
}
--------------
This methods may be usefull when we extend any kind of
class via subcalssing, f.e. a container or a component.
Here's a usage example:
class Abstract
{
protected void initializeGreat()
{
m_great = createGreat();
XXXUtil.makeReadOnly( m_great );
}
protected Great createGreat()
{
DefaultGreat great = new DefaultGreat();
great.put( foo );
great.put( bar );
return great;
}
}
class Derived extends Abstract
{
protected Great createGreat()
{
Great parent = super.createGreat();
final DefaultGreat great;
if ( parent instanceof DefaultGreat )
{
great = (DefaultGreat) parent;
}
else
{
great = new DefaultGreat( parent );
}
great.put( blah );
return great;
}
}
--------
Great could be Context, ServiceManager, etc.
--------
This mail is on introduction of WriteProtectable/ReadOnly.
Do you think it's a good idea to put them somewhere to the
framework, say o.a.a.f.writeprotection (bad name :-(( )
and make all the classes that have a makeReadOnly() method
implement WriteProtectable?
--------
Where can XXXUtil.makeReadOnly() go?
(My other mail is on a similar subject,
XXXUtil.get( context,key,defaultValue ), where can that go?
Should they both go to one class? Where can it live?)
WBR, Anton
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]