Skip to content

Commit bb500e4

Browse files
Merge pull request #82 from fnproject/mww-190614-jfdk-regex
Update Java fdk Regex example to latest code. Checked with Angie. Merging.
2 parents 081685b + 10eaa85 commit bb500e4

File tree

9 files changed

+40
-19
lines changed

9 files changed

+40
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

fdks/fdk-java/examples/regex-query/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This example provides an HTTP endpoint for performing regex matching on strings.
44

55
```bash
6-
$ curl -d '{ "text": "One, 2, Three, 4, Five", "regex": "\\\\d" }' 'http://localhost:8080/r/regex-query/query'
6+
$ curl -d '{"text":"One, 2, Three, 4, Five", "regex":"\\d"}' 'http://localhost:8080/t/regex-query/query'
77
{"regex":"\\d","text":"One, 2, Three, 4, Five","matches":[{"start":5,"end":6,"match":"2"},{"start":15,"end":16,"match":"4"}]}
88
```
99

@@ -34,7 +34,7 @@ Create an app and route to host the function
3434

3535
```bash
3636
$ fn create app regex-query
37-
$ fn create route regex-query /query
37+
$ fn --verbose deploy --app regex-query --local
3838
```
3939

4040
Invoke the function to perform a regex search
@@ -48,7 +48,7 @@ $ curl -d '{ "text": "One, 2, Three, 4, Five", "regex": "\\\\d" }' 'http://local
4848
## Code walkthrough
4949

5050
The entrypoint to the function is specified in `func.yaml` in the `cmd` key.
51-
This is set to be `com.fnproject.fn.examples.RegexQuery::query`. The class
51+
This is set to be `com.example.fn.RegexQuery::query`. The class
5252
containing the function is shown below:
5353

5454

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: fn-example/regex-query
2-
version: 0.0.1
1+
schema_version: 20180708
2+
name: query
3+
version: 0.0.4
34
runtime: java
4-
timeout: 30
5-
format: http
6-
cmd: com.fnproject.fn.examples.RegexQuery::query
7-
path: /query
5+
build_image: fnproject/fn-java-fdk-build:jdk11-1.0.96
6+
run_image: fnproject/fn-java-fdk:jre11-1.0.96
7+
cmd: com.example.fn.RegexQuery::query
8+
triggers:
9+
- name: query
10+
type: http
11+
source: /query
12+

fdks/fdk-java/examples/regex-query/pom.xml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<properties>
88
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
99
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
10-
11-
<fdk.version>1.0.0-SNAPSHOT</fdk.version>
10+
<maven.compiler.source>11</maven.compiler.source>
11+
<fdk.version>1.0.96</fdk.version>
1212
<jackson.version>2.9.9</jackson.version>
1313
</properties>
1414

15-
<groupId>com.fnproject.fn.examples</groupId>
15+
<groupId>com.example.fn</groupId>
1616
<artifactId>regex-query</artifactId>
17-
<version>1.0.0-SNAPSHOT</version>
17+
<version>1.0.0</version>
1818

1919
<dependencies>
2020
<dependency>
@@ -33,6 +33,11 @@
3333
<version>4.12</version>
3434
<scope>test</scope>
3535
</dependency>
36+
<dependency>
37+
<groupId>com.fnproject.fn</groupId>
38+
<artifactId>api</artifactId>
39+
<version>${fdk.version}</version>
40+
</dependency>
3641
<dependency>
3742
<groupId>com.fnproject.fn</groupId>
3843
<artifactId>testing-core</artifactId>
@@ -53,6 +58,7 @@
5358
</dependency>
5459
</dependencies>
5560

61+
5662
<build>
5763
<plugins>
5864
<plugin>
@@ -77,8 +83,16 @@
7783

7884
<repositories>
7985
<repository>
80-
<id>fn-maven-releases</id>
86+
<id>fn-release-repo</id>
8187
<url>https://dl.bintray.com/fnproject/fnproject</url>
88+
<releases>
89+
<enabled>true</enabled>
90+
</releases>
91+
<snapshots>
92+
<enabled>false</enabled>
93+
</snapshots>
8294
</repository>
8395
</repositories>
96+
97+
8498
</project>

fdks/fdk-java/examples/regex-query/src/main/java/com/fnproject/fn/examples/Match.java renamed to fdks/fdk-java/examples/regex-query/src/main/java/com/example/fn/Match.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fnproject.fn.examples;
1+
package com.example.fn;
22

33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.fasterxml.jackson.annotation.JsonProperty;

fdks/fdk-java/examples/regex-query/src/main/java/com/fnproject/fn/examples/Query.java renamed to fdks/fdk-java/examples/regex-query/src/main/java/com/example/fn/Query.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fnproject.fn.examples;
1+
package com.example.fn;
22

33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.fasterxml.jackson.annotation.JsonProperty;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package com.fnproject.fn.examples;
1+
package com.example.fn;
22

33
import java.util.ArrayList;
44
import java.util.List;
55
import java.util.regex.Matcher;
66
import java.util.regex.Pattern;
77

88
public class RegexQuery {
9+
910
public Response query(Query query) {
1011
return new Response(query.regex, query.text, getMatches(query));
1112
}

fdks/fdk-java/examples/regex-query/src/main/java/com/fnproject/fn/examples/Response.java renamed to fdks/fdk-java/examples/regex-query/src/main/java/com/example/fn/Response.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fnproject.fn.examples;
1+
package com.example.fn;
22

33
import com.fasterxml.jackson.annotation.JsonCreator;
44
import com.fasterxml.jackson.annotation.JsonProperty;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fnproject.fn.examples;
1+
package com.example.fn;
22

33
import com.fnproject.fn.testing.FnTestingRule;
44
import org.json.JSONException;

0 commit comments

Comments
 (0)