Spring 加载实现没有 xml

Spring load Implementation no xml

我有下一个问题,我有一个 SPRING 应用程序,其配置为 xml(没有 Spring),此文档的名称为 class在我的应用程序中实现(可以说 com.stack.impl.MyClass),这个 classs 实现我的界面(可以说是 MyInterface) 所以我想在发生某些事情时动态调用实现,如下所示:

    String myClass=xml.getProperty(id);
    MyInterface myInterface=ctx.getBean(myClass);
    myInterface.execute();

有什么建议吗?感谢和问候

我使用了这个方法,非常感谢你的帮助@duffymo 和@jjhavokk,希望你能从其他人那里得到同样的帮助:

public AnnotationConfigApplicationContext init(){
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    try { 
        Class<DataPreProcessor> c= (Class<DataPreProcessor>) Class.forName("com.banamex.middleware.commons.DataPrepProcesorTest");
        Class<DataPreProcessor> c2= (Class<DataPreProcessor>) Class.forName("com.banamex.middleware.commons.DataPrepProcesorTest2");
         DataPreProcessor dp=c.newInstance();
        DataPreProcessor dp2=c2.newInstance();
        context.getBeanFactory().registerSingleton("c", dp);
        context.refresh();
    } catch (InstantiationException e) {

        e.printStackTrace();
    } catch (IllegalAccessException e) { 
        e.printStackTrace();
    } catch (ClassNotFoundException e) { 
        e.printStackTrace();
    } 
    return context;
}