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

Using the Apache Maven Build System to Develop HK2 Components

If you are using Maven 2 to build HK2 components, invoke the auto-depends plug-in for Maven so that the META-INF/services files are generated automatically during build time.

Example 2-4 Example of the Maven Plug-In Configuration

<plugin>
    <groupId>com.sun.enterprise</groupId>
    <artifactId>hk2-maven-plugin</artifactId>
    <configuration>
        <includes>
            <include>com/sun/enterprise/v3/**</include>
        </includes>
    </configuration>
</plugin>

Example 2-5 Example of META-INF/services File Generation

This example shows how to use @Contract and @Service and the resulting META-INF/services files.

The interfaces and classes in this example are as follows:

package com.sun.v3.annotations;
@Contract
public interface Startup {...}

package com.wombat;
@Contract
public interface RandomContract {...}

package com.sun.v3;
@Service
public class MyService implements Startup, RandomContract, PropertyChangeListener {
    ...
}

These interfaces and classes generate this META-INF/services file with the MyService content:

com.sun.v3.annotations.Startup
com.wombat.RandomContract