Developer Story: Angular 7 in a JEE Project

January 4, 2019 Leave a comment

As a freelancer, I’ve been working over the years with lots of different frameworks, but when I create my own applications, I usually use JEE (the real one, not Spring) plus JSF2 for the frontend and Maven as build system. My android apps then I attach to JAX-RS webservices. The outcome are very secure, stable and modern looking applications. Anyway – sometimes you feel you should try out something new which currently seems trendy, so I decided to change JSF for Angular on the frontend side. I’ll keep the rest as it has proven to be bullet proof.

So to sum up how our application should look like:

  • Maven as Build System
  • Netbeans or IntelliJ for development
  • JEE (with ejb, web and ear), deployed on WildFly
  • Angular 7 for the Frontend
  • JAX-RS webservices for serving now both Android and the Angular Frontend

The first thing I did was searching the web for a matching maven archetype to create the initial structure. Although there were a few ones, most of them only were for Spring – obviously a mismatch. OK, no problem, start with the “basic” one bundled with NetBeans 9 and we end up with a root pom plus ear, ejb and web projects and can also open it in IntelliJ. (I’ll use both IDEs to find out which one works better for this project). Next thing is to integrate Angular 7… which turns out to not be really developer friendly if you are used developing with server side applications.

First, you need to install node and Angular CLI. Having done so, you can create a new Angular web application with the Angular CLI below the web module’s src/main/angular directory and install all the additional node_modules you want to have. The whole stuff would then get “compiled” and the outcome can be copied over to the .WAR’s web application.

If you are wondering what happens during Angular’s “build” – process… in Angular 7 you typically write TypeScript files which need to get transpiled into JavaScript files. Further, you also have lots of configuration files, annotations and language features which also can not simply be used by a browser – so the “compilation” process of Angular also involves automated code creation, obfuscation, bundling into single huge JS files etc. In the end I find I switched my xhtmls and backing beans for a much more complex set of html, TypeScript, module files and a maven compilation process (which integrates the angluar CLI compilation process) taking more than twice as long and where I previously developed a few minutes for frontend stuff editing 2 files, I now have to work on more than 6 files in multiple languages and the backend webservice as well. I hope that’s worth it…

On my next post, I’ll review the maven build process (used also by jenkins CI) and directory structure before we start diving into the development.

Advertisement

J2ME, PushRegistry and reading SMS

July 13, 2010 Leave a comment

J2ME has a nice feature: PushRegistry. You can “register” an event which then starts up automatically your application.

This of course also works for receiving SMS on specific ports.  (SMSes sent to a non-standard port will not show up in the inbox).

If such an SMS comes in on – lets say port 4321 – your application starts up, you can then easily find out that your app was woken up by such an event and read the SMS via the java messaging API. (Create the MessageConnection using a Connector, then call the method receive to get it).

But there is an interesting issue:

if during your tests once your application crashes between starting up and the call to receive, the message will remain in the SMS queue. Now if a new message comes in, your application is triggered, but if you now call the receive method, you will get the first message in the queue and not the actual one.

Now this gets a little bit tricky, as you can not enumerate the message queue and the call to receive is blocking – so you can not just “read until the last message is read”, because you don’t know when the end of the queue is reached and if you call receive once more, your application is stuck until the next message arrives.

Gladly, there also exists the method to setup a messagelistener, which is called once for every message in that queue. But now you have the problem, that this is done asynchronously, so you can not wait until the last message is received by this listener and then continue with it.

The solution is: if your application is triggered, read the message, then install the listener to purge the rest of the queue. If there already was a message in the queue, you have read the wrong one, but at least all following calls will work.

Cool video found

July 2, 2010 Leave a comment

I just stumbled on an extremely hot video worth looking – turn on sound !

Working Environment

May 14, 2010 Leave a comment

Often I am asked, which is a good software development environment, so I’ll sum up my preferences including some links where things can be found.

If you develop in PHP or Java, I recommend Netbeans from http://www.netbeans.org . It is free, fast, has lots of plugins and everything you need. If you develop Software for Windows, consider buying Visual Studio from Microsoft.

If you work in a team, use Subversion (which is typically part of every Linux distribution – or download it from http://www.collab.net ). Netbeans comes bundled with a subversion client, so you won’t have to deal with this. But for Visual Studio, you need to install the Ankh plugin from http://ankhsvn.open.collab.net/downloads.

If you need Software for Bugtracking and project management, I recommend JIRA and the Greenhopper plugin from http://www.atlassian.com. You then need the Netbeans JIRA plugin or the Atlassian Connector for Visual Studio. I’d further recommend to install the JIRA client (windows software) to integrate it into your development suite.

For developing Java Software that consists of many packages, uses lots of libraries or work in a distributed team, don’t use an ant based project – make it maven based. Then, install your own repository manager on one server (I recommend artifactory) and install hudson for continous build integration. If you include a distributionManagement – part in your maven build file (pom.xml), you can make hudson publish the created artifacts automatically to your repository. There of course exist plugins for integration hudson into Netbeans (to watch and start the builds) and JIRA (which will then show the build status, possible errors and links issues).

Then you of course need documentation for the code. If you are writing Java software, write your javaDoc-code (netbeans will assist you) and if you need really pretty documentation and possible even UML diagrams – use the doxygen plugin and put it in your maven build file.

If you are using Visual Studio, use the XML documentation http://msdn.microsoft.com/en-us/library/b2s063f7.aspx and build it with http://sandcastle.codeplex.com/ – don’t forget to install the ghostdoc plugin which aids you in creating the required sourcecode documentation.

Upcoming new Google Webmaster Tool

March 7, 2010 Leave a comment

So, this is now something really interesting !

http://googlewebmastercentral.blogspot.com/2010/03/is-your-site-hacked-new-message-center.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/amDG+(Official+Google+Webmaster+Central+Blog)&utm_content=Google+Feedfetcher

The idea behind is pretty simple: as google’s bots crawl the web to find new content and update the existing one, they of course stumble upon abusing forum entries, hacked pages, etc. Why not send this found unwanted “content” to the page owning webmaster ?

Typically, companies outsource the programming and sometimes even maintenance of their pages to freelancers or other companies. And if the companies now do not subscribe maintenance contracts, they are typically alone with their created page or content from now on – and often there is nobody inside this company who really cares about the webpages.

By adding the above tool, it gets possible to get feedback if the site you once created or owned by you needs urgent maintenance. So this of course may also be a good tool to bind your customers. Of course this only works, if they are aware, that it is simple not possible to protect the site against all possible ways of misuse.

Thumbs up, Google !

Just an idea: what could be next ? Give Google an administrator account to your forums, so that it can not only detect malicious entries, but also automatically delete them ? And if that is done, maybe they could also automatically correct the spelling of normal entries, manage the registered users, etc…

Categories: Google, Web, Webmaster

Hello world!

March 5, 2010 1 comment

So here is my blog – the first entry is always the most boring one, so just skip it. 😉