JPA annotation processing

Previously I had defined how I would design domain objects with JPA. One of the things I had noted was the notion of a table model that encapsulates persistence operations. The table model is pretty much common and although some things can be done by generics, some things such as named queries cannot and require the use of strings. However, a pattern can be followed for the names combines with Java annotation processor be used to create code that would reduce the use of strings for users of the class.

This post discusses how I would build an annotation processor that takes advantage of JPA entity definitions to create support classes that avoid strings in user code.
Continue reading

Share Button

Using JET to create code in Maven

Java Emitter Templates (JET) is a templating system that takes JET template files and converts them into Java source code.  Unlike other templating systems like Velocity, the code it generates does not require additional libraries making its generated code usable without additional libraries when creating annotation processors.

This is a simple introduction to using JET with Maven using the tikal-maven-jet-plugin in Eclipse M2E.
Continue reading

Share Button

Gaming allowance using Khan Academy

Eventually PM-1 will need to learn the value of a dollar. The normal way of doing it is by providing an allowance for the kid, but rather than do chores which I myself find menial to do, I would rather they continue focusing on learning. One of my friends from work, UV, introduced me to a smart use of one of the more popular learning sites I have encountered, Khan Academy, and how he uses it with his children’s allowance.
Continue reading

Share Button

Creating an annotation based code generator in Maven

One of the nicer features added in Java 5 was the support of creating custom annotation processors.  The use of custom annotation processing allows framework developers to set up a model that would generate additional code as part of the build.

This blog post discusses how to create and test an annotation processor in Maven. Continue reading

Share Button

Learning AngularJS

There’s many tutorials that show how to use AngularJS online, the AngularJS home page does a very good start. @blm849, one of the smarter people I know asked me if there was any site to ramp him up. I said the AngularJS home page followed by learning directives.

In this post I will expand on my suggestion and follow on with other things to look at.
Continue reading

Share Button

AngularJS Template Servlet

When working with AngularJS, templates allow developers to separate their HTML from the JavaScript code.  Though this is preferable for development, this can be an issue at runtime as each template will incur a network cost.  To alleviate this issue AngularJS provides a $templateCache that reduces the cost of doing network handshakes by combining multiple template files into a single JavaScript file that populates a cache.

That’s all well and good, but building the file can get cumbersome and having it as part of the build process would slow developers down.  It would be nice if it can be done at runtime like WRO4J does for CSS and JavaScript; so I create a servlet that does it for me.

Continue reading

Share Button

Being a good enterprise architecture citizen

One of the side projects I am working on is to develop yet another enterprise application framework.  The purpose of this was to learn and try out some of the current features of Java EE and try to put a fresh eye from what I have seen from other frameworks. Specifically, I wanted to look at developing my framework to be a good enterprise architecture citizen.

Continue reading

Share Button

WebSocket Service API Contact

The WebSocket API like HTTP is very open and allows a lot of flexibility to be able to work with many different types of applications. Like REST on top of HTTP, a WebSocket Service is an architectural style and has no defined standards making the need for a contract between UI developers and server side developers in order to keep things sane. This blog post defines a WebSocket Service API Contract that I use for my projects akin to the REST API Contract I use in my projects.
Continue reading

Share Button

REST API Contract

Developing RESTful services is more of an architectural style than a standard. This makes it flexible, yet difficult to implement as there is no proper contract like that of WS-*. In fact, the closest thing to a standard is the Hypertext Transfer Protocol which does not define how paths are to be defined and such.

RESTful services act as a gateway between the UI team using HTML, JavaScript and CSS and the backend teams using some form of application server. In order to keep things sane, it is best that these two groups form a contract before they go too far into development. So here are some guidelines on the contract for my UI and server development using REST.
Continue reading

Share Button

Cookies that can expire but must be removed when the browser is closed

In my JASPIC OAuth 2.0 implementation, a cookie is used to store the JWT payload.  In the JWT, there’s an “exp” value that specifies when the token should expire.  It would be nice if we can have the data expire when the “exp” value is hit or if the browser is closed, but unfortunately HTTP Cookies does not support that feature.

Continue reading

Share Button