use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class ResourceEditor method setAsText.
@Override
public void setAsText(final String text) throws IllegalArgumentException {
final Resource resource = Resource.getResource(text);
setValue(resource);
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class AttributeMap method setProperties.
public void setProperties(final String resourceUrl) {
final Resource resource = Resource.getResource(resourceUrl);
final Properties properties = new Properties();
try {
properties.load(resource.getInputStream());
setProps(properties);
} catch (final Throwable e) {
Logs.warn(this, "Cannot load properties from " + resource, e);
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class AttributeMap method setPropertyResources.
public void setPropertyResources(final Resource[] resources) {
final Properties properties = new Properties();
for (final Resource resource : resources) {
try {
properties.load(resource.getInputStream());
} catch (final Throwable e) {
Logs.warn(this, "Cannot load properties from " + resource, e);
}
}
setProps(properties);
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class MapObjectFactory method toObject.
/**
* Convert the resource specified in the source parameter to an object. The properties parameter
* will override those specific properties.
*
* @param source
* @param properties
* @return
*/
static <V> V toObject(final Object source, final Map<String, ? extends Object> properties) {
final Resource resource = Resource.getResource(source);
final Resource oldResource = Resource.setBaseResource(resource.getParent());
try {
final MapEx resourceProperties = Json.toMap(resource);
resourceProperties.putAll(properties);
return toObject(resourceProperties);
} catch (final Throwable t) {
Logs.error(MapObjectFactoryRegistry.class, "Cannot load object from " + resource, t);
return null;
} finally {
Resource.setBaseResource(oldResource);
}
}
use of com.revolsys.spring.resource.Resource in project com.revolsys.open by revolsys.
the class MapObjectFactory method toObject.
/**
* Convert the resource specified in the source parameter to an object. The properties parameter
* will override those specific properties.
*
* @param source
* @param properties
* @return
*/
static <V> V toObject(final Object source, final Map<String, ? extends Object> properties, final BiConsumer<Resource, Throwable> errorHandler) {
final Resource resource = Resource.getResource(source);
final Resource oldResource = Resource.setBaseResource(resource.getParent());
try {
final MapEx resourceProperties = Json.toMap(resource);
resourceProperties.putAll(properties);
return toObject(resourceProperties);
} catch (final Throwable t) {
errorHandler.accept(resource, t);
return null;
} finally {
Resource.setBaseResource(oldResource);
}
}
Aggregations