Consider adding a service layer to keep the glue code out of the HTTP layer and to provide an API for other interfaces other than just HTTP. Obviously this is a trivial example, but you can easily extrapolate how to build out the application. The basic “hello world” from the home page looks like this: import static spark. Like Sinatra, it uses a simple routing syntax and contains the basic facilities needed for most HTTP APIs. The Spark Framework (not to be confused with Apache Spark) is a Sinatra inspired framework for creating web applications. The best part is, we can keep the sound design methods that help applications stay maintainable, while shedding that enterprisey baggage. Through the use of some newer frameworks, some pretty basic design patterns and aided by Java 8’s new lambda expressions, we can get a minimal Java web application up and running quite quickly. Java as a language requires a good deal of ceremony and the frameworks available, though incredibily powerful, haven’t always been the easiest to use. To a point, a lot of this is well deserved. Many times when a developer hears the word Java, it conjures up images of clunky, “enterprise” applications with layers of abstractions, SimpleBeanFactoryAwareAspectInstanceFactories, and loads of unnecessary boilerplate code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |