• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using spring expressions

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help in using the below configration using spring expressions


I have a properties object which has system properties

here is the spring configration



to inject a property from this bean into other bean I do this




and I inject the bean serviceUrl into other beans.

<bean id="somebean" class="blah.....blah.SomeClass">
<property name="someproperty" ref="serviceUrl " />
</bean>

is there anyway I can avoid creating aserviceUrl bean and directly inject the propery into other beans using spring expressions?

Please advice
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.

#{systemProperties['ssi_launch_url']}

so if I have a bean class that I want to assign a property of that value I can do it.



Mark
 
srini carry
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Yes.

#{systemProperties['ssi_launch_url']}

so if I have a bean class that I want to assign a property of that value I can do it.



Mark



my object is this




and I tried this




this did not work cant I do this ?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well because it is a getter, you can do, and one other thing, I think systemProperties is a predefined implicit reference in Spring Expression Language.

so maybe the AuditProperties bean should be called auditProperties instead

so change the bean name to auditProperties and try

Wait a second. Why aren't those values just in a .properties file that you load in.

so in a file called auditProperties.properties put



Then you can load the file via

<util:properties id="auditProperties" location="locationOf/auditProperties.properties/>

Then you can use


#{auditProperties['ORG_ID']}

What you are currently doing is reinventing the wheel. Even if you didn't want it in a .properties file but still in code, you are reinventing the wheel because Java SDK comes with a class called Properties.


Mark">
 
srini carry
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is some example I can ofcourse put this in a property file , but this is a groovy file which I can change at runtime and app gets updated automatically , Please advice if I have this spring bean and I want to call getPropertyValue using spring expressions how to ?

Mark Spritzler wrote:Well because it is a getter, you can do, and one other thing, I think systemProperties is a predefined implicit reference in Spring Expression Language.

so maybe the AuditProperties bean should be called auditProperties instead

so change the bean name to auditProperties and try

Wait a second. Why aren't those values just in a .properties file that you load in.

so in a file called auditProperties.properties put



Then you can load the file via

<util:properties id="auditProperties" location="locationOf/auditProperties.properties/>

Then you can use


#{auditProperties['ORG_ID']}

What you are currently doing is reinventing the wheel. Even if you didn't want it in a .properties file but still in code, you are reinventing the wheel because Java SDK comes with a class called Properties.


Mark">

 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

srini carry wrote:This is some example I can ofcourse put this in a property file , but this is a groovy file which I can change at runtime and app gets updated automatically , Please advice if I have this spring bean and I want to call getPropertyValue using spring expressions how to ?



I don't understand the question. If I have an object that is a bean, has an id, and has a property. I get it via bean name dot property name. or if the property requires a dot in the name, then use brackets. Check out the Core Spring documentation.

#{beanName.propertyName} or

#{beanName['propertyName]

Both work.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic