JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Add-On Component Development Guide
search filter icon
search icon

Document Information


1.   Introduction to the Development Environment for GlassFish Server Add-On Components

2.  Writing HK2 Components

HK2 Component Model

Services in the HK2 Component Model

HK2 Runtime

Scopes of Services

Instantiation of Components in HK2

HK2 Lifecycle Interfaces

Inversion of Control

Injecting HK2 Components


Instantiation Cascading in HK2

Identifying a Class as an Add-On Component

Using the Apache Maven Build System to Develop HK2 Components

3.  Extending the Administration Console

4.  Extending the asadmin Utility

5.  Adding Monitoring Capabilities

6.  Adding Configuration Data for a Component

7.  Adding Container Capabilities

8.  Creating a Session Persistence Module

9.  Packaging, Integrating, and Delivering an Add-On Component

A.  Integration Point Reference


Identifying a Class as an Add-On Component

GlassFish Server discovers add-on components by identifying Java programming language classes that are annotated with the org.jvnet.hk2.annotation.Service annotation.

To identify a class as an implementation of an GlassFish Server service, add the org.jvnet.hk2.annotation.Service annotation at the class-definition level of your Java programming language class.

public class SamplePlugin implements ConsoleProvider {

The @Service annotation has the following elements. All elements are optional.


The name of the service. The default value is an empty string.


The scope to which this service implementation is tied. The default value is org.jvnet.hk2.component.PerLookup.class.


The factory class for the service implementation, if the service is created by a factory class rather than by calling the default constructor. If this element is specified, the factory component is activated, and Factory.getObject is used instead of the default constructor. The default value of the factory element is org.jvnet.hk2.component.Factory.class.

Example 2-3 Example of the Optional Elements of the @Service Annotation

The following example shows how to use the optional elements of the @Service annotation:

@Service (name="MyService", 
public class SamplePlugin implements ConsoleProvider {