Each asadmin command that you are adding must be represented as a Java class. To represent an asadmin command as a Java class, write a Java class that implements the org.glassfish.api.admin.AdminCommand interface. Write one class for each command that you are adding. Do not represent multiple asadmin commands in a single class.
Annotate the declaration of your implementations of the AdminCommand interface with the org.jvnet.hk2.annotations.Service annotation. The @Service annotation ensures that the following requirements for your implementations are met:
The implementations are eligible for resource injection and resource extraction.
The implementations are location independent, provided that the component that contains them is made known to the Enterprise Server runtime.
For information about how to make a component known to the Enterprise Server runtime, see Integrating an Add-On Component With Enterprise Server.