class SpringServiceManager implements ServiceManagerSystem {

    @SuppressWarnings("unchecked")
    @Override
    public <T> T getServiceByName(String name, Class<T> type) {
        T bean = null;
        // handle special case to return the core AC
        if (ApplicationContext.class.getName().equals(name)
                && ApplicationContext.class.isAssignableFrom(type)) {
            bean = (T) getApplicationContext();
        } else {
            if (name != null) {
                // get by name and type
                try {
                    bean = (T) applicationContext.getBean(name, type);
                } catch (BeansException e) {
                    // no luck, try the fall back option
                    log.info("Unable to locate bean by name or id=" + name + ". Will try to look up bean by type next.");
                    bean = null;
                }
            } else {
                // try making up the name based on the type
                try {
                    bean = (T) applicationContext.getBean(type.getName(), type);
                } catch (BeansException e) {
                    // no luck, try the fall back option
                    log.info("Unable to locate bean by name or id=" + type.getName() + ". Will try to look up bean by type next.");
                    bean = null;
                }
            }
            // if still no luck then try by type only
            if (name == null
                    && bean == null) {
                try {
                    Map<String, T> map = applicationContext.getBeansOfType(type);
                    if (map.size() == 1) {
                        // only return the bean if there is exactly one
                        bean = (T) map.values().iterator().next();
                    }
                    else
                    {
                        log.error("Multiple beans of type " + type.getName() + " found. Only one was expected!");
                    }
                } catch (BeansException e) {
                    // I guess there are no beans of this type
                    log.error(e.getMessage(), e);
                    bean = null;
                }
            }
        }
        return bean;
    }

    public  SpringServiceManager(ServiceManagerSystem parent, DSpaceConfigurationService configurationService, boolean testMode, boolean developmentMode, String... configPaths);

}