• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

spring property initialization with java property

 
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>
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a FieldRetrievingFactoryBean to retrieve the static WHEN_EXHAUSTED_FAIL.

 
ranger
Posts: 17344
11
Mac IntelliJ IDE 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 VI Editor Ubuntu
  • 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.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!