Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

I am very happy to be attending Devoxx Poland 2016; I enjoyed Devoxx Poland last year very much. As well as Krakow.

This year I am looking forward to talks on: Java 9 Flow API; Angular 2; Microservices; lambdas; and many other topics. But, worryingly there does not seem to be a single talk with "Java EE" in the title. Like last year Devoxx Poland has attracted many great speakers.

Also, the food last year was delicious, so I hoping for the same this year.

Here is Devoxx 2015 video



Read

This is a note on a simple regular expression to GREP for exceptions in a group of log files.

I have been debugging an issue unsure of what to look for. Of course 'Exception' on its own is not a great search term. Using a negative look-behind made the difference in trying to narrow down on what to look for. The look-behind made it possible to rule out the name of some of the exceptions that are not important to the issue at hand.

(?<!Faces|FileNotFound|Configuration)Exception


Read

I have been experimenting with the Twitter Bower package manager as part of the tech stack to be used with a Java EE JSF project.

This post is a note on how I set up the Web Application project to use the Bower package manager.

I began by setting up a new Mavan Web Application. I used the NetBeans 'New Project' wizard. Once the new Web Application project was created I added JavaServer Faces to the project via NetBeans' Properties > Framework menu.

Next I added a .bowerrc file to the root of the webapp as:

{
  "directory": "resources/components"
}

This .bowerrc file changes the default location that Bower will store the components it downloads. This change made Bower fit with a Mavan Web Application folder structure. Next I added a bower.json file to the root of the webapp.

{
  "name": "bower-setup-test",
  "authors": [
    "Geoffrey Hayward"
  ],
  "private": true
}

The bower.json file keeps a record of each dependency and its version that is added to the project. See the bower.json spec for details.

Then from the root of the webapp I ran the command: bower install bootstrap --save. The --save saved the dependency to bower.json file.

Why Bower? Good question. To reduce the size of the tracked GIT repository and to make the web component libraries explicit. Each time a file is forked from the dependency, such as a bootstrap LESS variables file, you add it to the bower.json ignore property. Likewise you then begin tracking the forked file in GIT. Everything that is managed by Bower (that is not forked) is in (or should be in) the .gitignore file.

My Thoughts: Post Experiment

My thoughts to using Bower with a Java EE JSF project are Bower adds complexity to a Java EE JSF project that may not bring any value. But, with that said Bower certainly would come in handy for a front-end framework heavy project; particularly when some control over what should and should not be edited is needed. In other words I am undecided for now, but have no plans to start using Bower just yet in this context.



Read

It is easy to generate a SOAP client from a WSDL with Java. Java comes with the tool named 'wsimport'. The wsimport tool is part of the Java JDK, found in the JDK bin folder. By default when you run the tool it will create and keep the compiled .class files. If you do not need the .class files just add -Xnocompile to the command.

wsimport http://localhost:8080/demo?wsdl -Xnocompile


Read

I have been trying to get the JavaFX MediaPlayer to play MP3s. Each of the MP3s, that I have been trying to play, are being retrieved over HTTPS. The java javafx.scene.media.Media class does not support the HTTPS protocol.

To workaround this problem meant temporarily storing the MP3 on the local disk. And then playing the MP3 from the temporary disk location.

URL url = new URL("https://resource.track.mp3");
        
Path mp3 = Files.createTempFile("now-playing", ".mp3");
        
try (InputStream stream = url.openStream()) {
        Files.copy(stream, mp3, StandardCopyOption.REPLACE_EXISTING);
}

Media media = new Media(mp3.toFile().toURI().toString());
MediaPlayer mediaPlayer = new MediaPlayer(media);
mediaPlayer.play();

Do you know of a better solution or workaround that will skip the need to write to disk when the media file is retrieved over HTTPS? Leave a comment if you do.



Read

Mailing List

Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.

ResponsiveMedia