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

Preface

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

Extraction

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

Index

Services in the HK2 Component Model

An HK2 service identifies the building blocks or the extension points of an application. A service is a plain-old Java object (POJO) with the following characteristics:

To clearly separate the contract interface and its implementation, the HK2 runtime requires the following information:

Interfaces that define a contract are identified by the org.jvnet.hk2.annotation.Contract annotation.

@Retention(RUNTIME)
@Target(TYPE)
public @interface Contract {   
}

Implementations of such contracts should be identified with an org.jvnet.hk2.annotations.Service annotation so that the HK2 runtime can recognize them as @Contract implementations.

@Retention(RUNTIME)
@Target(TYPE)
public @interface Service {
    ...
}

For more information, see Service.