Search in sources :

Example 11 with PlainTextActionReporter

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

the class MonitoringReporter method runAggregate.

private void runAggregate() {
    List<String> list = getOutputLines();
    ActionReport aggregateReporter = null;
    if (aggregateDataOnly) {
        plainReporter = new PlainTextActionReporter();
        aggregateReporter = plainReporter.addSubActionsReport();
    } else
        aggregateReporter = reporter.addSubActionsReport();
    setClusterInfo(aggregateReporter, list);
    if (aggregateDataOnly) {
        reporter = plainReporter;
        context.setActionReport(plainReporter);
    }
}
Also used : ActionReport(org.glassfish.api.ActionReport) PlainTextActionReporter(com.sun.enterprise.admin.report.PlainTextActionReporter)

Example 12 with PlainTextActionReporter

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

the class EmbeddedAdminCtrImpl method execute.

public CommandExecution execute(String commandName, CommandParameters params) {
    ParameterMap props = params.getOptions();
    if (params.getOperands().size() > 0) {
        for (String op : params.getOperands()) props.add("DEFAULT", op);
    }
    final ActionReport report = new PlainTextActionReporter();
    CommandExecution ce = new CommandExecution() {

        public ActionReport getActionReport() {
            return report;
        }

        public ActionReport.ExitCode getExitCode() {
            return report.getActionExitCode();
        }

        public String getMessage() {
            return report.getMessage();
        }
    };
    runner.getCommandInvocation(commandName, report, kernelIdentity.getSubject()).parameters(props).execute();
    return ce;
}
Also used : CommandExecution(org.glassfish.internal.embedded.admin.CommandExecution) ParameterMap(org.glassfish.api.admin.ParameterMap) ActionReport(org.glassfish.api.ActionReport) PlainTextActionReporter(com.sun.enterprise.admin.report.PlainTextActionReporter)

Example 13 with PlainTextActionReporter

use of com.sun.enterprise.admin.report.PlainTextActionReporter 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.admin.report.PlainTextActionReporter) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Example 14 with PlainTextActionReporter

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

the class EmbeddedDeployerImpl method deploy.

@Override
public String deploy(ReadableArchive archive, DeployCommandParameters params) {
    // ensure server is started. start it if not started.
    try {
        server.start();
    } catch (LifecycleException e) {
        throw new RuntimeException(e);
    }
    ActionReport report = new PlainTextActionReporter();
    if (params == null) {
        params = new DeployCommandParameters();
    }
    ExtendedDeploymentContext initialContext = new DeploymentContextImpl(report, archive, params, env);
    ArchiveHandler archiveHandler = null;
    try {
        archiveHandler = deployment.getArchiveHandler(archive);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    if (archiveHandler == null) {
        throw new RuntimeException("Cannot find archive handler for source archive");
    }
    if (params.name == null) {
        params.name = archiveHandler.getDefaultApplicationName(archive, initialContext);
    }
    ExtendedDeploymentContext context = null;
    try {
        context = deployment.getBuilder(logger, params, report).source(archive).archiveHandler(archiveHandler).build(initialContext);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    if (params.property != null) {
        context.getAppProps().putAll(params.property);
    }
    if (params.properties != null) {
        context.getAppProps().putAll(params.properties);
    }
    ApplicationInfo appInfo = null;
    try {
        appInfo = deployment.deploy(context);
    } catch (Exception e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.deployException, e);
    }
    if (appInfo != null) {
        boolean isDirectory = new File(archive.getURI().getPath()).isDirectory();
        EmbeddedDeployedInfo info = new EmbeddedDeployedInfo(appInfo, context.getModulePropsMap(), context.getAppProps(), isDirectory);
        deployedApps.put(appInfo.getName(), info);
        return appInfo.getName();
    }
    return null;
}
Also used : IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) PropertyVetoException(java.beans.PropertyVetoException) IOException(java.io.IOException) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) PlainTextActionReporter(com.sun.enterprise.admin.report.PlainTextActionReporter) File(java.io.File)

Aggregations

PlainTextActionReporter (com.sun.enterprise.admin.report.PlainTextActionReporter)14 ActionReport (org.glassfish.api.ActionReport)11 Test (org.junit.Test)6 IOException (java.io.IOException)3 ParameterMap (org.glassfish.api.admin.ParameterMap)3 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 File (java.io.File)2 AdminCommandContext (org.glassfish.api.admin.AdminCommandContext)2 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 ActionReporter (com.sun.enterprise.admin.report.ActionReporter)1 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)1 Applications (com.sun.enterprise.config.serverbeans.Applications)1 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1 Application (com.sun.enterprise.deployment.Application)1 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)1 InserverCommandRunnerHelper (com.sun.enterprise.v3.admin.InserverCommandRunnerHelper)1 RestartDomainCommand (com.sun.enterprise.v3.admin.RestartDomainCommand)1 PropertyVetoException (java.beans.PropertyVetoException)1