0

I develop server-sided products using websites as interfaces. The underlying logic is usually complex, however, the user interfaces are VERY simple (most of them are simple CRUD operations on mysql tables. The most complicated query usually takes a few joins, and everything is usually performed in an stateless way, except for user credentials).

Until now, I've designed my projects in this way:

  • PHP / HTML5 / JScript - A simple website to access data/configure options. It has NO direct access to the model. It needs to query the API (to minimize changes impact). Normaly I let the user fetch and process the data from the API using JavaScript.
  • PHP Api / MySQL - A PHP REST Api connected to the mysql model using my custom DB access class (made it for my first project, and after a few updates it usually covers most of the project's queries). The Api feeds data to our own JavaScript form controls and to custommer's custom GUIs. I prefer to ensure model's consistency within the database by normalizing it and using simple triggers to maintain consistency avoiding some dangerous edits in complex databases, so the most complex thing the PHP model does are complicated search queries or transactions. Some searches require the dynamic creation of queries for some auxiliary joins, however, this is not the normal scenario.
  • Executable file(s) with the complex logic, usually in C++, sometimes in Python or Java if time is a rush or there are really good libraries available and performance is not a key issue. It runs in background as service or gets invoked by PHP, depending on the project't needs. They're mostly Python, Java or C++. Background processes usually write directly to DB, while executed files give their output via stdout/err

As I said before, normally our websites are REALLY simple, so I built the base API and base website on top of Code Igniter for simplicity; as I said, that part of the application is really simple and covered by my own general classes.

The problem

I've two main problems:

  • I'm the only PHP developer left on the company, so my boss feels bad about project maintainability. He likes Java and I know Java, so he prefers to use Tomcat.
  • I've no professional experience on Java frameworks and I don't like to code the same things over and over again for every project, neither filling'em with boilerplate copy/pastes, so if I want some structured, pretty piece of code other's can understand frameworks are the way to go, as I'm not experienced enough with Tomcat to do it from scratch.

The Question

The next project I'll face would be much easier to implement with a state-aware server, such as Tomcat. I'd also like to be able to declare classes on an application scope (or some equivalent thing that makes them instantiated only once when Tomcat starts, if the framework discourages that practice).

Which Java frameworks are the most suitable for my problem and overall situation? My plan is to make a seed-project to make my projects homogeneous, however, it may be better to use generation tools, what's your experience about it?.I've time to play around with the framework before starting the project itself.

Right now, my colleagues who code Tomcat are currently using a mixture of the following:

  • Struts2
  • Mybatis for DB abstraction. It seems to be too big. It looks like I'll be using just 5% of it's power for my projects.
  • Tiles for visualization homogenization

I've no experience with struts, but it looks easy, so my first thought was to follow their schema to make the projects more homogeneous, which the side-advantage of having people I can ask questions sitting next to me, however, it looks like it produces too much boiler-plate, and that modifying certain things get tedious after the automatic generation process, but it may be just the lack of experience.

As I said, our endpoints are very simple, so I'd prefer a light-footprint framework. I know the best framework is the one you're most comfortable with, and that if my colleagues know a specific framework it is much better to just play along, but as I said, I've no experience with java frameworks, so I've to learn one anyway, so I wanted opinions based on experience.

SIDE question: As I said before, most my projects have a REST Api endpoint. PHP looks perfect for this, as is not type enforced, however, with arbitrary shape data structures, Java is not as easy as PHP. I remember from my Java times that I used Google's Gson library to handle JSON encoding/decoding, and it seems to still be trendy right now. It used to fulfill my needs in the past. Any thoughts on this?

side question 2: Imagine the following scenario: I've a Tika parser to extract plain text from documents. My first thought is to instantiate the Tika parser on application scope and then call it's methods when needed. In C I'd need to handle concurrency by myself, is Tomcat doing it properly? what are the best practices with tomcat? I'll be on an intense tomcat documentation reading this night, so I'll probably be able to answer myself on this one soon enough.

1 Answer 1

2

You have quite a lot of requirements and I have never heard of some frameworks you mentioned. (For example, I have never written a single line of PHP.) That said, I would recommend you the Spring (meta)framework.

Pivotal (the enterprise behind Spring) describe Spring like the following:

A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Furthermore there is Spring Boot, which gives you the ability to kick-start your project. A tutorial to create a simple REST-Server can be found here.

If you are looking for a simple, easy to learn framework Spring is not for you. But in my opinion it is more than a framework, because it provides a whole ecosystem of frameworks, which can be combined according to your needs.

There is for example Spring Data and Spring Data REST which automatically (more or less) create the REST API and the needed CRUD operations.

Unfortunately I have no experience with front-end development and Spring, but there is Spring MVC which supports you building front-ends.

Spring can also be packaged as a WAR and be deployed to a Tomcat server.

1
  • 1
    Thank you for your suggestions. Actually, I started experimenting with Struts2. I've Spring in my watchlist, however, it seems a bit heavy for me. I plan to learn about it, but I think I'll not really get into it until I find myself in a situation where Struts2 is too uncomfortable to implement: Our user interaction is really simple, so probably Struts will suffice for most my projects. It allows me to instantiate classes on application scope too, so I'm kinda happy with it ATM.
    – DGoiko
    Nov 8, 2018 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.