@SuppressWarnings("unchecked")
public <E extends BasicBean> E getBean(UniqueID id, long timeout) {
if (id == null) {
throw new NullPointerException("the unique id must'nt be null");
}
IDocument doc = getDocument(id, -1L);
if (doc == null) {
// try to find it localy in campaign
BasicBean bean = searchBean(getSpecificPath(), id);
if (bean != null) {
documentAdded(bean);
} else {
// try to find it globaly
bean = searchBean(getGlobalPath(), id);
if (bean != null) {
// add to document in order to avoid search agains
addDocument(new DocumentLocal(bean));
}
}
doc = getDocument(id, timeout);
}
return doc == null ? null : (E) doc.getBeanEncapsulator().getBean();
}