The first time I encountered e.g. Ruby's Sinatra framework or PHP's Zend Framework, I wondered if there is something adequate in Java, it all seems so bloated here. Although there are myriads of frameworks around, I have found none so far that I deemed perfect for the kind of architecture I would like to implement.
I wanted to design a web application that would be heavy on the Javascript with most of the application logic implemented on the client, the Java back-end would more or less just serve as a data store or perform complex computations.
I did look through related questions here but I couldn't find the perfect answer, each of the suggested solutions had a quirk that would not match the requirements.
So this is what I am looking for, a open source framework with the following features:
Basically this would mean an MVC framework that does the routing for me and offers template support for the views, but the rest is fully modular, no magic. Is there any minimalistic framework that would provide this (or at least is modular enough to be configured that way)?
The term "lightweight" refers to the conceptual weight of a framework. Lightweight frameworks like Spring have minimal impact to an application. That is, it does not require as many code changes to incorporate them into your application as does the more heavyweight frameworks like EJB.
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and deploy web applications on the World Wide Web.
JSON or JavaScript Object Notation is a widely used lightweight data format. JavaScript Object Notation (JSON) is a text-based data format for representing structured data. It is commonly used for transmitting data in web applications.
Vue is a highly popular web framework used to build single-page apps and user interfaces for web apps. The framework is based on MVVM architecture (Model-View-ViewModel). It is lightweight and has numerous tools and features to create functional user interfaces.
How about Play Framework?
Convention over Configuration
Play only has few configuration files. Most of its structure is by convention. For example the basic structure goes like this:
|
+---/app - All executable artifacts go here (java files, conf files and view templates).
| |
| +---/model - Your model Java classes.
| |
| +---/view - Your view templates.
| |
| +---/controller - Your controller classes
|
|---/conf - Contains all configuration files for the application. Initially contains application configuration and routing table.
|
|---/lib - Libraries your appliaction needs. Added automatically to classpath.
|
|---/log
|
|---/public - Public stuff are your static assets that your server gives directly
|
|---/test
|
|---/tmp - All your temporarily compiled .class files are here
No XML configuration except for web.xml
Play has no XML configuration, including no web.xml. It has a Routing file instead. See the example below what it uses for routing.
Pure Java (no Scala, no Groovy, ...)
It's pure Java, but you can use Scala or Groovy through a plugin.
- natural REST-style URLs such as /news/2011/july (no .do, no .jsp, ...)
- REST-aware
From the site:Play is a real "Share nothing" system. Ready for REST, it is easily scaled by running multiple instances of the same application on several servers.
In fact routing in a Rest like manner is quite easy:
# Play 'routes' configuration file…
# Method URL path Controller
GET / Application.index
GET /about Application.about
POST /item Item.addItem
GET /item/{id} Item.getItem
GET /item/{id}.pdf Item.getItemPdf
It's not hard to guess which goes where once you get used to Play a bit.
- it shouldn't force me to deploy on an application server (e.g. EJB should be optional)
It doesn't. In fact you deploy by saving your files. EJB are completely optional and so are .war
, .ear
and other forms of deployment.
code generation as in Rails would be awesome but not mandatory
I don't think it does much code generation but I'm not 100% on that. It does automatically create all required folders and instantiate a basic example page. I don't know if Rails generates anything else...
MVC would be nice, but
- I'd like to be able to choose the M part, choose the persistence libraries on my own (no bundling).
- No automatically generated code for the view, neither HTML, Javascript, nor CSS
- An integrated template language would be nice, but it should be minimalistic (simple control flow,
See MVC in Play
.html
,.css
,.js
and other files to create dynamic pages.I has inbuilt template language based on Groovy template language e.g.
You have ${emails.unread ?: 'no'} ${emails.unread?.pluralize('email')} !
Other pros:
Cons:
I have used the Stripes framework on several projects in the past, and it sounds like it meets all/most of your criteria, especially the convention over configuration. There is no XML configuration- there is one stripes.properties file that has general behavioral configuration (it's a one time addition to your classpath). A one time edit to the web.xml is needed to configure the "Stripes Dispatcher", which is a Filter that routes requests to their appropriate action beans. ActionBeans are automatically discovered, so you do not have to even update your web.xml when you add more Action Beans. Your URLs are all set up using annotations on the action beans, rest supported, dynamic ActionBean bindings, Server-Side validation and conversion via built-in annotations for simple types, with the ability to create your own validation handlers and convertors for complex types. Works with JSPs and your custom JS/CSS libraries. Documentation and support forums are great. It's quick to learn if you follow their tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With