aspose file tools*
The moose likes Other Application Frameworks and the fly likes spring property initialization with java property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "spring property initialization with java property" Watch "spring property initialization with java property" New topic
Author

spring property initialization with java property

Kazimierz Trzonek
Greenhorn

Joined: Oct 08, 2008
Posts: 22
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

You could use a FieldRetrievingFactoryBean to retrieve the static WHEN_EXHAUSTED_FAIL.



[My Blog]
All roads lead to JavaRanch
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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 ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Kazimierz Trzonek
Greenhorn

Joined: Oct 08, 2008
Posts: 22
Thank You, both solutions work.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Thanks Mark, I didn't know about util:constant.

"Bolek Lolek", please check your privates messages.
 
 
subject: spring property initialization with java property