samaxes

samaxes logo

Ramblings about Open Source, Java and other Web technologies by Samuel Santos

Unit Testing JBoss 5 Services

The JBoss Microcontainer is a refactoring of JBoss’s JMX Microkernel to support direct POJO deployment and standalone use outside the JBoss application server.
It allows the creation of services using simple Plain Old Java Objects (POJOs) to be deployed into a standard Java SE runtime environment.

JBoss Microcontainer uses dependency injection to wire individual POJOs together to create services. Configuration is performed using either annotations or XML depending on where the information is best located.

The goal of this article is to show how easy it is to test these services using TestNG testing framework.
Read the rest of this entry »

JBoss PojoCache configuration

Everyone knows that documentation is not one of JBoss strengths.
This article is meant to fill this gap. It describes and exemplifies how to configure JBoss PojoCache as a MBean service, using loadtime transformations with JBossAop framework, so you don’t need precompiled instrumentation.

Introduction

This section gives you an introduction about PojoCache and its advantages over TreeCache (a plain cache system).

PojoCache is an in-memomy, transactional, and replicated POJO (plain old Java object) cache system that allows users to operate on a POJO transparently without active user management of either replication or persistency aspects. PojoCache, a component of JBossCache (uses PojoCache class as an internal implementation, the old implementation TreeCacheAop has been deprecated.), is the first in the market to provide a POJO cache functionality. JBossCache by itself is a 100% Java based library that can be run either as a standalone program or inside an application server.

TreeCache limitations:

  • Users will have to manage the cache specifically; e.g., when an object is updated, a user will need a corresponding API call to update the cache content.
  • If the object size is huge, even a single field update would trigger the whole object serialization. Thus, it can be unnecessarily expensive.
  • The object structure can not have a graph relationship. That is, the object can not have sub-objects that are shared (multiple referenced) or referenced to itself (cyclic). Otherwise, the relationship will be broken upon serialization.

PojoCache advantages:

  • No need to implement Serializable interface for the POJOs.
  • Replication (or even persistency) is done on a per-field basis (as opposed to the whole object binary level).
  • The object relationship and identity are preserved automatically in a distributed, replicated environment. It enables transparent usage behavior and increases software performance.

Read the rest of this entry »

JBoss AS 5.0 is out!

JBoss announced the GA release of JBoss AS 5.0.

JBoss 5 is the next generation of the JBoss Application Server build on top of the new JBoss Microcontainer. The JBoss Microcontainer is a lightweight container for managing POJOs, their deployment, configuration and lifecycle. It is a standalone project that replaces the famous JBoss JMX Microkernel of the 3.x and 4.x JBoss series. The Microcontainer integrates nicely with the JBoss framework for Aspect Oriented Programming, JBoss AOP. Support for JMX in JBoss 5 remains strong and MBean services written against the old Microkernel are expected to work.

JBoss5 is designed around the advanced concept of a Virtual Deployment Framework (VDF), that takes the aspect oriented design of many of the earlier JBoss containers and applies it to the deployment layer. Aspectized Deployers operate in a chain over a Virtual File System (VFS), analyze deployments and produce metadata to be used by the JBoss Microcontainer, which in turn instantiates and wires together the various pieces of a deployment, controlling their lifecycle and dependencies.

See the full release notes and downloads page.

And good luck to get your J2EE applications working with this new version.

JBoss Web and PHP Install Tutorial

Approximately 2 years ago I’ve written a set of tutorials that served as a guideline for a Beginner’s PHP Training Course. These tutorials were made with the WAMP solution stack in mind.

Since I’ve been working with Java EE Technologies and Servers recently, I’ve decided do add another one explaining how to install JBoss Web 1.0.1 GA with PHP support (PHP Handler Servlet).

This was based on a tutorial by Philippe Fievet that is now offline for some reason.

JBoss - Stacking Login Modules

Sometimes no single login module is enough to meet our needs. Imagine the case of using an external LDAP server to provide the user authentication and a database server to provide the user authorization. A user would be in one repository or the other, and login should succeed if the user is found in either repository.

JBoss allows you to specify multiple login modules for a single security domain. But simple module stacking doesn’t resolve the problem on its own. For that, you need to use password stacking.

Password stacking allows modules to skip the actual authentication and to provide supplemental roles. The modules require the password-stacking option to useFirstPass for this to work.

<application-policy name="myRealm">
  <authentication>
    <login-module code="org.jboss.security.auth.spi.LdapLoginModule" flag="optional">
      <module-option name="password-stacking">useFirstPass</module-option>
      <module-option name="java.naming.factory.initial">com.sun.jndi.ldap.LdapCtxFactory</module-option>
      <module-option name="java.naming.provider.url">ldap://LDAP_SERVER:LDAP_PORT/</module-option>
      <module-option name="java.naming.security.authentication">simple</module-option>
      <module-option name="principalDNPrefix">MY_DOMAIN\</module-option>
    </login-module>
    <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
      <module-option name="password-stacking">useFirstPass</module-option>
      <module-option name="dsJndiName">java:myDS</module-option>
      <module-option name="principalsQuery">SELECT passwd FROM user WHERE login = ?</module-option>
      <module-option name="rolesQuery">SELECT role, 'Roles' FROM user_roles r, user u WHERE u.userid = r.userid AND u.login = ?</module-option>
    </login-module>
  </authentication>
</application-policy>

The option principals query is optional; it’s a fallback in the case the authentication fails in the LDAP server. Notice that the LDAP configuration omits the roles query option set so the authorization is only provided by the database server module.

JBoss Seam 1.0 released

JBoss Seam 1.0, an application framework for Java EE 5 based on Asynchronous JavaScript and XML(AJAX), Java Serve Faces(JSF), Enterprise Java Beans(EJB3), and other technologies, has been released.

Read more in JBoss SEAM 1.0: rethinking web application architecture at InfoQ.

The Seam project is proud to announce the release of JBoss Seam 1.0 GA, an application framework for Java EE 5. Seam aims to be the most productive platform for development of enterprise and rich internet applications in any programming language.

Seam integrates Java EE 5 technologies like EJB 3.0, JSF and JMS into a unified programming model and then narrows the semantic gap between the business domain and the Java programming language by deeply integrating technologies like jBPM for business process and user interaction modelling and Drools for management of business rules. Seam Remoting provides an AJAX-based remoting layer for EJB 3.0, allowing client-side JavaScript to call EJB session beans directly. Seam’s unique contextual state management architecture makes it easy to build applications with complex, stateful user interactions and helps eliminate a whole class of bugs endemic to browser-based applications. Seam also eliminates the “XML hell” that plagues Java frameworks designed for use with J2EE by leveraging Java 5 annotations for declarative programming.

Seam 1.0 introduces the following new features:

  • Seam Remoting - an AJAX-based remoting layer for EJB 3.0 components and JMS (created by Shane Bryzak)
  • Support for JSR-168 compliant portal engines such as JBoss Portal
  • Elegant handling of internationalization and JSF messages via EL-based interpolation
  • Helper components for JMS senders/publishers
  • JSF tag library
  • Redesigned XML-based configuration facility
  • Support for integrating databinding architectures
  • Eventing architecture for loosely-coupled components
  • Seam Logging
  • JBoss Cache integration for cluster-wide state replication
  • Experimental Drools integration
  • Compatibility with the Java EE 5 reference implementation
  • Much more…

As usual, the best way to learn about Seam is to check out the example applications. Start with the registration, numberguess, booking, blog, dvdstore and chatroom examples.

From In Relation To…

Web Beans approved by the EC Unanimously

The Web Beans specification JSR-299 was approved unanimously by the JCP executive committee.

This is the first time JBoss (or even Red Hat) has led a JSR, so this is great news to the Java EE community!

Oh, and remember we love you (and so does Red Hat) ;)

Sponsors