JBoss Enterprise Web Platform 5

JBoss Microcontainer User Guide

for use with JBoss Enterprise Web Platform 5

Edition 5.1.1

Mark Newton

Red Hat

Aleš Justin

Red Hat

Edited by

Misty Stanley-Jones

Red Hat

Legal Notice

Copyright © 2011 Red Hat, Inc. and others.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.

Abstract

This guide is intended for Java developers who wish to use the JBoss Microcontainer to deploy customized, modular Java environments for their applications.
Preface
1. Document Conventions
1.1. Typographic Conventions
1.2. Pull-quote Conventions
1.3. Notes and Warnings
2. Getting Help and Giving Feedback
2.1. Do You Need Help?
2.2. Give us Feedback
I. Introduction to The Microcontainer - Guided Tutorial
1. Prerequisites to Using This Guide
1.1. Install Maven
1.2. Special Maven Settings for the Microcontainer Examples
1.3. Downloading the Examples
2. Introduction to the Microcontainer
2.1. Features
2.2. Definitions
2.3. Installation
3. Building Services
3.1. Introduction to the Human Resources Example
3.2. Compiling the HRManager Example Project
3.3. Creating POJOs
3.3.1. XML Deployment Descriptors
3.4. Connecting POJOs Together
3.4.1. Special Considerations
3.5. Working with Services
3.5.1. Configuring A Service
3.5.2. Testing A Service
3.5.3. Packaging A Service
4. Using Services
4.1. Bootstrapping the Microcontainer
4.2. Deploying the Service
4.3. Direct Access
4.4. Indirect Access
4.5. Dynamic Classloading
4.5.1. Problems With Classloaders Created with Deployment Descriptors
5. Adding Behavior with AOP
5.1. Creating An Aspect
5.2. Configuring the Microcontainer for AOP
5.3. Applying An Aspect
5.4. Lifecycle Callbacks
5.5. Adding Service Look-ups Through JNDI
II. Advanced Concepts with the Microcontainer
6. Component Models
6.1. Allowable Interactions with Component Models
6.2. A Bean With No Dependencies
6.3. Using the Microcontainer with Spring
6.4. Using Guice With the Microcontainer
6.5. Legacy MBeans, and Mixing Different Component Models
6.6. Exposing POJOs as MBeans
7. Advanced Dependency Injection and IoC
7.1. Value Factory
7.2. Callbacks
7.3. Bean Access Mode
7.4. Bean Alias
7.5. XML (or MetaData) Annotations Support
7.6. Autowire
7.7. Bean Factory
7.8. Bean Metadata Builder
7.9. Custom ClassLoader
7.10. Controller Mode
7.11. Cycle
7.12. Demand and Supply
7.13. Installs
7.14. Lazy Mock
7.15. Lifecycle
8. The Virtual File System
8.1. VFS Public API
8.2. VFS Architecture
8.3. Existing Implementations
8.4. Extension Hooks
8.5. Features
9. The ClassLoading Layer
9.1. ClassLoader
9.2. ClassLoading
9.3. ClassLoading VFS
10. The Virtual Deployment Framework
10.1. Agnostic Handling of Deployment Types
10.2. Separation of Structure Recognition From Deployment lifecycle logic
10.3. Natural Flow Control in the form of Attachments
10.4. Client, User, and Server Usage and Implementation Details
10.5. Single State Machine
10.6. Scanning Classes for Annotations
A. Revision History