blob: 5631b6f81ab1c672caaa09688391c6f51cdc305d [file] [log] [blame]
package org.apache.karaf.webconsole.osgi.internal.bundle;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.karaf.webconsole.osgi.internal.bundle.model.BundleModel;
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
import org.apache.wicket.model.IModel;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
public class BundlesDataProvider extends SortableDataProvider<Bundle> {
private BundleContext context;
public BundlesDataProvider(BundleContext context) {
this.context = context;
}
public Iterator<? extends Bundle> iterator(int first, int count) {
List<Bundle> bundles = Arrays.asList(context.getBundles());
return bundles.subList(first, first + count).iterator();
}
public IModel<Bundle> model(Bundle object) {
return new BundleModel(object.getBundleId(), context);
}
public int size() {
return context.getBundles().length;
}
}