You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Donald <do...@apache.org> on 2001/06/04 11:35:55 UTC

makeReadOnly() method

Hi,

I have just added makeReadOnly() method to a whole bunch of classes in
framework. The reason was that I recently came across someone who was using
Avalon code and doing something like

((DefaultComponentManager)componentManager).put( "blah", blah );

which is obviously bad form. So after you make something read only this
would actually throw an IllegalStateException.


Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


Re: makeReadOnly() method

Posted by Peter Donald <do...@apache.org>.
At 06:15 AM 6/4/01 -0700, Berin Loritsch wrote:
>Actually, for the Excalibur stuff, I wanted to have
>the intialize() function take care of that.  It is
>IMO messy to have a makeReadOnly() method when
>something like that can be hidden.  I will check,
>but hopefully you haven't altered the interfaces--
>that would suck.  It would break backwards
>compatibility for something that is another concern.

forwards compatibility is there as it is a RuntimeException that is
generated on failure.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by Peter Donald <do...@apache.org>.
At 08:55 AM 6/6/01 -0400, Berin Loritsch wrote:
>Here is an idea:  what about making the default implementations
>writable _only_ once.  IOW, once the name/value is set, it cannot
>be changed (value is String or child Configuration[]).

Nice in theory. I am not sure it would work in practice for configuration
or context (definetly wouldn't for context). It could definetly work for CM
... not sure if I like it yet though.

Personally I would prefer manually or programatically constructing
interfaces so as not to disturb users of framework.

Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by Berin Loritsch <bl...@apache.org>.
Berin Loritsch wrote:
> 
> giacomo wrote:
> >
> > On Mon, 4 Jun 2001, Berin Loritsch wrote:
> >
> > > Actually, for the Excalibur stuff, I wanted to have
> > > the intialize() function take care of that.  It is
> > > IMO messy to have a makeReadOnly() method when
> > > something like that can be hidden.  I will check,
> > > but hopefully you haven't altered the interfaces--
> > > that would suck.  It would break backwards
> > > compatibility for something that is another concern.
> >
> > IMHO a better way to solve it is to wait until JDK 1.3 is available for
> > almost any platform and Avalon can integrate generating proxies to
> > secure the contracts.
> 
> That may be good in the long run--or it may be overkill.
> I am not sure of performance issues on that.  The important
> thing is we need to operate in the JDK 1.2 environment now.


Here is an idea:  what about making the default implementations
writable _only_ once.  IOW, once the name/value is set, it cannot
be changed (value is String or child Configuration[]).

For DefaultContext, it could be initialized with a Map in
the constructor, using Collections to make it readonly:

DefaultContext {
    private final Map m_context;

    public DefaultContext(Map myContext)
    {
        this.m_context = Collections.unmodifiableMap(myContext);
    }
}

For DefaultConfiguration, once setValue() or addChildren() is
called, it automatically becomes read-only.

For DefaultComponentManager, make it Initializable, this is
conceptually good.  Or you can do the DefaultContext approach
and remove the add methods altogether.

That type of thing.  It imposes no extra requirements on the clients,
and guarantees the security we are looking for.

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by Berin Loritsch <bl...@apache.org>.

giacomo wrote:
> 
> On Mon, 4 Jun 2001, Berin Loritsch wrote:
> 
> > Actually, for the Excalibur stuff, I wanted to have
> > the intialize() function take care of that.  It is
> > IMO messy to have a makeReadOnly() method when
> > something like that can be hidden.  I will check,
> > but hopefully you haven't altered the interfaces--
> > that would suck.  It would break backwards
> > compatibility for something that is another concern.
> 
> IMHO a better way to solve it is to wait until JDK 1.3 is available for
> almost any platform and Avalon can integrate generating proxies to
> secure the contracts.

That may be good in the long run--or it may be overkill.
I am not sure of performance issues on that.  The important
thing is we need to operate in the JDK 1.2 environment now.

> 
> Giacomo
> 
> >
> > --- Peter Donald <do...@apache.org> wrote:
> > > At 07:35 PM 6/4/01 +1000, Peter Donald wrote:
> > > >Hi,
> > > >
> > > >I have just added makeReadOnly() method to a whole
> > > bunch of classes in
> > > >framework. The reason was that I recently came
> > > across someone who was using
> > > >Avalon code and doing something like
> > > >
> > > >((DefaultComponentManager)componentManager).put(
> > > "blah", blah );
> > > >
> > > >which is obviously bad form. So after you make
> > > something read only this
> > > >would actually throw an IllegalStateException.
> > > >
> > > >
> > > >Cheers,
> > > >
> > > >Pete
> > > >
> > >
> > >*-----------------------------------------------------*
> > > >| "Faced with the choice between changing one's
> > > mind, |
> > > >| and proving that there is no need to do so -
> > > almost |
> > > >| everyone gets busy on the proof."
> > >   |
> > > >|              - John Kenneth Galbraith
> > >   |
> > >
> > >*-----------------------------------------------------*
> > > >
> > > >
> > > Cheers,
> > >
> > > Pete
> > >
> > >
> > *-----------------------------------------------------*
> > > | "Faced with the choice between changing one's
> > > mind, |
> > > | and proving that there is no need to do so -
> > > almost |
> > > | everyone gets busy on the proof."
> > >  |
> > > |              - John Kenneth Galbraith
> > >  |
> > >
> > *-----------------------------------------------------*
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > avalon-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > avalon-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get personalized email addresses from Yahoo! Mail - only $35
> > a year!  http://personal.mail.yahoo.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
> >
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by giacomo <gi...@apache.org>.
On Mon, 4 Jun 2001, Berin Loritsch wrote:

> Actually, for the Excalibur stuff, I wanted to have
> the intialize() function take care of that.  It is
> IMO messy to have a makeReadOnly() method when
> something like that can be hidden.  I will check,
> but hopefully you haven't altered the interfaces--
> that would suck.  It would break backwards
> compatibility for something that is another concern.

IMHO a better way to solve it is to wait until JDK 1.3 is available for
almost any platform and Avalon can integrate generating proxies to
secure the contracts.

Giacomo

>
> --- Peter Donald <do...@apache.org> wrote:
> > At 07:35 PM 6/4/01 +1000, Peter Donald wrote:
> > >Hi,
> > >
> > >I have just added makeReadOnly() method to a whole
> > bunch of classes in
> > >framework. The reason was that I recently came
> > across someone who was using
> > >Avalon code and doing something like
> > >
> > >((DefaultComponentManager)componentManager).put(
> > "blah", blah );
> > >
> > >which is obviously bad form. So after you make
> > something read only this
> > >would actually throw an IllegalStateException.
> > >
> > >
> > >Cheers,
> > >
> > >Pete
> > >
> >
> >*-----------------------------------------------------*
> > >| "Faced with the choice between changing one's
> > mind, |
> > >| and proving that there is no need to do so -
> > almost |
> > >| everyone gets busy on the proof."
> >   |
> > >|              - John Kenneth Galbraith
> >   |
> >
> >*-----------------------------------------------------*
> > >
> > >
> > Cheers,
> >
> > Pete
> >
> >
> *-----------------------------------------------------*
> > | "Faced with the choice between changing one's
> > mind, |
> > | and proving that there is no need to do so -
> > almost |
> > | everyone gets busy on the proof."
> >  |
> > |              - John Kenneth Galbraith
> >  |
> >
> *-----------------------------------------------------*
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > avalon-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > avalon-dev-help@jakarta.apache.org
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail - only $35
> a year!  http://personal.mail.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by Berin Loritsch <bl...@yahoo.com>.
Actually, for the Excalibur stuff, I wanted to have
the intialize() function take care of that.  It is
IMO messy to have a makeReadOnly() method when
something like that can be hidden.  I will check,
but hopefully you haven't altered the interfaces--
that would suck.  It would break backwards
compatibility for something that is another concern.

--- Peter Donald <do...@apache.org> wrote:
> At 07:35 PM 6/4/01 +1000, Peter Donald wrote:
> >Hi,
> >
> >I have just added makeReadOnly() method to a whole
> bunch of classes in
> >framework. The reason was that I recently came
> across someone who was using
> >Avalon code and doing something like
> >
> >((DefaultComponentManager)componentManager).put(
> "blah", blah );
> >
> >which is obviously bad form. So after you make
> something read only this
> >would actually throw an IllegalStateException.
> >
> >
> >Cheers,
> >
> >Pete
> >
>
>*-----------------------------------------------------*
> >| "Faced with the choice between changing one's
> mind, |
> >| and proving that there is no need to do so -
> almost |
> >| everyone gets busy on the proof."                
>   |
> >|              - John Kenneth Galbraith            
>   |
>
>*-----------------------------------------------------*
> >
> >
> Cheers,
> 
> Pete
> 
>
*-----------------------------------------------------*
> | "Faced with the choice between changing one's
> mind, |
> | and proving that there is no need to do so -
> almost |
> | everyone gets busy on the proof."                 
>  |
> |              - John Kenneth Galbraith             
>  |
>
*-----------------------------------------------------*
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> avalon-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> avalon-dev-help@jakarta.apache.org
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by Peter Donald <do...@apache.org>.
At 07:35 PM 6/4/01 +1000, Peter Donald wrote:
>Hi,
>
>I have just added makeReadOnly() method to a whole bunch of classes in
>framework. The reason was that I recently came across someone who was using
>Avalon code and doing something like
>
>((DefaultComponentManager)componentManager).put( "blah", blah );
>
>which is obviously bad form. So after you make something read only this
>would actually throw an IllegalStateException.
>
>
>Cheers,
>
>Pete
>
>*-----------------------------------------------------*
>| "Faced with the choice between changing one's mind, |
>| and proving that there is no need to do so - almost |
>| everyone gets busy on the proof."                   |
>|              - John Kenneth Galbraith               |
>*-----------------------------------------------------*
>
>
Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Re: makeReadOnly() method

Posted by coconut forcoconuts <co...@yahoo.com>.
--- Peter Donald <do...@apache.org> wrote:
> oops - wrong group ;)
> 
> At 07:35 PM 6/4/01 +1000, you wrote:
> >Hi,
> >
> >I have just added makeReadOnly() method to a whole
> bunch of classes in
> >framework. The reason was that I recently came
> across someone who was using
> >Avalon code and doing something like
> >
> >((DefaultComponentManager)componentManager).put(
> "blah", blah );
> >
> >which is obviously bad form. So after you make
> something read only this
> >would actually throw an IllegalStateException.
> >
> >
> >Cheers,
> >
> >Pete
> >
>
>*-----------------------------------------------------*
> >| "Faced with the choice between changing one's
> mind, |
> >| and proving that there is no need to do so -
> almost |
> >| everyone gets busy on the proof."                
>   |
> >|              - John Kenneth Galbraith            
>   |
>
>*-----------------------------------------------------*
> >
> >
> Cheers,
> 
> Pete
> 
>
*-----------------------------------------------------*
> | "Faced with the choice between changing one's
> mind, |
> | and proving that there is no need to do so -
> almost |
> | everyone gets busy on the proof."                 
>  |
> |              - John Kenneth Galbraith             
>  |
>
*-----------------------------------------------------*
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

Re: makeReadOnly() method

Posted by Peter Donald <do...@apache.org>.
oops - wrong group ;)

At 07:35 PM 6/4/01 +1000, you wrote:
>Hi,
>
>I have just added makeReadOnly() method to a whole bunch of classes in
>framework. The reason was that I recently came across someone who was using
>Avalon code and doing something like
>
>((DefaultComponentManager)componentManager).put( "blah", blah );
>
>which is obviously bad form. So after you make something read only this
>would actually throw an IllegalStateException.
>
>
>Cheers,
>
>Pete
>
>*-----------------------------------------------------*
>| "Faced with the choice between changing one's mind, |
>| and proving that there is no need to do so - almost |
>| everyone gets busy on the proof."                   |
>|              - John Kenneth Galbraith               |
>*-----------------------------------------------------*
>
>
Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*