File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes Spring injection in enum value - question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "Spring injection in enum value - question" Watch "Spring injection in enum value - question" New topic
Author

Spring injection in enum value - question

Juan Rolando Prieur-Reza
Ranch Hand

Joined: Jun 20, 2003
Posts: 233
Can Spring provide dependency-injection in this example? If so, how?

In the code snippet below, the blank final declaration of the attribute strangeState
is satisfied in the enum's constructor by invoking new Straneness( int q).

If we want to eliminate the new Straneness( int q) by using Spring to assign an instance of Strangeness, we would have a problem.
First, the blank final would flag an error if strangeState is not defined during the constructor execution.
Second, if we simply assign null to strangeState, or remove the final, how can we be sure that Spring's subsequent
replacement of the strangeState value with new Straneness( int q) will not corrupt the bytecode? How would Spring handle this situation properly?



I believe this objective is beyond the capabilities of Spring. Let me know if you agree, or not. Thanks in advance for your constructive insights.


Juan Rolando Prieur-Reza, M.S., LSSBB, SCEA, SCBCD, SCWCD, SCJP/1.6, IBM OOAD, SCSA
 
 
subject: Spring injection in enum value - question
 
Threads others viewed
Enums in a map
Enums (Is this the best way)?
enums do not allow access to static members within constructors and instance init blocks
i want some information related to enum keyword
Hard Exam question
Two Laptop Bag