can we use java code in web2py application code?

戏子无情 提交于 2019-12-07 04:57:25

I would consider looking into webservices. If you could expose url from java, that will route to a method/function of java where logic is performed and it returns json object. While in web2py urllib2 you can make a request and decode that json into native python dictionary. The clue is that you would have to expose all the methods of objects and pass the object back and forth as json. Do not be scared in most programming lanugages objects are just hash_arrays/dictionaries with some special qualities. So if you can serialize and deserialize the object and expose apriopriate urls you will be fine.

Also there is implementation of web2py in jython. But then the entire stack will be in JVM and i may be more complex to work with.

If all the java is doing is connecting to a remote machine, then I strongly recommend that you reimplement it in python.

If it is doing something substantive, then consider putting a web interface in front of it (I like the spark microframework for this), and you can speak to it using the requests module (get it via pip).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!