You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Glen Stampoultzis <gs...@gmail.com> on 2005/05/24 06:58:06 UTC

Defining symbols...

I've been trying to figure out how I asd symbols to my application but I 
haven't been getting very far.

I'm wondering if my problem might not call for symbols at all. My issue is 
this...

I have a bunch of services that have various dependencies between each 
other. One of the objects these services require can't be known until a 
particular point into the execution of the program. I was thinking symbols 
sounded like the right idea but after reading the documentation I'm not sure 
how to use them. None of the examples seem to feature symbols.

Can anyone show me a nice small example of how to achieve this?

Regards,

Glen Stampoultzis

Re: Defining symbols...

Posted by belaran <be...@gmail.com>.
Given your probleme, symbols seems ,to really be the solution.

The way i understand them hivemind symbols can be used in two way :

-like old symbols on makefile ( to define let's say a directory at
only one place in the module and use the symbol everywhere else)
- to defining attribute or object (or even implementation ) at run time.

To this you have first to create a class that implements the interface:

public class Configurator implements SymbolSource
{
   public String valueForSymbol(String symbol)
   {
     ...
   }
}

And then you have to say to hivemind, through the hivemodule.xml, taht
a new sources for symbol is born :

	<contribution configuration-id="hivemind.SymbolSources">
		<source name="configurator" class="user.implementation.Configurator"/>
	</contribution>

Then, when you'll ask hivemind for something that implies a symbol it'll call
the 'valueForSymbol()' with the string contained in the ${...} and replace it.

I hope I respond to your question.  

2005/5/24, Glen Stampoultzis <gs...@gmail.com>:
> 
>  
>  I've been trying to figure out how I asd symbols to my application but I
> haven't been getting very far.
>  
>  I'm wondering if my problem might not call for symbols at all.  My issue is
> this...
>  
>  I have a bunch of services that have various dependencies between each
> other.  One of the objects these services require can't be known until a
> particular point into the execution of the program.  I was thinking symbols
> sounded like the right idea but after reading the documentation I'm not sure
> how to use them.  None of the examples seem to feature symbols.
>  
>  Can anyone show me a nice small example of how to achieve this?
>  
>  Regards,
>  
>  Glen Stampoultzis
>

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


Re: Defining symbols...

Posted by Knut Wannheden <kn...@gmail.com>.
Glen,

On 5/24/05, Glen Stampoultzis <gs...@gmail.com> wrote:
>  
>  I've been trying to figure out how I asd symbols to my application but I
> haven't been getting very far.
>  
>  I'm wondering if my problem might not call for symbols at all.  My issue is
> this...
>  
>  I have a bunch of services that have various dependencies between each
> other.  One of the objects these services require can't be known until a
> particular point into the execution of the program.  I was thinking symbols
> sounded like the right idea but after reading the documentation I'm not sure
> how to use them.  None of the examples seem to feature symbols.
>  
>  Can anyone show me a nice small example of how to achieve this?
>  

Based on this description of what you're trying to achieve it is not
very clear what the best approach to take is. It basically depends a
lot on *when precisely* this "particular point into the execution of
the program" is. Let me explain what I mean.

I assume that your required object is also a HiveMind service and that
you by "can't be known" mean that this services *implementation* is
not known.

If you want to use HiveMind constructs (e.g. symbols as you say) to
solve this problem, then the implementation of the required service
must be known at the time HiveMind constructs it. And this is the
first time one of the service methods is invoked. If the
implementation isn't known until later you have to address this
problem in the application code.

That being said, symbols are indeed a way to solve this problem. You
can for instance use a symbol for the service's implementation class:

<service-point id="RequiredService" interface="SomeInterface">
 <construct class="${required.service.impl.class}"/>
</service-point>

Another solution you might want look into is conditional
contributions: http://jakarta.apache.org/hivemind/conditional.html.

HTH,

--knut

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