Injecting static variables

Posted on 2014-01-22
Last Modified: 2014-01-24
Is it possible to inject static variables of one class into another using spring config ?
Question by:FranklinRaj22
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 39802058
Can you please make it clear on what you meant by spring config.?

Accepted Solution

Mahesh Bhutkar earned 500 total points
ID: 39802138
You can use org.springframework.beans.factory.config.MethodInvokingFactoryBean.

Add setter method to inject the value.

Check this example :-

Expert Comment

ID: 39802253
question not clear

Author Comment

ID: 39806834
Sorry my mistake , I wanted to inject static variables from class A into Class B and wanted to do it via spring config file rather than doing it in the Class B code .

I used the below and it worked well .
util:constant static-field

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question