First iteration of support for Java

This commit is contained in:
Mukhtar Haji
2017-06-01 02:19:37 -07:00
committed by Matthew Gilliard
parent 82d612a754
commit cd0b68dfb7
12 changed files with 246 additions and 21 deletions

View File

@@ -0,0 +1 @@
func.yaml

View File

@@ -0,0 +1,13 @@
import java.io.*;
public class Func {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String name = bufferedReader.readLine();
name = (name == null) ? "world" : name;
System.out.println("Hello, " + name + "!");
}
}

View File

@@ -0,0 +1,43 @@
# Oracle Functions: Java
This is a hello world example of a Oracle Function using the Java runtime.
Firstly, we initialize our function by creating a `func.yaml` using `fn init`. This command can optionally take a `--runtime` flag to explicitly specify the target function runtime. In this example, the target runtime is implied to be Java because there is a `Func.java` file in the working directory.
```sh
$ fn init <YOUR_DOCKERHUB_USERNAME>/hello-java
```
This is what our `func.yaml` looks like now.
```
name: mhaji/hello-java
version: 0.0.1
runtime: java
entrypoint: java Func
path: /hello-java
max_concurrency: 1
```
Next, we build and run our function using `fn run`.
```sh
$ fn run
Hello, world!
```
You can also pipe input via `stdin` into to the function as follows:
```sh
$ echo "Michael FassBender" | fn run
Hello Michael FassBender!
```
To execute your function via a HTTP trigger:
```sh
fn apps create myapp
fn routes create myapp /hello
curl -H "Content-Type: text/plain" -X POST -d "Michael FassBender" http://localhost:8080/r/myapp/hello
```