You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Aleksej <al...@ivs.lt> on 2006/07/11 14:53:47 UTC
How to inject into many services the same Long value?
Hi!
I have lots of services and all of them ( almost ) require Long value
to be injected in it.
This value must be configured in one place ( properties file is ideal
variant, but configuration-point is good too ).
So far I have only 2 ideas how to make it:
1)
Create configuration point for Long and configure all services with it
and after
injection read first of them. But I don't know how to make configuration
of primitives
and I don't like that service will get List but not Long.
2)
Create very simple service which reads Long value from some properties
file ( on classpath or anywhere else ),
and has property which returns it. Then to configure each service to
inject service object in it. Something
like "service-property:ApplicationConfig:myLongValue".
But I probably want to have something like:
<implementation service-id="SomeService">
<invoke-factory model="singleton">
<construct class="ClassFullName">
<long>${myLongValue}</long>
</construct>
</invoke-factory>
</implementation>
and to provide ${myLongValue} in some external properties file ( or
maybe some other way ).
I think that I need to dig for word "symbol" but I don't know what is it
and is it really
the thing I searching for.
Re: How to inject into many services the same Long value?
Posted by Aleksej <al...@ivs.lt>.
Shing, thanks for wonderful example!
Using it and James example I made everything as I wanted!
Shing Hing Man wrote:
> I got an example of setting up a symbol source (a
> property file) in HiveMind.
>
> http://lombok.demon.co.uk/hiveMind/welcome?service=page/ListOfStringsSymbolSourceCP
>
> It might be useful to you.
> But I have not tried using
> <long>${myLongValue}</long>
>
> in <invoke-factory>.
>
> Shing
>
> --- Aleksej <al...@ivs.lt> wrote:
>
>
>> Hi!
>> I have lots of services and all of them ( almost )
>> require Long value
>> to be injected in it.
>> This value must be configured in one place (
>> properties file is ideal
>> variant, but configuration-point is good too ).
>> So far I have only 2 ideas how to make it:
>> 1)
>> Create configuration point for Long and configure
>> all services with it
>> and after
>> injection read first of them. But I don't know how
>> to make configuration
>> of primitives
>> and I don't like that service will get List but not
>> Long.
>> 2)
>> Create very simple service which reads Long value
>> from some properties
>> file ( on classpath or anywhere else ),
>> and has property which returns it. Then to configure
>> each service to
>> inject service object in it. Something
>> like
>> "service-property:ApplicationConfig:myLongValue".
>>
>> But I probably want to have something like:
>> <implementation service-id="SomeService">
>> <invoke-factory model="singleton">
>> <construct class="ClassFullName">
>> <long>${myLongValue}</long>
>> </construct>
>> </invoke-factory>
>> </implementation>
>> and to provide ${myLongValue} in some external
>> properties file ( or
>> maybe some other way ).
>> I think that I need to dig for word "symbol" but I
>> don't know what is it
>> and is it really
>> the thing I searching for.
>>
>>
>
>
> Home page :
> http://uk.geocities.com/matmsh/index.html
>
>
>
> ___________________________________________________________
> The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
>
>
>
RE: How to inject into many services the same Long value?
Posted by James Carman <ja...@carmanconsulting.com>.
No problem. Here's how I use symbols in my tapestr-acegi module:
<contribution configuration-id="hivemind.FactoryDefaults">
<default symbol="tapestry.acegi.anonymous.key" value="acegi_anonymous"/>
<default symbol="tapestry.acegi.anonymous.userAttribute"
value="anonymous,ROLE_ANONYMOUS"/>
</contribution>
<service-point
id="AnonymousProcessingFilter"
interface="javax.servlet.Filter">
<invoke-factory>
<construct
class="org.acegisecurity.providers.anonymous.AnonymousProcessingFilter"
initialize-method="afterPropertiesSet">
<set property="key"
value="${tapestry.acegi.anonymous.key}"/>
<set property="userAttribute"
value="${tapestry.acegi.anonymous.userAttribute}"/>
</construct>
</invoke-factory>
</service-point>
If you want to see the whole file, you can look at:
http://svn.javaforge.com/svn/tapestry/tapestry-acegi/trunk/src/main/resource
s/META-INF/hivemodule.xml
Use anonymous/anon to login if it asks (which it should). Hope that helps!
-----Original Message-----
From: Aleksej [mailto:aleksej@ivs.lt]
Sent: Tuesday, July 11, 2006 9:44 AM
To: user@hivemind.apache.org
Subject: Re: How to inject into many services the same Long value?
Thanks Shing and James!
I will investigates symbols a little bit later, coz now my head is about
to blow :)
Re: How to inject into many services the same Long value?
Posted by Aleksej <al...@ivs.lt>.
Thanks Shing and James!
I will investigates symbols a little bit later, coz now my head is about
to blow :)
Re: How to inject into many services the same Long value?
Posted by Shing Hing Man <ma...@yahoo.com>.
I got an example of setting up a symbol source (a
property file) in HiveMind.
http://lombok.demon.co.uk/hiveMind/welcome?service=page/ListOfStringsSymbolSourceCP
It might be useful to you.
But I have not tried using
<long>${myLongValue}</long>
in <invoke-factory>.
Shing
--- Aleksej <al...@ivs.lt> wrote:
> Hi!
> I have lots of services and all of them ( almost )
> require Long value
> to be injected in it.
> This value must be configured in one place (
> properties file is ideal
> variant, but configuration-point is good too ).
> So far I have only 2 ideas how to make it:
> 1)
> Create configuration point for Long and configure
> all services with it
> and after
> injection read first of them. But I don't know how
> to make configuration
> of primitives
> and I don't like that service will get List but not
> Long.
> 2)
> Create very simple service which reads Long value
> from some properties
> file ( on classpath or anywhere else ),
> and has property which returns it. Then to configure
> each service to
> inject service object in it. Something
> like
> "service-property:ApplicationConfig:myLongValue".
>
> But I probably want to have something like:
> <implementation service-id="SomeService">
> <invoke-factory model="singleton">
> <construct class="ClassFullName">
> <long>${myLongValue}</long>
> </construct>
> </invoke-factory>
> </implementation>
> and to provide ${myLongValue} in some external
> properties file ( or
> maybe some other way ).
> I think that I need to dig for word "symbol" but I
> don't know what is it
> and is it really
> the thing I searching for.
>
Home page :
http://uk.geocities.com/matmsh/index.html
___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html
RE: How to inject into many services the same Long value?
Posted by James Carman <ja...@carmanconsulting.com>.
I would use a symbol for this. If you have to change a properties file (and
re-deploy of course), then you can just as easily change your hivemodule.xml
file. Correct?
-----Original Message-----
From: Aleksej [mailto:aleksej@ivs.lt]
Sent: Tuesday, July 11, 2006 8:54 AM
To: hivemind-user@jakarta.apache.org
Subject: How to inject into many services the same Long value?
Hi!
I have lots of services and all of them ( almost ) require Long value
to be injected in it.
This value must be configured in one place ( properties file is ideal
variant, but configuration-point is good too ).
So far I have only 2 ideas how to make it:
1)
Create configuration point for Long and configure all services with it
and after
injection read first of them. But I don't know how to make configuration
of primitives
and I don't like that service will get List but not Long.
2)
Create very simple service which reads Long value from some properties
file ( on classpath or anywhere else ),
and has property which returns it. Then to configure each service to
inject service object in it. Something
like "service-property:ApplicationConfig:myLongValue".
But I probably want to have something like:
<implementation service-id="SomeService">
<invoke-factory model="singleton">
<construct class="ClassFullName">
<long>${myLongValue}</long>
</construct>
</invoke-factory>
</implementation>
and to provide ${myLongValue} in some external properties file ( or
maybe some other way ).
I think that I need to dig for word "symbol" but I don't know what is it
and is it really
the thing I searching for.