You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br> on 2002/11/21 14:36:33 UTC

[CONTRIB] who is my father ? The configuration asks !

Hi all. I'm sending this patches to the list to see if you would like to
include them into CVS.

These changes should help a developer, with a Configuration instance at
hand, determine it's parent and root Configuration instances.
It respects the read-only nature of Configuration objects.

-- 
Leandro Rodrigo Saad Cruz
IT - Inter Business Tecnologia e Servicos (IB)
http://www.ibnetwork.com.br
http://jakarta.apache.org/ojb

RE: [CONTRIB] who is my father ? The configuration asks !

Posted by "Noel J. Bergman" <no...@devtech.com>.
Really?!  Wow.  Sorry.  I thought it was clear that I considered it not only
a violation of the established design patterns, but also a potentially
dangerous approach.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [CONTRIB] who is my father ? The configuration asks !

Posted by Berin Loritsch <bl...@citi-us.com>.
> From: Noel J. Bergman [mailto:noel@devtech.com]
> 
> I assume that you weren't replying to me in contradiction, 
> because as far as
> I can see we are agreeing.  I'm not the one who proposed 
> visibility to an
> enclosing configuration.  :-)

The last paragraph cast some doubt on whether you were for
or against, sorry ;P

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [CONTRIB] who is my father ? The configuration asks !

Posted by "Noel J. Bergman" <no...@devtech.com>.
I assume that you weren't replying to me in contradiction, because as far as
I can see we are agreeing.  I'm not the one who proposed visibility to an
enclosing configuration.  :-)

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [CONTRIB] who is my father ? The configuration asks !

Posted by Berin Loritsch <bl...@citi-us.com>.
Configuration is not now, nor ever has been meant as a
replacement for DOM/JDOM/etc.  Please take the time to
look through the archives (you might have to go as far
back as 2000), and you will see all the arguments for
and against Configuration providing access to a parent.

There are other ways of accomplishing what you want
to accomplish than messing with the current Configuration
contracts.  An alteration of current contracts requires
more justification than "it would make my life easier"
because it affects existing code.  Existing code makes
assumptions based on the contract in affect at the time.
If a contract change as fundamental as this is made, an
existing system has to change its codebase to protect
against a type of attack that was not previously
available at the time.  That is another reason for my
-1 of the proposed change.

If you want to be able to traverse up and down the
heirarchy, use a DOM based API--not Configuration.  In
order to incorporate that into your system, you need
to use the Extension mechanism that is the same between
Fortress and Merlin in your code.  I personally don't
see the advantage of using a full DOM based approach
for configuration information.  I will need some
convincing.  If we do need a full DOM based approach,
then we use JDOM or something similarly easy to use
but do not change existing contracts with the
configuration object.


> From: Noel J. Bergman [mailto:noel@devtech.com]
> 
> As far as I can see, the proposal violates Avalon's IoC/SoC 
> patterns.  The
> code providing the Configuration is supposed to have control 
> and knowledge
> over what it is providing.  IF it wants to provide parent 
> information, it
> can.
> 
> On another line of reasoning, I think it is safer (and more 
> consistent) for
> it to explicitly provide what it wants, than to need to deny. 
>  For example,
> consider schema evolution.  I might not have confidential 
> information in a
> parent configuration at the moment, so I might not think of 
> preventing the
> parent from being accessed.  I might not remember, in the 
> future, when I add
> confidential information.  On the other hand, if I am 
> explicitly passing the
> configuration as part of the contract, then I am more likely 
> to be aware of
> the issue.
> 
> 	--- Noel
> 
> 
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [CONTRIB] who is my father ? The configuration asks !

Posted by "Noel J. Bergman" <no...@devtech.com>.
As far as I can see, the proposal violates Avalon's IoC/SoC patterns.  The
code providing the Configuration is supposed to have control and knowledge
over what it is providing.  IF it wants to provide parent information, it
can.

On another line of reasoning, I think it is safer (and more consistent) for
it to explicitly provide what it wants, than to need to deny.  For example,
consider schema evolution.  I might not have confidential information in a
parent configuration at the moment, so I might not think of preventing the
parent from being accessed.  I might not remember, in the future, when I add
confidential information.  On the other hand, if I am explicitly passing the
configuration as part of the contract, then I am more likely to be aware of
the issue.

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [CONTRIB] who is my father ? The configuration asks !

Posted by Leandro Rodrigo Saad Cruz <le...@ibnetwork.com.br>.
All you have to do is setPatent(null) on the copnfiguration fragment to
prevent this behavior !

On Thu, 2002-11-21 at 11:49, Stephen McConnell wrote:
> 
> Hang on a tick - if I understand the comments below correctly, a object 
> having a refernce to a configuration fragment could get the parent of 
> that fragment and from there, get the partent and children of the 
> parent, - i.e. navigate the entire configuration hierachy.  While your 
> respect read-only, its scarry feature because currently the 
> configuration fragment is totally isolated and the rest of the 
> configuration.
> 
> Cheers, Steve.
> 
> (who think s that "know me" is not the same as "knowing my family")
> 
> 
> 
> Leandro Rodrigo Saad Cruz wrote:
> 
> >Hi all. I'm sending this patches to the list to see if you would like to
> >include them into CVS.
> >
> >These changes should help a developer, with a Configuration instance at
> >hand, determine it's parent and root Configuration instances.
> >It respects the read-only nature of Configuration objects.
> >
> >  
> >
> >------------------------------------------------------------------------
> >
> >Index: src/java/org/apache/avalon/framework/configuration/Configuration.java
> >===================================================================
> >RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/Configuration.java,v
> >retrieving revision 1.23
> >diff -u -b -B -r1.23 Configuration.java
> >--- src/java/org/apache/avalon/framework/configuration/Configuration.java	7 Nov 2002 08:35:27 -0000	1.23
> >+++ src/java/org/apache/avalon/framework/configuration/Configuration.java	21 Nov 2002 13:27:53 -0000
> >@@ -499,4 +499,19 @@
> >      *         the value is not set.
> >      */
> >     boolean getAttributeAsBoolean( String name, boolean defaultValue );
> >+
> >+    /**
> >+     * Returns the parent os this Configuration instance, (can be null).
> >+     *
> >+     * @return Configuration object that this instance is child of.
> >+     */
> >+    public Configuration getParent();
> >+
> >+    /**
> >+     * Returns the root Configuration object that this Configuration instance is part of.
> >+     *
> >+     * @see SAXConfigurationHandler
> >+     * @return Configuration object that is the root of the Configuration tree.
> >+     */
> >+    public Configuration getRoot();
> > }
> >  
> >
> >------------------------------------------------------------------------
> >
> >Index: src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java
> >===================================================================
> >RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java,v
> >retrieving revision 1.25
> >diff -u -b -B -r1.25 DefaultConfiguration.java
> >--- src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java	11 Nov 2002 01:54:07 -0000	1.25
> >+++ src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java	21 Nov 2002 13:31:02 -0000
> >@@ -84,6 +84,7 @@
> >     private ArrayList m_children;
> >     private String m_value;
> >     private boolean m_readOnly;
> >+    private Configuration m_parent;
> > 
> >     /**
> >      * Create a new <code>DefaultConfiguration</code> instance.
> >@@ -536,5 +537,46 @@
> >             throw new IllegalStateException
> >                 ( "Configuration is read only and can not be modified" );
> >         }
> >+    }
> >+
> >+
> >+
> >+    /**
> >+     * Returns the parent os this Configuration instance, (can be null).
> >+     *
> >+     * @return Configuration object that this instance is child of.
> >+     */
> >+    public Configuration getParent()
> >+    {
> >+        return m_parent;
> >+    }
> >+
> >+
> >+
> >+    /**
> >+     * Set the parent Configuration object for this instance
> >+     */
> >+    public void setParent(Configuration parent)
> >+    {
> >+        m_parent = parent;
> >+    }
> >+
> >+
> >+
> >+    /**
> >+     * Returns the root Configuration object that this Configuration instance is part of.
> >+     * A Configuration object is considered to be the root of the Configuration tree if it has no parent.    
> >+     *
> >+     * @see SAXConfigurationHandler
> >+     * @return Configuration object that is the root of the Configuration tree.
> >+     */
> >+    public Configuration getRoot()
> >+    {
> >+        if(m_parent != null)
> >+        {
> >+            return m_parent.getRoot();
> >+        }
> >+        return this;
> >+
> >     }
> > }
> >  
> >
> >------------------------------------------------------------------------
> >
> >Index: src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java
> >===================================================================
> >RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java,v
> >retrieving revision 1.24
> >diff -u -b -B -r1.24 SAXConfigurationHandler.java
> >--- src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java	7 Nov 2002 08:35:27 -0000	1.24
> >+++ src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java	21 Nov 2002 13:27:14 -0000
> >@@ -232,6 +232,7 @@
> >         {
> >             final DefaultConfiguration parent =
> >                 (DefaultConfiguration)m_elements.get( depth - 1 );
> >+            configuration.setParent(parent);
> >             parent.addChild( configuration );
> >             // inherits parent's space preservation policy
> >             preserveSpace = m_preserveSpace.get( depth - 1 );
> >
> >  
> >
> >------------------------------------------------------------------------
> >
> >--
> >To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> -- 
> 
> Stephen J. McConnell
> 
> OSM SARL
> digital products for a global economy
> mailto:mcconnell@osm.net
> http://www.osm.net
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
-- 
Leandro Rodrigo Saad Cruz
IT - Inter Business Tecnologia e Servicos (IB)
http://www.ibnetwork.com.br
http://jakarta.apache.org/ojb


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [CONTRIB] who is my father ? The configuration asks !

Posted by Stephen McConnell <mc...@apache.org>.
Hang on a tick - if I understand the comments below correctly, a object 
having a refernce to a configuration fragment could get the parent of 
that fragment and from there, get the partent and children of the 
parent, - i.e. navigate the entire configuration hierachy.  While your 
respect read-only, its scarry feature because currently the 
configuration fragment is totally isolated and the rest of the 
configuration.

Cheers, Steve.

(who think s that "know me" is not the same as "knowing my family")



Leandro Rodrigo Saad Cruz wrote:

>Hi all. I'm sending this patches to the list to see if you would like to
>include them into CVS.
>
>These changes should help a developer, with a Configuration instance at
>hand, determine it's parent and root Configuration instances.
>It respects the read-only nature of Configuration objects.
>
>  
>
>------------------------------------------------------------------------
>
>Index: src/java/org/apache/avalon/framework/configuration/Configuration.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/Configuration.java,v
>retrieving revision 1.23
>diff -u -b -B -r1.23 Configuration.java
>--- src/java/org/apache/avalon/framework/configuration/Configuration.java	7 Nov 2002 08:35:27 -0000	1.23
>+++ src/java/org/apache/avalon/framework/configuration/Configuration.java	21 Nov 2002 13:27:53 -0000
>@@ -499,4 +499,19 @@
>      *         the value is not set.
>      */
>     boolean getAttributeAsBoolean( String name, boolean defaultValue );
>+
>+    /**
>+     * Returns the parent os this Configuration instance, (can be null).
>+     *
>+     * @return Configuration object that this instance is child of.
>+     */
>+    public Configuration getParent();
>+
>+    /**
>+     * Returns the root Configuration object that this Configuration instance is part of.
>+     *
>+     * @see SAXConfigurationHandler
>+     * @return Configuration object that is the root of the Configuration tree.
>+     */
>+    public Configuration getRoot();
> }
>  
>
>------------------------------------------------------------------------
>
>Index: src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java,v
>retrieving revision 1.25
>diff -u -b -B -r1.25 DefaultConfiguration.java
>--- src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java	11 Nov 2002 01:54:07 -0000	1.25
>+++ src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java	21 Nov 2002 13:31:02 -0000
>@@ -84,6 +84,7 @@
>     private ArrayList m_children;
>     private String m_value;
>     private boolean m_readOnly;
>+    private Configuration m_parent;
> 
>     /**
>      * Create a new <code>DefaultConfiguration</code> instance.
>@@ -536,5 +537,46 @@
>             throw new IllegalStateException
>                 ( "Configuration is read only and can not be modified" );
>         }
>+    }
>+
>+
>+
>+    /**
>+     * Returns the parent os this Configuration instance, (can be null).
>+     *
>+     * @return Configuration object that this instance is child of.
>+     */
>+    public Configuration getParent()
>+    {
>+        return m_parent;
>+    }
>+
>+
>+
>+    /**
>+     * Set the parent Configuration object for this instance
>+     */
>+    public void setParent(Configuration parent)
>+    {
>+        m_parent = parent;
>+    }
>+
>+
>+
>+    /**
>+     * Returns the root Configuration object that this Configuration instance is part of.
>+     * A Configuration object is considered to be the root of the Configuration tree if it has no parent.    
>+     *
>+     * @see SAXConfigurationHandler
>+     * @return Configuration object that is the root of the Configuration tree.
>+     */
>+    public Configuration getRoot()
>+    {
>+        if(m_parent != null)
>+        {
>+            return m_parent.getRoot();
>+        }
>+        return this;
>+
>     }
> }
>  
>
>------------------------------------------------------------------------
>
>Index: src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java
>===================================================================
>RCS file: /home/cvspublic/jakarta-avalon/src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java,v
>retrieving revision 1.24
>diff -u -b -B -r1.24 SAXConfigurationHandler.java
>--- src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java	7 Nov 2002 08:35:27 -0000	1.24
>+++ src/java/org/apache/avalon/framework/configuration/SAXConfigurationHandler.java	21 Nov 2002 13:27:14 -0000
>@@ -232,6 +232,7 @@
>         {
>             final DefaultConfiguration parent =
>                 (DefaultConfiguration)m_elements.get( depth - 1 );
>+            configuration.setParent(parent);
>             parent.addChild( configuration );
>             // inherits parent's space preservation policy
>             preserveSpace = m_preserveSpace.get( depth - 1 );
>
>  
>
>------------------------------------------------------------------------
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [CONTRIB] who is my father ? The configuration asks !

Posted by Peter Royal <pr...@apache.org>.
On Thursday, November 21, 2002, at 05:36  AM, Leandro Rodrigo Saad Cruz 
wrote:
> Hi all. I'm sending this patches to the list to see if you would like 
> to
> include them into CVS.
>
> These changes should help a developer, with a Configuration instance at
> hand, determine it's parent and root Configuration instances.
> It respects the read-only nature of Configuration objects.

I understand that you may have a need to do what you are doing, but 
such a change to the Configuration interface will receive a -1 to me.

The design to view only child configurations was an explicit design 
choice. It preserves the "Inversion of Control" that is central to 
Avalon. A component can pass a portion of its configuration on to child 
components with full confidence that the child component can only 
access what it was given.
-peter

-- 
peter royal -> proyal@apache.org


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [CONTRIB] who is my father ? The configuration asks !

Posted by Berin Loritsch <bl...@citi-us.com>.
That has been discussed many times.  It is the chief reason
why we use Configuration objects and not JDOM.

A component must not _*EVER*_ be able to look at the configuration
of another component.  There could be sensitive information that
is meant for the consumption of only that other component like
usernames and passwords.

Configuration objects allow you to take any node, and give it to
a component--confident in the fact that a trojan component cannot
exploit weaknesses in the Configuration object to get unauthorized
information.

> -----Original Message-----
> From: Leandro Rodrigo Saad Cruz [mailto:leandro@ibnetwork.com.br]
> Sent: Thursday, November 21, 2002 8:37 AM
> To: Avalon Developers List
> Subject: [CONTRIB] who is my father ? The configuration asks !
> 
> 
> Hi all. I'm sending this patches to the list to see if you 
> would like to
> include them into CVS.
> 
> These changes should help a developer, with a Configuration 
> instance at
> hand, determine it's parent and root Configuration instances.
> It respects the read-only nature of Configuration objects.
> 
> -- 
> Leandro Rodrigo Saad Cruz
> IT - Inter Business Tecnologia e Servicos (IB)
> http://www.ibnetwork.com.br
> http://jakarta.apache.org/ojb
> 
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>