December 22, 2014

SyntaxHighlighter

Supported styling.

https://github.com/rwz/SyntaxHighlighter/blob/master/demos/autoloader.html

Java EE 7 Maven Dependency

In my previous blog about Java EE 6 Maven Dependency a wrote about the crippled javaee-api maven dependency in maven central.

That is finally fixed in EE 7.

See also Essential Maven POM For JavaEE 7

December 21, 2014

Java EE 6 Maven Dependency

The EE 6 classes are available in maven central.

But when running unit test against them you receive the below error. Thats because they do not contain implementation classes, only api class.

So in practice, the dependecy is in real life unusable. Instead you must use api classes from specific vendors like JBoss.

Java EE 7 Deployment Descriptors

Deployment descriptors are like configuration files.

The below sites summaries all xml schemas defintions for all EE 7 deployment descriptors.

http://antoniogoncalves.org/2013/06/04/java-ee-7-deployment-descriptors/

Java EE 6 Interceptors 1.0 (JSR318)

Introduction

Interceptor was in EE 5 introduced in EJB 3.0, see EJB3 Interceptors javax.ejb.AroundInvoke. In EE 6 that was taken out and made generic into Interceptors (JSR318), package javax.interceptor.*.

You can call Interceptor in EE 6 in two way:

  • By annotating method or class with @javax.interceptor.Interceptors(MyInterceptor.class)
  • Create custom Annotation with Annotation @javax.interceptor.InterceptorBinding and annotate with that you method or class.

Example

Your custom Interceptor.

Interception in a POJO.

Interception in a Stateless Session Bean.

beans.xml located for war in WEB-INF/.

To use the Interceptor you must let weld create the intercepted class, otherwise will weld never knew about the interceptor and hence will the interceptor never work.

Example usage from a Servlet.

Limitation

You cannot use Interceptor directly in servlets, see https://java.net/projects/servlet-spec/lists/jsr340-experts/archive/2012-02/message/0.

Taking Snapshot in Ubuntu

When taking snapshot in Ubuntu you could always use the predefined keyboard shortcuts, see https://help.ubuntu.com/community/KeyboardShortcuts#Desktop_shortcuts

A better tool is to use the gnome-screenshot tool.

You can install via `sudo apt-get install gnome-screenshot`


How to Manage Properties Files in JBoss Module

From JBoss AS 7 and EAP 6 forth, classloading have changed and all jar dependencies are packaged and loaded as jboss modules.

Besides dependency jar in a module you also might need to be able to configure it for different server environment. The best way and maybe the natural way, is to make use of a java properties file.

This is a good practice, now you can RPM package your custom module. This is how Red Hat do with JBoss EAP 6. With RPM packing you have now the capability of versioning your module and to centrally install it from, e.g. Red Hat Satellite. And finally centrally configure the property file from, e.g. Satellite 6 via Puppet.

But there is classloading gotchas. You need to add <resource-root path="."/> to you module.xml.

See https://developer.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath for longer description.