}
if (o instanceof byte[])
{
try
{
final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
final Resource resource = resManager.createDirectly(o, Image.class);
return new DefaultImageReference(resource);
}
catch (ResourceException e)
{
if (ImageLoadFilter.logger.isDebugEnabled())
{
ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
}
else if (ImageLoadFilter.logger.isWarnEnabled())
{
ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
}
return null;
}
}
else if (o instanceof Blob)
{
try
{
final Blob b = (Blob) o;
final byte[] data = IOUtils.getInstance().readBlob(b);
final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
final Resource resource = resManager.createDirectly(data, Image.class);
return new DefaultImageReference(resource);
}
catch (Exception e)
{
if (ImageLoadFilter.logger.isDebugEnabled())
{
ImageLoadFilter.logger.debug("Error while loading the image from a blob", e);
}
else if (ImageLoadFilter.logger.isWarnEnabled())
{
ImageLoadFilter.logger.warn("Error while loading the image from a blob: " + e.getMessage());
}
return null;
}
}
else if (o instanceof URL)
{
// a valid url is found, lookup the url in the cache, maybe the image is loaded and
// still there.
final URL url = (URL) o;
final String urlText = String.valueOf(url);
if (failureCache.contains(urlText))
{
return null;
}
try
{
final ResourceManager resManager = runtime.getProcessingContext().getResourceManager();
final Resource resource = resManager.createDirectly(url, Image.class);
return new DefaultImageReference(resource);
}
catch (ResourceException e)
{
if (ImageLoadFilter.logger.isDebugEnabled())