Search in sources :

Example 21 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class ListJavaMailResourcesTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    parameters = new ParameterMap();
    cr = habitat.getService(CommandRunner.class);
    assertTrue(cr != null);
    Resources resources = habitat.<Domain>getService(Domain.class).getResources();
    context = new AdminCommandContextImpl(LogDomains.getLogger(ListJavaMailResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
    for (Resource resource : resources.getResources()) {
        if (resource instanceof MailResource) {
            origNum = origNum + 1;
        }
    }
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) MailResource(org.glassfish.resources.javamail.config.MailResource) Resource(com.sun.enterprise.config.serverbeans.Resource) ParameterMap(org.glassfish.api.admin.ParameterMap) Resources(com.sun.enterprise.config.serverbeans.Resources) Domain(com.sun.enterprise.config.serverbeans.Domain) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) MailResource(org.glassfish.resources.javamail.config.MailResource) Before(org.junit.Before)

Example 22 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class DeleteJavaMailResourceTest method setUp.

@Before
public void setUp() {
    habitat = getHabitat();
    parameters = new ParameterMap();
    cr = habitat.getService(CommandRunner.class);
    resources = habitat.<Domain>getService(Domain.class).getResources();
    context = new AdminCommandContextImpl(LogDomains.getLogger(DeleteJavaMailResourceTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter());
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) Before(org.junit.Before)

Example 23 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class JerseyContainerCommandService method postConstruct.

@Override
public void postConstruct() {
    if (Boolean.valueOf(System.getenv("AS_INIT_REST_EAGER"))) {
        ExecutorService executor = Executors.newFixedThreadPool(2);
        this.future = executor.submit(new Callable<JerseyContainer>() {

            @Override
            public JerseyContainer call() throws Exception {
                return exposeContext();
            }
        });
        executor.execute(new Runnable() {

            @Override
            public void run() {
                final CommandRunner.CommandInvocation invocation = habitat.getService(CommandRunner.class).getCommandInvocation("uptime", new PropsFileActionReporter(), kernelIdentity.getSubject());
                invocation.parameters(new ParameterMap());
                invocation.execute();
            }
        });
        executor.shutdown();
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ParameterMap(org.glassfish.api.admin.ParameterMap) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter) Callable(java.util.concurrent.Callable)

Example 24 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class DumpHK2Command method execute.

public void execute(AdminCommandContext context) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    modulesRegistry.dumpState(new PrintStream(baos));
    ActionReport report = context.getActionReport();
    report.setActionExitCode(ExitCode.SUCCESS);
    String msg = baos.toString();
    // cause problems.  Manifest.write() is OK but Manifest.read() explodes!
    if (report instanceof PropsFileActionReporter) {
        msg = ManifestUtils.encode(msg);
    }
    report.setMessage(msg);
}
Also used : PrintStream(java.io.PrintStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ActionReport(org.glassfish.api.ActionReport) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter)

Example 25 with PropsFileActionReporter

use of com.sun.enterprise.admin.report.PropsFileActionReporter in project Payara by payara.

the class GetHabitatInfo method execute.

@Override
public void execute(AdminCommandContext context) {
    StringBuilder sb = new StringBuilder();
    if (contract == null) {
        dumpContracts(sb);
        dumpModules(sb);
        dumpTypes(sb);
    } else {
        dumpInhabitantsImplementingContractPattern(contract, sb);
    }
    String msg = sb.toString();
    ActionReport report = context.getActionReport();
    report.setActionExitCode(ExitCode.SUCCESS);
    if (report instanceof PropsFileActionReporter) {
        msg = ManifestUtils.encode(msg);
    }
    report.setMessage(msg);
}
Also used : ActionReport(org.glassfish.api.ActionReport) PropsFileActionReporter(com.sun.enterprise.admin.report.PropsFileActionReporter)

Aggregations

PropsFileActionReporter (com.sun.enterprise.admin.report.PropsFileActionReporter)30 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)23 ParameterMap (org.glassfish.api.admin.ParameterMap)19 Before (org.junit.Before)14 CommandRunner (org.glassfish.api.admin.CommandRunner)13 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)9 Test (org.junit.Test)9 MessagePart (org.glassfish.api.ActionReport.MessagePart)7 ActionReport (org.glassfish.api.ActionReport)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 Resource (com.sun.enterprise.config.serverbeans.Resource)4 Resources (com.sun.enterprise.config.serverbeans.Resources)3 IiopService (org.glassfish.orb.admin.config.IiopService)3 RestPayloadImpl (com.sun.enterprise.admin.remote.RestPayloadImpl)2 CachedCommandModel (com.sun.enterprise.admin.util.CachedCommandModel)2 ArrayList (java.util.ArrayList)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2 Ignore (org.junit.Ignore)2 ParamsWithPayload (com.sun.enterprise.admin.remote.ParamsWithPayload)1 ActionReporter (com.sun.enterprise.admin.report.ActionReporter)1