try { ctx.getBeanFactory(); } catch (IllegalStateException ise) { ctx.refresh(); }
    public static OmeroContext getInstance(String beanFactoryName)    {        OmeroContext ctx = (OmeroContext)         ContextSingletonBeanFactoryLocator.getInstance()            .useBeanFactory(beanFactoryName).getFactory();        return ctx;    }