Class CommandInvokedEvent

java.lang.Object
org.glassfish.internal.api.events.CommandInvokedEvent

public class CommandInvokedEvent extends Object

An HK2 event that is triggered when an Admin command is invoked via the REST interface (including Admin Console and CLI).

To listen to this event, create an HK2 subscriber with the following:

  • invalid reference
    Service
    annotation on the class or otherwise register the class as an HK2 service
  • MessageReceiver qualifier annotation on the class with the CommandInvokedEvent message type
  • A listener method with void return type and a single argument of the CommandInvokedEvent type annotated with the SubscribeTo annotation
  • Make sure that this subscriber is started as an HK2 service to receive the events

An example listener:

   

@Service
@RunLevel(value = StartupRunLevel.VAL, mode = RunLevel.RUNLEVEL_MODE_NON_VALIDATING)
@MessageReceiver({CommandInvokedEvent.class})
public class CommandSubscriber {

    public void commandInvoked(@SubscribeTo CommandInvokedEvent event) {
        log(event);
    }

 }
 
 
Author:
Ondro Mihalyi
  • Constructor Details

    • CommandInvokedEvent

      public CommandInvokedEvent(String commandName, org.glassfish.api.admin.ParameterMap parameters, Subject subject)
  • Method Details

    • getCommandName

      public String getCommandName()
      Returns:
      Name of the executed command
    • getParameters

      public org.glassfish.api.admin.ParameterMap getParameters()
      Returns:
      Parameters used with the command. If not parameters, the result is an empty map. Never null.
    • getSubject

      public Subject getSubject()
    • getUserPrincipal

      public Optional<org.glassfish.security.common.UserPrincipal> getUserPrincipal()