Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Spring injection in enum value - question

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic