AW: variable dependencies on Components

"Steinkamp Andre" <[email protected]>
Newsgroups gmane.comp.jakarta.avalon.user
Message-ID <70D96E20708058488B73E2F0CDD63524095283@ssn-ex2000>
sure, youre right!

MyComponent now can get the dep1 and dep2 from the ServiceManager, but what if i want a user to edit the block.xml and not the source code and the .xinfo files? so he can add a new Component from MyService and declare a new dependency with key="dep3". but in the service method from MyComponent this dependency will never be fulfilled. so there is no chance to style it variable!?

André Steinkamp
IT Projekte



-----Ursprüngliche Nachricht-----
Von: Raffael Herzog [mailto:[email protected]]
Gesendet: Dienstag, 24. August 2004 11:02
An: [email protected]
Betreff: Re: variable dependencies on Components


Am Tue, 24 Aug 2004 09:12:52 +0200 schrieb Steinkamp Andre  
<[email protected]>:

> so i did it, but for every component i will add, i have to edit the  
> source code from the components interface to set a key for the new  
> dependency. it would be nice to be independent from the source code and  
> only to edit the block.xml by adding a new component using perhaps three  
> components from the second interface. can i get several objects from the  
> servicemanager with a lookup when they have the same key? can they have  
> the same key?

They don't have the same key. What you specify in the source code is just  
a default. If you declare the component with a name, this will be it's  
name, not the one specified in the code (xinfo). The same goes for  
dependencies:

<component name="c3" class="MyService"/>
<component name="c4" class="MyService"/>
<component name="c2" class="MyComponent">
   <dependencies>
     <dependency key="dep1" source="c3"/>
     <dependency key="dep2" source="c4"/>
   </dependencies>
</component>

Now, c2 will find c3 as dep1 and c4 as dep2 in the ServiceManager,  
regardless of what name you specified in the source code of MyService.

cu & HTH,
    Raffi

-- 
The difference between theory and practice is that in theory, there is no  
difference, but in practice, there is.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.