title: Is there a handy way to get the name of a Spring Bean/Service?
body: <p>I could do SomeSpringService.class.getSimpleName() and lowercase the first letter to get the default bean name, but I'm wondering if there is a simple Spring function that could find this for me? Simple meaning I'm not getting the application context, or building a factory, or such.</p>
  
  <p>Thank you</p>
  
  <p>Update: current hack</p>
  
  <pre><code>@Service
  public class ServiceSelector
  {
     @Autowired
     Map&lt;String, IThing&gt; implementations;
  
     public SomethingInterface getDecisionStrategy(AnEnum type)
     {
        SomethingInterface something;
  
        switch (type)
        {
          case ONE:
             implementation = findInstance(Impl1.class);
             break;
          case TWO:
             implementation = findInstance(Impl2.class);
             break;
           default:
              implementation = findInstance(Impl2.class);
        }
        return implementation;
     }
  
     private SomethingInterface findInstance(Class clazz)
     {
        String className = clazz.getSimpleName();
        String defaultBeanName = Character.toLowerCase(className.charAt(0)) + className.substring(1);
        return implementations.get(defaultBeanName);
     }
  }
  </code></pre>