Search in sources :

Example 1 with Description

use of org.apache.openejb.api.jmx.Description in project tomee by apache.

the class JMXDeployer method getDeployedApplications.

@ManagedAttribute
@Description("List available applications")
public String[] getDeployedApplications() {
    try {
        final Collection<AppInfo> apps = deployer().getDeployedApps();
        final String[] appsNames = new String[apps.size()];
        int i = 0;
        for (final AppInfo info : apps) {
            appsNames[i++] = info.path;
        }
        return appsNames;
    } catch (final Exception e) {
        return new String[] { "ERR:" + e.getMessage() };
    }
}
Also used : NamingException(javax.naming.NamingException) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Description(org.apache.openejb.api.jmx.Description) ManagedAttribute(org.apache.openejb.api.jmx.ManagedAttribute)

Example 2 with Description

use of org.apache.openejb.api.jmx.Description in project tomee by apache.

the class JMXDeployer method reload.

@ManagedOperation
@Description("Reload the specified application")
public String reload(final String moduleId) {
    try {
        final Collection<AppInfo> apps = deployer().getDeployedApps();
        boolean found = false;
        for (final AppInfo info : apps) {
            if (info.path.equals(moduleId)) {
                found = true;
                break;
            }
        }
        if (found) {
            deployer().reload(moduleId);
            return "OK";
        } else {
            return "NOT FOUND";
        }
    } catch (final Exception e) {
        return "ERR:" + e.getMessage();
    }
}
Also used : NamingException(javax.naming.NamingException) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Description(org.apache.openejb.api.jmx.Description) ManagedOperation(org.apache.openejb.api.jmx.ManagedOperation)

Example 3 with Description

use of org.apache.openejb.api.jmx.Description in project tomee by apache.

the class JMXContainer method getManagedBeans.

@ManagedAttribute
@Description("Container managed beans.")
public String[] getManagedBeans() {
    final BeanContext[] beans = container.getBeanContexts();
    final String[] beanNames = new String[beans.length];
    int i = 0;
    for (final BeanContext bc : beans) {
        beanNames[i++] = new StringBuilder("bean-class: ").append(bc.getBeanClass().getName()).append(", ").append("ejb-name: ").append(bc.getEjbName()).append(", ").append("deployment-id: ").append(bc.getDeploymentID()).append(", ").toString();
    }
    return beanNames;
}
Also used : BeanContext(org.apache.openejb.BeanContext) Description(org.apache.openejb.api.jmx.Description) ManagedAttribute(org.apache.openejb.api.jmx.ManagedAttribute)

Example 4 with Description

use of org.apache.openejb.api.jmx.Description in project tomee by apache.

the class JMXBasicDataSource method executeValidationQuery.

@ManagedOperation
@Description("Execute the validation query.")
public String executeValidationQuery() {
    final String query = ds.getValidationQuery();
    if (query == null || query.trim().isEmpty()) {
        return "no validation query defined";
    }
    final Connection conn;
    try {
        conn = ds.getConnection();
    } catch (final SQLException e) {
        return e.getMessage();
    }
    Statement statement = null;
    try {
        statement = conn.createStatement();
        if (statement.execute(query)) {
            return "OK";
        }
        return "KO";
    } catch (final SQLException e) {
        return e.getMessage();
    } finally {
        if (statement != null) {
            try {
                statement.close();
            } catch (final SQLException e) {
            // no-op
            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (final SQLException e) {
            // no-op
            }
        }
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) Description(org.apache.openejb.api.jmx.Description) ManagedOperation(org.apache.openejb.api.jmx.ManagedOperation)

Aggregations

Description (org.apache.openejb.api.jmx.Description)4 NamingException (javax.naming.NamingException)2 ManagedAttribute (org.apache.openejb.api.jmx.ManagedAttribute)2 ManagedOperation (org.apache.openejb.api.jmx.ManagedOperation)2 AppInfo (org.apache.openejb.assembler.classic.AppInfo)2 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Statement (java.sql.Statement)1 BeanContext (org.apache.openejb.BeanContext)1