• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spring property initialization with java property

 
Kazimierz Trzonek
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I would like to initialize my byte property with java constant, is it
possible? how can I do it? where is it explained? i checked spring reference, and there's no such example (http://static.springframework.org/spring/docs/2.5.x/reference/beans.html).
I would like sth like:
<property name="whenExhaustedAction" >
<value>
org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_FAIL
</value>
</property>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a FieldRetrievingFactoryBean to retrieve the static WHEN_EXHAUSTED_FAIL.

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it is much easier than that.

The util namespace can access a constant for you. I believe it is

<util:constant> and tell it which constant to use.

Here is the documentation link

http://static.springframework.org/spring/docs/2.5.x/reference/xsd-config.html#xsd-config-body-schemas-util-constant

You will notice the first example is the same that Christophe posted, then the next code example is with using <util:constant> to make it easier.

Mark
[ October 09, 2008: Message edited by: Mark Spritzler ]
 
Kazimierz Trzonek
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You, both solutions work.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark, I didn't know about util:constant.

"Bolek Lolek", please check your privates messages.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic