Maven Project Design Guidelines

There are some items to keep in mind when creating a maven build script for your application:

  • A maven script should not change source code at build time. If you are using maven filters, then this is probably the case!
  • Once checked out, a maven application should build without errors, first try. It should not require specific set ups.
  • A maven project should not contain generated code. Code must be generated in a separate maven project, published to Nexus (artifact store) and then imported into your project as a dependency. For example, say you have a module that generates a service contract from a wsdl file. This generated code is not checked into version control (should not!). On a different machine, the maven build will fail initially due to compile errors. One would have to run the code generator, and then run the maven build for the build to pass. This violates point number 2.
  • Never mix business logic and configuration in the same artifact. Environment specific configuration should go into a config module.
  • EJB libraries must not be bundled into the applications whose services they expose. This is due to versioning. A change in the application that does not affect the API’s external interface, should not result in a version bump of the EJB library. In other words, the library version should only change when the API changes. Clients using the EJB library do not care about application-internal changes, which is why it is such bad practise to bundle the library with the application. (Though it does make sense on first thought).

Thanks to Tor for sharing his knowledge and giving me these pointers! Will come in handy.

EJBs

Funky Shit Explained in Simple Terms — Today: EJB Libraries

EJBs provide a Java specific way for two Java applications to talk to one another. From your application’s perspective it does not matter whether they are running on the same machine or on different hosts.

If Java server A has to interact with server B, it can inject server B’s EJB library and use it as if it were a local object on server A. This mechanism is not a protocol like HTTP because it is not universal. EJBs are specific to the server on which they are running. JBoss EJBs are not compatible with Weblogic EJBs for example.

Continue reading EJBs

Defining and executing quick commmands

When creating Docker files, writing blog posts, or working on my home automation server there are a number of repetitve tasks that you find yourself executing. Let’s define them in a script to speed up invocation and allow them to be version controlled!

Pagination