Search in sources :

Example 6 with AdminCommandContext

use of org.glassfish.api.admin.AdminCommandContext in project Payara by payara.

the class SetNotificationConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    final AdminCommandContext theContext = context;
    final ActionReport actionReport = context.getActionReport();
    Properties extraProperties = actionReport.getExtraProperties();
    if (extraProperties == null) {
        extraProperties = new Properties();
        actionReport.setExtraProperties(extraProperties);
    }
    enableNotificationConfigureOnTarget(actionReport, theContext);
    enableNotificationNotifierConfigurerOnTarget(actionReport, theContext);
}
Also used : ActionReport(org.glassfish.api.ActionReport) Properties(java.util.Properties) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext)

Example 7 with AdminCommandContext

use of org.glassfish.api.admin.AdminCommandContext in project Payara by payara.

the class AdminCommandContextTest method testSerialization.

@Test
public void testSerialization() throws IOException, ClassNotFoundException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    ActionReport report = new PlainTextActionReporter();
    AdminCommandContext context = new AdminCommandContextImpl(null, /* logger */
    report);
    report.setFailureCause(new RuntimeException("Test"));
    oos.writeObject(context);
    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(is);
    AdminCommandContext restored = (AdminCommandContextImpl) ois.readObject();
    assertEquals("failureCause", "Test", restored.getActionReport().getFailureCause().getMessage());
// context.setPayload
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ActionReport(org.glassfish.api.ActionReport) PlainTextActionReporter(com.sun.enterprise.v3.common.PlainTextActionReporter) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 8 with AdminCommandContext

use of org.glassfish.api.admin.AdminCommandContext in project Payara by payara.

the class WrappedAdminCommandTest method getParamValueTest.

/*
     * Test getParamValue from wrapped command.
     */
@Test
public void getParamValueTest() {
    DummyAdminCommand dac = new DummyAdminCommand();
    dac.foo = "test";
    WrappedAdminCommand wrappedCommand = new WrappedAdminCommand(dac) {

        @Override
        public void execute(AdminCommandContext context) {
        // nothing todo
        }
    };
    assertEquals("set param value", "test", CommandSupport.getParamValue(wrappedCommand, "foo"));
    // note, after resolver it must be not null
    assertNull("unset param value must be null", CommandSupport.getParamValue(wrappedCommand, "foobar"));
    assertNull("non existent param value must be null", CommandSupport.getParamValue(wrappedCommand, "dummy"));
}
Also used : WrappedAdminCommand(org.glassfish.api.admin.WrappedAdminCommand) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext) Test(org.junit.Test)

Aggregations

AdminCommandContext (org.glassfish.api.admin.AdminCommandContext)8 ActionReport (org.glassfish.api.ActionReport)5 Properties (java.util.Properties)4 Config (com.sun.enterprise.config.serverbeans.Config)3 AdminCommand (org.glassfish.api.admin.AdminCommand)3 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)3 Test (org.junit.Test)3 HttpService (com.sun.enterprise.config.serverbeans.HttpService)2 SystemPropertyConstants (com.sun.enterprise.util.SystemPropertyConstants)2 PlainTextActionReporter (com.sun.enterprise.v3.common.PlainTextActionReporter)2 MessageFormat (java.text.MessageFormat)2 List (java.util.List)2 Optional (java.util.Optional)2 Logger (java.util.logging.Logger)2 Inject (javax.inject.Inject)2 I18n (org.glassfish.api.I18n)2 Param (org.glassfish.api.Param)2 CommandLock (org.glassfish.api.admin.CommandLock)2 ExecuteOn (org.glassfish.api.admin.ExecuteOn)2 RestEndpoint (org.glassfish.api.admin.RestEndpoint)2