You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Marcus Crafter <cr...@fztig938.bank.dresdner.net> on 2001/11/09 17:21:53 UTC

silly question #1 - config files & globals ?

Hi All,
	
	Hope all is well!

	Sorry for asking such a simple question, but I'm kinda stuck,
	and I'd like to learn how to use avalon the way it was intended :)

	Pretty simple question, hence the title - I'm wondering how others
	access global configuration settings specified in xml files, when
	configuring managed components.

	I have a few settings like 'default operating mode', 'default
	server locale', 'default unavailable time' etc, which are not
	really applicable to any one component in my app, but are global
	across the entire application and commonly required by several
	components - I'm wondering where I should specify them in our .xconf
	config file, and how I should access them in my application.

	Using the component manager described in Berin's document I can easily
	create a config file for all my components and have them automatically
	configured which is really cool - but how should I obtain
	non-per-component specific options ?

	Should I create a 'globals' component or similar so that I have
	something like:

	<app>
		<globals>
			<operating-mode>test</operating-mode>
			<unavailable-time>100</unavailable-time>
			<server-locale>en_AU</server-locale>
		</globals>
	</app>

	and so on ? I can see how this would work - but is this overkill ?
	(ie. creating a whole new component simply just to store some values).

	Something like:

	<app mode="test">
		<unavailable-time>100</unavailable-time>
		<server-locale>de_DE</server_locale>
	</app>

	would be possible if I handled everything manually, but I can't see
	how I can access these values from a managed component - The
	Configuration object passed via configure() Component is not the
	complete file, just what's under it's component definition.
	
	Perhaps I should save the values somewhere before calling
	ComponentManager.configure() ?

	Any thoughts ? Ideas ? Obviously I'm still learning :)

	Cheers,

	Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   Managesoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'     Email : Marcus.Crafter@managesoft.com
          &&&&.        Business Hours : +49 69 9757 200
    &&&&&&&:

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


Re: silly question #1 - config files & globals ?

Posted by Berin Loritsch <bl...@apache.org>.
Marcus Crafter wrote:
> 
> Hi All,
> 
>         Hope all is well!
> 
>         Sorry for asking such a simple question, but I'm kinda stuck,
>         and I'd like to learn how to use avalon the way it was intended :)
> 
>         Pretty simple question, hence the title - I'm wondering how others
>         access global configuration settings specified in xml files, when
>         configuring managed components.

The first question I have to ask, is "what is managing the Components?"
For instance, if you have a group of global configurations that are specific
to a GROUP of components (i.e. not the whole app), then you should have
the containing component use those variables:

<app>
  <main-component>
    <operating-mode>test</operating-mode>
    <unavailable-time>100</unavailable-time>
    <server-locale>en_AU</server-locale>

    <child-component/>
    <child-component/>
  </main-component>

  <unassociated-component/>
  <unassociated-component/>
</app>

That MainComponent is responsible for the main contract it has, as well as
managing the child components.  One of the things it can do is to "rewrite"
the child component configuration heirarchy so that the globals are repeated
in each child-component definition.


However, that does not address the problem of a truly GLOBAL configuration.
Because we have never come accross a situation where we needed something that
was truly applicable to all components, we never provided a solution.  There
is the registry option, but any Windows user (you don't have to be a developer)
will tell you that the implementation is severely broken.  Of course, the
configuration rewriting technique can be used for this solution as well--and
that requires changes to the ComponentManager.

>         I have a few settings like 'default operating mode', 'default
>         server locale', 'default unavailable time' etc, which are not
>         really applicable to any one component in my app, but are global
>         across the entire application and commonly required by several
>         components - I'm wondering where I should specify them in our .xconf
>         config file, and how I should access them in my application.
> 
>         Using the component manager described in Berin's document I can easily
>         create a config file for all my components and have them automatically
>         configured which is really cool - but how should I obtain
>         non-per-component specific options ?
> 
>         Should I create a 'globals' component or similar so that I have
>         something like:
> 
>         <app>
>                 <globals>
>                         <operating-mode>test</operating-mode>
>                         <unavailable-time>100</unavailable-time>
>                         <server-locale>en_AU</server-locale>
>                 </globals>
>         </app>
> 
>         and so on ? I can see how this would work - but is this overkill ?
>         (ie. creating a whole new component simply just to store some values).

Perhaps if it were a Registry component, it would be better named.  It would
work, and if it were a full registry, then it would not be overkill.  It would
probably play into our ConfigurationManager idea we through around a while back.

>         Something like:
> 
>         <app mode="test">
>                 <unavailable-time>100</unavailable-time>
>                 <server-locale>de_DE</server_locale>
>         </app>
> 
>         would be possible if I handled everything manually, but I can't see
>         how I can access these values from a managed component - The
>         Configuration object passed via configure() Component is not the
>         complete file, just what's under it's component definition.

The object that actually reads the file from the DefaultConfigurationBuilder
has access to these, and can perform the necessary processing.

>         Perhaps I should save the values somewhere before calling
>         ComponentManager.configure() ?

That is basically the above solution.

>         Any thoughts ? Ideas ? Obviously I'm still learning :)

Hopefully the ideas I came up with may help.

BTW, I'm still learning too. :)


-- 

"Those who would trade liberty for
 temporary security deserve neither"
                - Benjamin Franklin

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


Re: silly question #1 - config files & globals ?

Posted by giacomo <gi...@apache.org>.
On Fri, 9 Nov 2001, Marcus Crafter wrote:

My answer to this question is the Context object. Of course you have to
set it in the main class where you create and configure your CM and have
the information you need to put into the Context from somewhere else
that the component xconf file. But I see the Context object as the
entity responsable for holding "global" information. Components
interested in this information must implement the Contextualizable
interface.

Giacomo

> Hi All,
>
> 	Hope all is well!
>
> 	Sorry for asking such a simple question, but I'm kinda stuck,
> 	and I'd like to learn how to use avalon the way it was intended :)
>
> 	Pretty simple question, hence the title - I'm wondering how others
> 	access global configuration settings specified in xml files, when
> 	configuring managed components.
>
> 	I have a few settings like 'default operating mode', 'default
> 	server locale', 'default unavailable time' etc, which are not
> 	really applicable to any one component in my app, but are global
> 	across the entire application and commonly required by several
> 	components - I'm wondering where I should specify them in our .xconf
> 	config file, and how I should access them in my application.
>
> 	Using the component manager described in Berin's document I can easily
> 	create a config file for all my components and have them automatically
> 	configured which is really cool - but how should I obtain
> 	non-per-component specific options ?
>
> 	Should I create a 'globals' component or similar so that I have
> 	something like:
>
> 	<app>
> 		<globals>
> 			<operating-mode>test</operating-mode>
> 			<unavailable-time>100</unavailable-time>
> 			<server-locale>en_AU</server-locale>
> 		</globals>
> 	</app>
>
> 	and so on ? I can see how this would work - but is this overkill ?
> 	(ie. creating a whole new component simply just to store some values).
>
> 	Something like:
>
> 	<app mode="test">
> 		<unavailable-time>100</unavailable-time>
> 		<server-locale>de_DE</server_locale>
> 	</app>
>
> 	would be possible if I handled everything manually, but I can't see
> 	how I can access these values from a managed component - The
> 	Configuration object passed via configure() Component is not the
> 	complete file, just what's under it's component definition.
>
> 	Perhaps I should save the values somewhere before calling
> 	ComponentManager.configure() ?
>
> 	Any thoughts ? Ideas ? Obviously I'm still learning :)
>
> 	Cheers,
>
> 	Marcus
>
>


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