CDI Producer

CDI (Context and dependency injection) is a great specification introduced in the JEE6 that offers a lot of resources. One of them is the Producer methods, and we’ll be talking about it in this post.

CDI Producer can be used in some scenarios, such as:

  • Making Non-CDI beans eligible to be injected into other CDI beans. You may be using some library that doesn’t expose their beans via CDI but you want to inject them in your CDI beans by convenience.
  • You have a bean that requires a constructor with some argument.

Continue reading “CDI Producer”

Understanding transaction attributes

In this post we’ll be talking about a subject that is little explored by most of the developers: Transaction attributes. When we’re creating a service (EJB, Spring..), we can either control the transaction manually (BMT – Bean Managed Transaction) or delegate this responsibility to the container (CMT – Container Managed Transaction). CMT is used in most of the cases and with declarative configuration and it’s for this type of configuration that the transaction attributes exist. They define, for example, if your method must or must not be invoked from within a transactional scope.

Just to make things easier and clearer, the term client in this post means the caller, that can be a standalone application, an EJB, a Spring Service, etc.

Continue reading “Understanding transaction attributes”

Configuring a data source on JBoss 7

This post will describe the steps necessary to configure a JDBC DataSource in JBoss 7. MySQL database and JBoss 7.1.0-Final will be used as example.

Configuring MySQL JDBC driver module

The first big change on JBoss 7 compared to the previous versions is that the libraries to be deployed are no longer considered “libs”, in the sense that all the required work was to copy the .jar files to a specific folder and start using the services provided by that .jar. Any lib is now considered a JBoss module, like the server’s internal services, such as messaging. The following steps are required to configure the MySQL JDBC driver:
Continue reading “Configuring a data source on JBoss 7”