Examples of ColumnFormatter


Examples of com.sun.enterprise.util.ColumnFormatter

        map.put(MAX_QUEUE_SIZE, helper.getMaxQueueSize());
        map.put(DATA_SOURCE_NAME, helper.getDataSourceJndiName());
        map.put(MAX_DATA_RETENTION_TIME_IN_SECONDS, helper.getMaxRetentionTime());
        extraProps.put("list-batch-runtime-configuration", map);

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        Object[] data = new Object[getOutputHeaders().length];
        for (int index=0; index<getOutputHeaders().length; index++) {
            switch (getOutputHeaders()[index]) {
                case MAX_THREAD_POOL_SIZE:
                    data[index] = helper.getMaxThreadPoolSize();
                    break;
                case MIN_THREAD_POOL_SIZE:
                    data[index] = helper.getMinThreadPoolSize();
                    break;
                case MAX_IDLE_THREAD_TIMEOUT_IN_SECONDS:
                    data[index] = helper.getMaxIdleThreadTimeout();
                    break;
                case MAX_QUEUE_SIZE:
                    data[index] = helper.getMaxQueueSize();
                    break;
                case DATA_SOURCE_NAME:
                    data[index] = helper.getDataSourceJndiName();
                    break;
                case MAX_DATA_RETENTION_TIME_IN_SECONDS:
                    data[index] = helper.getMaxRetentionTime();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
        }
        columnFormatter.addRow(data);
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

     */
    public String list() throws BackupException {
        StringBuffer sb = new StringBuffer();
        String headings[] = { BACKUP, USER, DATE, FILENAME };
        List<Integer> badPropsList = null;
        ColumnFormatter cf = null;
        boolean itemInRow = false;
        TreeSet<Status>statusSet = new TreeSet<Status>(new FileNameComparator());
       
        // If a backup config was not provided then look for all zips
        // including those in the backup config directories.
        // If a backup config was provided then only look for zips in
        // that backup config directory.
        findZips(request.backupConfig == null);

        badPropsList = new ArrayList<Integer>();

        // it is GUARANTEED that the length > 0
        for(int i = 0; i < zips.length; i++) {
            Status status = new Status();

            if (!status.loadProps(zips[i]))
                badPropsList.add(Integer.valueOf(i));
            else {
                //XXX: if (request.terse)  How indicate no headers?

                statusSet.add(status);
                itemInRow = true;
            }
        }

        if (itemInRow) {
            for (Status status : statusSet) {
                if (request.verbose) {
                    File f = null;

                    try {
                        f = new File(status.getBackupPath());
                    } catch (NullPointerException e) {
                    }

                    if (f != null) {
                        sb.append(status.read(f, request.terse));
                        sb.append("\n\n");
                    }
                } else {
                    String filename = status.getFileName();

                    if (cf == null) {
                        cf = new ColumnFormatter(headings);
                    }

                    if (filename == null)
                        filename = strings.get("backup-list.unavailable");

                    cf.addRow(new Object[] {
                              status.getBackupConfigName(),
                              status.getUserName(),
                              status.getTimeStamp(),
                              filename
                         });
                }
            }
        }


        if (cf != null)
            sb.append(cf.toString());

        // If no items in the row and we are not in terse mode indicate
        // there was nothing to list.
        if (!itemInRow && !request.terse)
            sb.append("\n" + strings.get("backup-list.nothing"));
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

    String executionId;

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps) {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        if (isSimpleMode()) {
            extraProps.put("simple-mode", true);
            extraProps.put("list-batch-jobs", findSimpleJobInfo(columnFormatter));
        } else {
            extraProps.put("simple-mode", false);
            List<Map<String, Object>> jobExecutions = new ArrayList<>();
            extraProps.put("list-batch-jobs", jobExecutions);
            for (JobExecution je : findJobExecutions()) {
                jobExecutions.add(handleJob(je, columnFormatter));
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

                    data = je.getEndTime();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
            jobInfo.put(getOutputHeaders()[index], data);
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobExecutions", jobExecutions);
        if (executionId != null) {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            JobExecution je = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (instanceId != null) {
                JobInstance ji = jobOperator.getJobInstance(Long.valueOf(executionId));
                if (ji.getInstanceId() != Long.valueOf(instanceId)) {
                    throw new RuntimeException("executionid " + executionId
                    + " is not associated with the specified instanceid (" + instanceId + ")"
                    + "; did you mean " + ji.getInstanceId() + " ?");
                }
            }
            jobExecutions.add(handleJob(je, columnFormatter));
        } else if (instanceId != null) {
            for (JobExecution je : getJobExecutionForInstance(Long.valueOf(instanceId))) {
                jobExecutions.add(handleJob(je, columnFormatter));
            }
        } else {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            Set<String> jobNames = jobOperator.getJobNames();
            if (jobNames != null) {
                for (String jn : jobOperator.getJobNames()) {
                    List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
                    if (exe != null) {
                        for (JobInstance ji : exe) {
                            for (JobExecution je : jobOperator.getJobExecutions(ji)) {
                                jobExecutions.add(handleJob(jobOperator.getJobExecution(je.getExecutionId()), columnFormatter));
                            }
                        }
                    }
                }
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());

    }
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

                    cfData[index] = je.getEndTime().toString();
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                case STEP_COUNT:
                    long exeId = executionId == null ? je.getExecutionId() : Long.valueOf(executionId);
                    data = jobOperator.getStepExecutions(exeId) == null
                        ? 0 : jobOperator.getStepExecutions(exeId).size();
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

    ////////  static formatting stuff below   ///////////////////////////////
    /////////////////////////////////////////////////////////////////////////

    public static String format(List<InstanceInfo> infos) {
        String headings[] = {NAME, HOST, PORT, PID, CLUSTER, STATE};
        ColumnFormatter cf = new ColumnFormatter(headings);
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getHost(),
                        info.getPort(),
                        formatPid(info),
                        info.getDisplayCluster(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

        }
        return cf.toString();
    }

    public static String formatBrief(List<InstanceInfo> infos) {
        ColumnFormatter cf = new ColumnFormatter();
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

        final ActionReport report = context.getActionReport();
        String header_name = localStrings.getLocalString("list.loggers.header.name", "Logger Name");
        String header_subsystem = localStrings.getLocalString("list.loggers.header.subsystem", "Subsystem");
        String header_description = localStrings.getLocalString("list.loggers.header.description", "Logger Description");
       
        ColumnFormatter colFormatter = new ColumnFormatter(new String[]{header_name, header_subsystem, header_description});
               
        // An option to specify client locale should be supported. However, it probably
        // should not be specific to this command. For now, localize using the default locale.
        Locale locale = Locale.getDefault();

        try {
            Set<String> loggers = loggerInfoMetadataService.getLoggerNames();
            Set<String> sortedLoggers = new TreeSet<String>(loggers);
            // The following Map & List are used to hold the REST data
            Map<String, String> loggerSubsystems = new TreeMap<String, String>();
            Map<String, String> loggerDescriptions = new TreeMap<String, String>();
            List<String> loggerList = new ArrayList<String>();
           
            for (String logger : sortedLoggers) {
                String subsystem = loggerInfoMetadataService.getSubsystem(logger);
                String desc = loggerInfoMetadataService.getDescription(logger, locale);
                boolean published = loggerInfoMetadataService.isPublished(logger);
                if (subsystem == null) subsystem = UNKNOWN;
                if (desc == null) desc = UNKNOWN;
                if (published || listInternalLoggers) {
                    colFormatter.addRow(new Object[]{logger, subsystem, desc});
                    loggerSubsystems.put(logger, subsystem);
                    loggerDescriptions.put(logger, desc); //Needed for REST xml and JSON output
                    loggerList.add(logger); //Needed for REST xml and JSON output                                   
                }
            }
           
            report.appendMessage(colFormatter.toString());
            report.appendMessage(System.getProperty("line.separator"));
           
            // Populate the extraProperties data structure for REST...
            Properties restData = new Properties();
            restData.put("loggerSubsystems", loggerSubsystems);
View Full Code Here

Examples of com.sun.enterprise.util.ColumnFormatter

        map.put(DATA_SOURCE_NAME, batchRuntimeConfiguration.getDataSourceLookupName());
        map.put(EXECUTOR_SERVICE_NAME, batchRuntimeConfiguration.getExecutorServiceLookupName());
        extraProps.put("listBatchRuntimeConfiguration", map);

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        Object[] data = new Object[getOutputHeaders().length];
        for (int index=0; index<getOutputHeaders().length; index++) {
            switch (getOutputHeaders()[index]) {
                case DATA_SOURCE_NAME:
                    data[index] = batchRuntimeConfiguration.getDataSourceLookupName();
                    break;
                case EXECUTOR_SERVICE_NAME:
                    data[index] = batchRuntimeConfiguration.getExecutorServiceLookupName();
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
            }
        }
        columnFormatter.addRow(data);
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.