spring bean interface definition
<p>Is it possible to register interface and somehow to attach interface implementation to it through the bean definitions?
Simply I want to do this:</p>

<pre><code>@Bean
public MyInterface myInterface(){
 return new MyInterfaceImpl();
}

interface MyInterface{
}
class MyInterfaceImpl implements MyInterface{
}
</code></pre>

<p>but using BeanDefinitionRegistry in this way:</p>

<pre><code>@Autowired
ApplicationContext applicationContext;

public void register() {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) applicationContext.getAutowireCapableBeanFactory();
BeanDefinition myDefenition = BeanDefinitionBuilder
        .genericBeanDefinition(MyInterface.class)
        .setScope(BeanDefinition.SCOPE_SINGLETON)
        .getBeanDefinition();
registry.registerBeanDefinition("myInterface", myDefenition);
BeanDefinition myImplDefenition = BeanDefinitionBuilder
        .genericBeanDefinition(MyInterfaceImpl.class)
        .setScope(BeanDefinition.SCOPE_SINGLETON)
        .getBeanDefinition();
registry.registerBeanDefinition("myImpl", myImplDefenition);        
}
</code></pre>

<p>Here I want some magic to force</p>

<pre><code>applicationContext.getBeansOfType(MyInterface.class)
</code></pre>

<p>return <code>MyInterfaceImpl</code> beans.</p>

<p>I've browsed the documentation but haven't found something like this.
Is it possible or am I just wasting my time?</p>