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

org.ow2.jonas.admin.osgi.bundle.SimpleTableModel Maven / Gradle / Ivy

The newest version!
/**
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 2009 Bull S.A.S.
 * Contact: [email protected]
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.ow2.jonas.admin.osgi.bundle;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;

public class SimpleTableModel {
    public static Object getValueAt(final BundleContext m_context, final int row, final int column) {
        if (column == 0) {
            return new Long(m_context.getBundles()[row].getBundleId());
        } else if (column == 1) {
            return getStateString(m_context.getBundles()[row].getState());
        } else if (column == 2) {
            String name = (String) m_context.getBundles()[row].getHeaders().get(Constants.BUNDLE_NAME);
            name = (name == null) ? m_context.getBundles()[row].getLocation() : name;
            return name;
        } else if (column == 3) {
            return m_context.getBundles()[row].getSymbolicName();
        }
        return null;
    }

    private static String getStateString(final int state) {
        switch (state) {
            case Bundle.INSTALLED:
                return "Installed";
            case Bundle.RESOLVED:
                return "Resolved";
            case Bundle.STARTING:
                return "Starting";
            case Bundle.ACTIVE:
                return "Active";
            case Bundle.STOPPING:
                return "Stopping";
        }
        return "[unknown]";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy