Hello Marco!
GMF> Hi,
GMF> does anyone have some snipplets how to nest containers ?
Okay, let's do it :")
a) what is the intent of nesting the containers?
I can imagine two possible intents
a.1)
In your example if we have the following hierarchy
generalContainer
|
-------------------------
| |
specialContainer ComGC1
| | |
ComSC1 ComSC2 ComSC3
ComSC1 will have access to all components
* ComSC1
* ComSC2
* ComSC3
* ComGC1
But ComGC1 won't have access to ComSC1, ComSC2, ComSC3
This looks like a sort of "partitioning component space"
Is this the intent?
Probably I have to scratch my head some more to find a clean
way to do this...
The code proposed by Unico may be the way. Only make sure
to manually dispose specialContainer before disposing
generalContainer. (You have to dispose it manually since you
created it manually.)
GMF> The GeneralContainer and SpecialContainer are similar
GMF> (DefaultContainer), they just should have different role/config-files,
GMF> so that a component from the SpecialContainer can lookup a component from
GMF> the GeneralContainer.
This suggests that you really wanted to do a.1...
Still I will tell about what I know how to do well, it's a.2
a.2)
specialContainer is a component itself. It has a role. Like
public class SpecialContainer extends DefaultContainer
implements RoleA
In this case all becomes somewhat clearer.
Do not create specialContainer manually.
Just declare it in the configuration file like any other
normal component. Probably you will like to overload its
configure method:
public class SpecialContainer extends DefaultContainer
implements RoleA
{
public void configure( Configuration conf ) throws ...
{
Configuration myConfig = conf.getChild( "my" );
Configuration childConfig = conf.getChild( "child" );
super.configure( childConfig );
.... use myConfig to setup yourself ....
}
}
and your config will look like
super.xconf
<config>
<special-container id="specialContainer">
<my>
....regular configuration...
</my>
<child>
<!-- now declare all child component for special
container --->
<component-type-1 id="ComSC1">
....
</component-type-1>
<component-type-2 id="ComSC2">
....
</component-type-2>
<component-type-3 id="ComSC3">
....
</component-type-3>
</special-container>
<component-type-4 id="ComGC1">
...
</component-name-4>
</config>
Note that ComGC1 will have access to "specialContainer" as a
component (remember, it implements RoleA ?), but not to
ComSC1, ComSC2, ComSC3.
ComSC1 in its turn will have access to ComGC1, specialContainer,
ComSC1, ComSC2, ComSC3.
Good luck!
GMF> maybe ServeltContainer...
you're probably looking for SEVAK, it's in avalon-sandbox
GMF> Only the ServletContainer may override the DefaultContainer)
this sentence has remained a miracle to me (i did not understand
what "override" means)
GMF> Have any ideas how to build this with fortress ?
Have relined my.
The approach for a.2 is different because I'm not sure
if all goes well for a component without any roles.
Still you may try to use a.2 style for a.1.
I would subclass DefaultContainer, only to add
@avalon.component directive there and give it a name,
say "default-container", but no roles.
Then I would try to configure it like
<config>
<default-container>
<component-type-1 id="ComSC1">
....
</component-type-1>
<component-type-2 id="ComSC2">
....
</component-type-2>
<component-type-3 id="ComSC3">
....
</component-type-3>
</default-container>
<component-type-4 id="ComGC1">
....
</component-type-4>
</config>
This should work too. Please report your failure/success
(sorry, not time atm to experiment myself :-(
-Anton
GMF> Thanks,
GMF> Marco
GMF> ---------------------------------------------------------------------
GMF> To unsubscribe, e-mail: [EMAIL PROTECTED]
GMF> For additional commands, e-mail: [EMAIL PROTECTED]
GMF> ---------------------------------------------------------------------
GMF> To unsubscribe, e-mail: [EMAIL PROTECTED]
GMF> For additional commands, e-mail: [EMAIL PROTECTED]
--
Best regards,
Anton mailto:[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]