Summary

We are now running the frontend web server in Python and the backend on the JVM. While this example isn't flashy or necessarily dynamic, it shows the capability of integrating these two systems together.

Since Jython is all about making it possible to run compiled class files, it becomes possible to replace the Java-based database code with something more sophisticated like a Groovy-based feed reader using its terse XmlSlurper module or a Scala-based system that monitors RSS feeds from multiple airlines.

At the same time, we can keep coding using our favorite Python tactics in CherryPy, or perhaps another web framework of choice. We can also write useful command-line scripts that access the same back end information.

A key point is that we didn't have to do the wiring ourselves. Instead of managing the low level API of Pyro, Spring Python did the work for us.

Spring Python offers many valuable features that we have visited throughout this book. There are many useful abstractions. But the abstractions aren't one-to-one with the ones provided by Spring Java. Instead, it focuses on Python libraries. For example, Spring Python integrates with Pyro, while Spring Java integrates with RMI. And this makes sense, because Python developers aren't as likely to integrate with an RMI-based system as they are to link together Python components.

This book also introduces the powerful concept of dependency injection. Spring Python and Spring Java share this philosophy. Throughout the various examples in this book, we saw how to decouple components and wiring them together in a container. This made it easy to test, introduce services with little impact, and allow rewiring as needs change. This gives developers the flexibility they need to adapt to changing requirements.

In this chapter we have learned how to:

  • Build a front end in CPython using CherryPy and then link it to a back end written in Java
  • Create the necessary adapter code to handle serialization between CPython and Java
  • Replace a Python-to-Python call with a Python-to-Java call with no impact to the front end or the back end
  • Compile Java code and run it from Jython using 3rd party libraries

I hope you have enjoyed this book, and that it will inspire you in new ways to design, code, and maintain more powerful systems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.244.217