Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Conversation

@allen-servedio
Copy link
Contributor

Closes #93

@jthomas - Okay, here is my attempt at adding the Java runtime. Apologies if there are some obvious NodeJS coding issues. Just let me know what you want altered.

I installed it locally and pushed up a simple Java action and was able to call it.

@codecov-io
Copy link

codecov-io commented Feb 7, 2018

Codecov Report

Merging #94 into master will increase coverage by 0.28%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
+ Coverage    83.9%   84.19%   +0.28%     
==========================================
  Files          40       41       +1     
  Lines        1373     1398      +25     
  Branches      276      279       +3     
==========================================
+ Hits         1152     1177      +25     
  Misses        221      221
Impacted Files Coverage Δ
compile/functions/runtimes/index.js 100% <100%> (ø) ⬆️
compile/functions/runtimes/java.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 419af45...434d0c3. Read the comment docs.

@jthomas
Copy link
Contributor

jthomas commented Feb 7, 2018

@allen-servedio Fast work on getting this implemented!

I'll code review tomorrow and let you know if I find anything.

Can you add docs to the README for Java support? Follow the style here:
https://github.com/serverless/serverless-openwhisk#writing-functions---php

Once this is ready, we should drop a PR to the main framework project. This will include adding docs which get imported on hosted on their site, a template project for the Java runtime and examples in the serverless/examples project to show people how to use it.

Thanks again for doing this! Congrats on the first PR to this project. Since you know your way around the code-base now, feel free to open issues and send PRs for other stuff you find!

@allen-servedio
Copy link
Contributor Author

Okay @jthomas, pushed the docs (sorry I missed them initially). Let me know what changes you want and generally what you want in the PR for the examples, etc...

README.md Outdated
runtime: java
functions:
hello:
handler: target/hello-world-1.0.jar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to provide both the JAR file and the main class in the handler parameter. This keeps it consistent with the other runtimes which use a file.method style. For this runtime, we would adopt the following:

    handler: target/hello-world-1.0.HelloWorld

This should be a small change to your PR - I think if you back out the convertHandlerToPath & calculateFunctionMain fns it should just work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is going to get a little gnarly if they follow the standard practice of NOT using the default package and actually place their class into a package. For example, if they put the class in a package called com.company.app then the handler will look like this:

handler: target/hello-world-1.0.com.company.app.HelloWorld

That is visually a bit hard to parse (and I THINK breaks the code you were referring to). I suppose you could do something like this:

handler: target/hello-world-1.0.jar:com.company.app.HelloWorld

The reason I used annotation in this pull request was I saw that was how you marked an action as a web action... So I was thinking annotations could be used to provide further refinements of how actions needed to be deployed. That being said, I understand what you mean by consistency, so definitely open to changing that part.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that might get a bit long. handler: target/hello-world-1.0.jar:com.company.app.HelloWorld is definitely a bit better style.

Annotations are actually passed through to the platform when creating the actions. They aren't used for meta-data inside the framework if you see what I mean?

I agree it does get a bit long but think the second style (with :) is the best compromise between consistency and readability.

@jthomas
Copy link
Contributor

jthomas commented Feb 8, 2018

This PR is looking really good - great doc updates!

Everything looks fine apart from a small change to how we define the main to be consistent with the other runtimes. If you can get that done, I'll merge this and work on a new release to get this great change out asap.

Thanks for the work on this 👍

…e to adding it after the jar with a colon between.
@allen-servedio
Copy link
Contributor Author

Okay changes pushed @jthomas . Let me know where I need to make the other doc changes and I can run up another PR. Thanks!

@jthomas jthomas merged commit 761c343 into serverless:master Feb 12, 2018
@jthomas
Copy link
Contributor

jthomas commented Feb 12, 2018

This looks perfect, thanks for the changes. I'll make a note to get a release out with this in soon.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants