use of org.osgi.framework.dto.BundleDTO in project bnd by bndtools.
the class AgentServer method getBundles.
private List<BundleDTO> getBundles() {
Bundle[] bundles = context.getBundles();
ArrayList<BundleDTO> list = new ArrayList<BundleDTO>(bundles.length);
for (Bundle b : bundles) {
list.add(toDTO(b));
}
return list;
}
use of org.osgi.framework.dto.BundleDTO in project bnd by bndtools.
the class JMXBundleDeployer method listBundles.
/**
* Calls osgi.core bundleState MBean listBundles operation
*
* @return array of bundles in framework
*/
public BundleDTO[] listBundles() {
final List<BundleDTO> retval = new ArrayList<BundleDTO>();
try {
final ObjectName bundleState = getBundleState();
final Object[] params = new Object[] { new String[] { "Identifier", "SymbolicName", "State", "Version" } };
final String[] signature = new String[] { String[].class.getName() };
final TabularData data = (TabularData) mBeanServerConnection.invoke(bundleState, "listBundles", params, signature);
for (Object value : data.values()) {
final CompositeData cd = (CompositeData) value;
try {
retval.add(newFromData(cd));
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return retval.toArray(new BundleDTO[0]);
}
use of org.osgi.framework.dto.BundleDTO in project bnd by bndtools.
the class AgentServer method getBundles.
@Override
public List<BundleDTO> getBundles(long... bundleId) throws Exception {
Bundle[] bundles;
if (bundleId.length == 0) {
bundles = context.getBundles();
} else {
bundles = new Bundle[bundleId.length];
for (int i = 0; i < bundleId.length; i++) {
bundles[i] = context.getBundle(bundleId[i]);
}
}
List<BundleDTO> bundleDTOs = new ArrayList<BundleDTO>(bundles.length);
for (Bundle b : bundles) {
BundleDTO dto = toDTO(b);
bundleDTOs.add(dto);
}
return bundleDTOs;
}
use of org.osgi.framework.dto.BundleDTO in project bnd by bndtools.
the class AgentServer method toDTO.
private BundleDTO toDTO(Bundle b) {
BundleDTO bd = new BundleDTO();
bd.id = b.getBundleId();
bd.lastModified = b.getLastModified();
bd.state = b.getState();
bd.symbolicName = b.getSymbolicName();
bd.version = b.getVersion() == null ? "0" : b.getVersion().toString();
return bd;
}
use of org.osgi.framework.dto.BundleDTO in project bnd by bndtools.
the class AgentTest method testAgentUpdateBundle.
public void testAgentUpdateBundle() throws Exception {
BundleDTO t2Bundle = supervisor.getAgent().getBundles(2).get(0);
assertEquals("bsn-2", t2Bundle.symbolicName);
assertEquals("2.0.0", t2Bundle.version);
long previousModified = t2Bundle.lastModified;
File t2prime = create("bsn-2", new Version(2, 0, 1));
String sha = supervisor.addFile(t2prime);
assertNull(supervisor.getAgent().update(2, sha));
t2Bundle = supervisor.getAgent().getBundles(2).get(0);
assertTrue(previousModified != t2Bundle.lastModified);
}
Aggregations