Sun GlassFish Enterprise Server v3 Prelude Add-On Component Development Guide

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.