if(StringUtil.isEmpty(name)) {
name = defaultName;
}
// Look for a global property setting the default server, if the parameter is empty
if(StringUtil.isEmpty(name)) {
throw new SBTException(null,"The name of the endpoint is empty");
}
// Look for a property defining the bean associated to this server
Context context = Context.get();
String beanName = context.getProperty(SERVERPROP_PREFIX+name, null);
if(StringUtil.isEmpty(beanName)) {
beanName = SERVERBEAN_PREFIX+name;
}
// Look for a bean and/or class
Object o = context.getBean(beanName);
if(o!=null) {
if(!(o instanceof Endpoint)) {
throw new SBTException(null,"Invalid ServerBean implementation for bean {0} is instance of {1}",beanName,o.getClass());
}
else{
((AbstractEndpoint)o).setName(beanName);
}
return (Endpoint)o;