]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/ResourceSpecAttribute.java
1 package org
.argeo
.slc
.core
.execution
;
3 import java
.io
.IOException
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.SlcException
;
8 import org
.springframework
.core
.io
.Resource
;
11 public class ResourceSpecAttribute
extends AbstractSpecAttribute
{
12 public final static String TYPE_PATH
= "path";
13 public final static String TYPE_URL
= "url";
14 public final static String TYPE_STREAM
= "stream";
16 private Resource resource
;
17 private String type
= TYPE_PATH
;
19 private final static Log log
= LogFactory
20 .getLog(ResourceSpecAttribute
.class);
22 public ResourceSpecAttribute() {
25 + " is deprecated and will soon be removed. Please use slcDefault.executionResources instead.");
28 public Object
getValue() {
29 return convertResource(resource
);
32 public void setResource(Resource resource
) {
33 this.resource
= resource
;
36 public Object
convertResource(Resource resource
) {
38 if (TYPE_PATH
.equals(type
))
39 return resource
.getFile().getCanonicalPath();
40 else if (TYPE_URL
.equals(type
))
41 return resource
.getURL().toString();
42 else if (TYPE_STREAM
.equals(type
))
43 return resource
.getInputStream();
45 throw new SlcException("Unkown type " + type
);
46 } catch (IOException e
) {
47 throw new SlcException("Cannot convert resource " + resource
, e
);
51 public void setType(String type
) {
55 public String
getType() {