public Object getBean(String name) throws BeansException {
return getBean(name, null);
}
public Object getBean(String name, Class requiredType) throws BeansException {
SCAObject object = children.get(name); // keep cast due to compiler error
if (object == null) {
return null;
}
Class<?> type;
if (object instanceof Reference) {
type = ((Reference) object).getInterface();
} else if (object instanceof Service) {
type = ((Service) object).getInterface();
} else {
throw new AssertionError("Illegal object type [" + name + "]");
}
if (requiredType != null && requiredType.isAssignableFrom(type)) {
// need null check since Spring may pass in a null
throw new BeanNotOfRequiredTypeException(name, requiredType, type);
}
return object.getServiceInstance();
}