// There can be a race between this exists() check and the next
// access of the manager+id (which is typically coming in a few
// nanoseconds). That is OK, the layer below is authoritative.
if (!this.manager.exists(instanceid, Manager.INSTANCE)) {
throw new NoSuchResourceException(
"unknown workspace: '" + instanceid + "'");
}
final Element el = this.cache.get(instanceid);
final InstanceResource resource;
if (el == null) {
resource = new InstanceResource(instanceid,
this.manager,
this.secDescPath,
this.translate,
this,
this.timerManager);
resource.load(rkey);
this.manager.registerDestructionListener(instanceid,
Manager.INSTANCE,
resource);
this.cache.put(new Element(instanceid, resource));
} else {
resource = (InstanceResource) el.getObjectValue();
}
return resource;
} catch (ConfigException e) {
logger.error(e.getMessage(), e);
throw new ResourceException(e.getMessage(), e);
} catch (ManageException e) {
logger.error(e.getMessage(), e);
throw new ResourceException(e.getMessage(), e);
} catch (DoesNotExistException e) {
throw new NoSuchResourceException(e.getMessage(), e);
} catch (NoSuchResourceException e) {
throw e;
} catch (Throwable t) {
logger.error(t.getMessage(), t);
throw new ResourceException(t.getMessage(), t);