Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Injecting static variables

Posted on 2014-01-22
4
Medium Priority
?
233 Views
Last Modified: 2014-01-24
Is it possible to inject static variables of one class into another using spring config ?
0
Comment
Question by:FranklinRaj22
[X]
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
4 Comments
 
LVL 1

Expert Comment

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

Accepted Solution

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

Add setter method to inject the value.

Check this example :- http://www.felfelworld.com/2012/07/08/how-make-spring-initialize-static-variable/
0
 

Expert Comment

by:anwarul
ID: 39802253
question not clear
0
 

Author Comment

by:FranklinRaj22
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
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…
Suggested Courses

730 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