Yes and no, I like the code of MyClass, the next part is how you tell Spring there is the dependency between MyClass and the Hello class.
You can define another bean of type MyClass in your configuration and use a <property> tag in that <bean> tag that points or "ref"s references your "hello" bean. That is if you want it defined in the xml.
The other choice is to use Annotations. the @Autowired (Spring annotation) or the @Resource (JSR-250 annotation) does the trick. But to use annotations you have to put in the xml file that you are using annotations.
Now, if MyClass is not going to be a Spring Bean, then in MyClass you need to get a reference to the ApplicationContext object and call the getBean(
String beanName) method.
Mark