title: Inject dependencies into enum with guice(or Spring)
body: <p>I'm integrating a servlet application with Guice (could be Spring, I choose Guice just because I worked with it). And this application use constant-specific method extensively (thousands of enums). From service, it determine the action to call:</p>
  
  <pre><code>ActionEnum act = ActionEnum.valueof("Action from context");
  act.perform();
  </code></pre>
  
  <p>The enum action looks like this:</p>
  
  <pre><code>public enum ActionEnum {
      ACTION1 { perform() {}},
      ACTION2 { perform() {}};
      abstract void perform();
  }
  </code></pre>
  
  <p>Is there any way to inject something in to the enum class by Guice (or Spring)? eg:</p>
  
  <pre><code>public enum ActionEnum {
      ACTION1 {
         @Inject
         SomeClass case1ToBeUsedByAction1;
  
         void perform() { 
              case1ToBeUsedByAction1.doSomething();
              case2ToBeUsedByActionN.doSomething();
         }
      },
      ACTION2 { void perform() { case2ToBeUsedByActionN.doSomething(); }};
      abstract void perform();
      @Inject SomeClass case2ToBeUsedByActionN;
  }
  </code></pre>
  
  <p>Or how do I change the current code base to enable injection?</p>