Oracle GlassFish Server 3.0.1 Add-On Component Development Guide

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


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;
public interface Startup {...}

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

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

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