title: Performance: Utility class vs. CDI bean
body: <p>I want to externalize commonly used applicationlogic into a "utility class" called <strong>Helper</strong>. The applicationlogic needs other CDI beans to work.</p>
  
  <p>Two possibilities:</p>
  
  <p>a) </p>
  
  <pre><code>@SessionScoped
  class ControllerWithCdiBean {
  
    @Inject
    Helper helper;
  
    public void doIt() {
        Object result = helpder.calculate();
    }
  }
  
  @RequestScoped
  class Helper{
  
    @Inject
    Service anyService;
  
    public Object calculate() {
       return anyService.calc();
    }
  }
  </code></pre>
  
  <p>b)</p>
  
  <pre><code>@SessionScoped
  class ControllerWithStaticCallsViaDeltaspike {
  
    public void doIt() {
        Object result = Helpder.calculate();
    }
  }
  
  class Helper{
  
    private static Service anyService = BeanProvider.getContextualReference(Service.class);
  
    public static Object calculate() {
       return anyService.calc();
    }
  </code></pre>
  
  <p>What about <strong>performance</strong>? Are there any notable differences? Both solutions are possible for me, is one solutions <em>better</em> than the other?</p>
  
  <p>One disadvantage: 
  Helpder gets initialized for <strong>every</strong> Request.</p>