Skip Navigation Links | |
Exit Print View | |
Oracle GlassFish Server 3.1 Add-On Component Development Guide |
1. Introduction to the Development Environment for GlassFish Server Add-On Components
Services in the HK2 Component Model
Instantiation of Components in HK2
Instantiation Cascading in HK2
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
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.
@Service 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", scope=com.example.PerRequest.class, factory=com.example.MyCustomFactory) public class SamplePlugin implements ConsoleProvider { ... }