All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sirius.biz.i5.I5Command Maven / Gradle / Ivy

There is a newer version: 9.6
Show newest version
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.biz.i5;

import sirius.kernel.di.std.Part;
import sirius.kernel.di.std.Register;
import sirius.kernel.health.console.Command;

import javax.annotation.Nonnull;
import java.lang.ref.WeakReference;

/**
 * Provides a list of active connections for all configured I5 connection pools.
 */
@Register
public class I5Command implements Command {

    @Part
    private I5Connector i5;

    @Override
    public void execute(Output output, String... strings) throws Exception {
        for (I5ConnectionPool pool : i5.pools.values()) {
            output.line(pool.toString());
            output.separator();
            for (WeakReference c : pool.openConnections) {
                I5Connection connection = c.get();
                if (connection != null) {
                    output.apply("%-25s %s", connection.getLastUse(), connection.getLastJob());
                }
            }
            output.blankLine();
        }
    }

    @Override
    public String getDescription() {
        return "List all active connections to an IBM i5";
    }

    @Nonnull
    @Override
    public String getName() {
        return "i5";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy