Command Line like Django Command in Play Framework - command-line

I want to make a Java function in Play Framework Project, and want to execute it in terminal like Django command, my purpose is to run it in cron after ready.
Is it possible to do that? I'm sorry, maybe it rather sound silly, but I'm not a java developer, I'm python/Django developer and requested to help another team. Thanks anyway.

As play strongly supports RESTful approaches to development, you should simply be able to call your Play action via a well defined URL, and then use CURL to call your action via that URL.
However, you could also use the concept of Jobs in Play. Play jobs was designed to give CRON like functionality within your applications without needing to rely on external scheduling mechanisms.

Related

Is it possible to run a webserver with apache openwhisk?

I'm working on a project in my University, and we want to use an Apache OpenWhisk service for our student projects. I already set up the OpenWhisk service and add some components like Java, NodeJS and Python, everything works fine. My next step is to set up a webserver, so our students can use this instances to publish their websites (written in HTML, PHP, Java Script). I have already searched for this topic but don't found anything.
Hopefully someone can help me.
There are several ways to accomplish this and it depends on how far you want to go in the serverless direction.
For example this repo https://github.com/jthomas/express_example is a way to package an existing web server inside a function. This is another variation on the same https://github.com/IBM/expressjs-openwhisk.
If you want the students to implement a serverless web application from scratch, then generally every API end point becomes a function using web actions https://github.com/apache/openwhisk/blob/master/docs/webactions.md.
You can use web actions to also serve static content (html, js, css) by inlining those files and returning them as part of the function result. This is not ideal and should be done from a CDN instead. OpenWhisk itself does not offer object storage/CDN support but you can use S3 or Google buckets to accomplish the same.
Some serverless platforms like Netlify or Nimbella might be suitable. The latter provides an integrated CDN + OpenWhisk to implement entire web applications including JAMstack.

Adding REST support to application

I have a requirement to provide REST support to my application. Currently my application is in Linux, it has CLI commands available to configure it. I want to add REST API support to it such that I can configure my application using REST calls too. I want to have a simple HTTP server just for the REST calls and then map those requests to the respective CLI commands for addition, deletion, updation.
Can anyone provide me some info on what I should look at, tools available to perform the same, some good links to look at.
You could try subclassing the http.server.BaseHTTPRequestHandler class in Python3.
It has a simple interface for your needs. Simply add the do_<Method Name> functions to your subclass that respectively create the command line arguments and invoke your application.

Searching workflow/process tool based on ZF

Does anyone know a workflow system based on Zend (or php), which is open source and can be integrated in a project? What do I understand as workflow system:
User starts a workflow through submitting some start parameter (e.g. SOAP/HTML request)
Zend runs the workflow in the background (on high server load the operations are lined up in a queue)
Workflow may be build out of several modules/actions e.g. export xml > create pdf > send pdf to user > send email (Backend)
User sees current status of the running workflow online and gets the result as soon as finished through ajax requests to the server. (User Interface)
Admin has a overview of general running workflows (Admin Interface)
Thanks for your hints!
If I understand correctly, the workflow is just a pre-defined set of actions.
I don't believe there is a ready tool for this, but I think you may be interested in running a set of cron jobs from the Zend Framework CLI (e.g. building your own Zend_Tool Provider) and in Zend_Queue.
You might want to use the right tool for such task - eg. Gearman. It is a piece of software solely for the requirements you described. See more here:
http://www.slideshare.net/felixdv/high-gear-php-with-gearman
http://weierophinney.net/matthew/archives/240-Writing-Gearman-Workers-in-PHP.html
You may want to try eZ Components Workflow library: http://www.ezcomponents.org/docs/api/trunk/introduction_Workflow.html
This post describes how to integrate the eZ Components library with Zend:
http://devzone.zend.com/article/156
Other than that I haven't found any real examples of integrating the eZ workflow classes with a Zend MVC application.
Symfony has a component for this. http://symfony.com/doc/current/components/workflow.html
Oro platform has a bundle for this.
https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Resources/doc/index.md
Otherwise, you could build your own implementation based on maybe the State design pattern. Here is a nice example from Sebastian Bergman.
https://github.com/sebastianbergmann/state

Applets and liftweb in scala

My goal is to create an applet on a client machine which somehow is able to communicate back and forth with the same server that deployed the applet. One way of doing this would of course be through some kind of AJAX code, but if it's possible I'd very much like to keep everything in Scala.
So far I've used remote actors which have the unfortunate consequence that the applet needs to be signed. Which isn't an optimal solution either. I'm searching for alternate solutions.
Is there any way to make an applet deployed by liftweb communicate with lift directly via Scala?
Communication through remote actors is directly via Scala.
Now, Lift enables one to run JavaScript code on the client, communicating with the Scala server seamlessly (and without having to write a single line of JavaScript code). See the many Lift examples for that (for instance, the wizard).

GWT test with external server

I have a server-code that's written in Python, and I have a client-code that's written with GWT. Now I want to run automation testing on the GWT against the data from the Python server.
From what I searched, people recommends using the Selenium, but I prefer to have a GWT-test that has more visibility into the client-code. That way I can verify the local database, and any data that are not exposed to the UI.
Also at this point I'm not too worried about the DOM aspect, layout, and the other UI stuff.
Is there anyway to make the GWTTest work with external server?
I've tried to search for the solution, or people with similar problem, but I couldn't find one. If this question has been asked previously, I apologize.
Thanks, KOkon.
You can use the GWTTest framework to incorporate testing some GWT components that call the server. But the tests won't be able to communicate directly with the server. If you need your tests to set up state on the server, I'm afraid you'll need to write special "for testing purposes only" RPC servers or servlets or similar to do it.
Having said that, I would (presumably like those who suggested Selenium) recommend three types of tests:
Unit tests for server components, and unit GWTTests for client components,
Integration tests for testing server code interaction with database, etc.
Selenium acceptance tests, which are "black box" - they don't have access to the innards of the GWT components.
What you could do is create a proxy servlet that gets started in the GWTTestCase embedded Jetty instance. That proxy could forward all calls to you real services in Python.