Skip to content

Commit 738f180

Browse files
authoredMar 9, 2021
Merge pull request #144 from radcortez/scripting
Script public constructor and getters.
2 parents 52599c1 + 7e447f4 commit 738f180

File tree

1 file changed

+19
-1
lines changed
  • jberet-core/src/main/java/org/jberet/job/model

1 file changed

+19
-1
lines changed
 

‎jberet-core/src/main/java/org/jberet/job/model/Script.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ public class Script implements Serializable, Cloneable {
7373
this.src = src;
7474
}
7575

76+
public Script(final String type, final String src, final String content) {
77+
this.type = type;
78+
this.src = src;
79+
this.content = content;
80+
}
81+
7682
/**
7783
* Gets the content of the script as string.
7884
* If the script is specified as inline in job XML, its content is returned. Otherwise, this method tries to load
@@ -112,7 +118,8 @@ public String getContent(final ClassLoader classLoader) {
112118
java.util.Scanner scanner = null;
113119
try {
114120
scanner = new java.util.Scanner(is).useDelimiter("\\A");
115-
return scanner.hasNext() ? scanner.next() : "";
121+
this.content = scanner.hasNext() ? scanner.next() : "";
122+
return content;
116123
} finally {
117124
if (scanner != null) {
118125
try {
@@ -125,6 +132,17 @@ public String getContent(final ClassLoader classLoader) {
125132
}
126133
}
127134

135+
public String getContent() {
136+
if (content == null) {
137+
throw new IllegalStateException();
138+
}
139+
return content;
140+
}
141+
142+
public String getSrc() {
143+
return src;
144+
}
145+
128146
/**
129147
* Gets the type of the script, for example, {@code javascript}.
130148
* @return type of the script

0 commit comments

Comments
 (0)