use of org.apache.felix.service.command.Descriptor in project felix by apache.
the class Basic method update.
@Descriptor("update bundle from URL")
public void update(@Descriptor("command session") CommandSession session, @Descriptor("target bundle") Bundle bundle, @Descriptor("URL from where to retrieve bundle") String location) throws IOException {
if (location != null) {
location = Util.resolveUri(session, location.trim());
try {
// Get the bundle.
if (bundle != null) {
InputStream is = new URL(location).openStream();
bundle.update(is);
} else {
System.err.println("Please specify a bundle to update");
}
} catch (MalformedURLException ex) {
System.err.println("Unable to parse URL");
} catch (IOException ex) {
System.err.println("Unable to open input stream: " + ex);
} catch (BundleException ex) {
if (ex.getNestedException() != null) {
System.err.println(ex.getNestedException().toString());
} else {
System.err.println(ex.toString());
}
} catch (Exception ex) {
System.err.println(ex.toString());
}
} else {
System.err.println("Must specify a location.");
}
}
use of org.apache.felix.service.command.Descriptor in project felix by apache.
the class Basic method frameworklevel.
@Descriptor("set framework active start level")
public void frameworklevel(@Descriptor("target start level") int level) {
// Keep track of service references.
List<ServiceReference<?>> refs = new ArrayList<ServiceReference<?>>();
// Get start level service.
StartLevel sl = Util.getService(m_bc, StartLevel.class, refs);
if (sl == null) {
System.out.println("Start Level service is unavailable.");
}
sl.setStartLevel(level);
Util.ungetServices(m_bc, refs);
}
use of org.apache.felix.service.command.Descriptor in project felix by apache.
the class Basic method refresh.
@Descriptor("refresh bundles")
public void refresh(@Descriptor("target bundles (can be null or empty)") Bundle[] bundles) {
if ((bundles != null) && (bundles.length == 0)) {
bundles = null;
}
// Keep track of service references.
List<ServiceReference<?>> refs = new ArrayList<ServiceReference<?>>();
// Get package admin service.
PackageAdmin pa = Util.getService(m_bc, PackageAdmin.class, refs);
if (pa == null) {
System.out.println("Package Admin service is unavailable.");
}
pa.refreshPackages((bundles == null) ? null : bundles);
Util.ungetServices(m_bc, refs);
}
use of org.apache.felix.service.command.Descriptor in project felix by apache.
the class Basic method resolve.
@Descriptor("resolve bundles")
public void resolve(@Descriptor("target bundles (can be null or empty)") Bundle[] bundles) {
if ((bundles != null) && (bundles.length == 0)) {
bundles = null;
}
// Keep track of service references.
List<ServiceReference<?>> refs = new ArrayList<ServiceReference<?>>();
// Get package admin service.
PackageAdmin pa = Util.getService(m_bc, PackageAdmin.class, refs);
if (pa == null) {
System.out.println("Package Admin service is unavailable.");
}
if (!pa.resolveBundles(bundles)) {
System.out.println("Not all bundles could be resolved.");
}
Util.ungetServices(m_bc, refs);
}
use of org.apache.felix.service.command.Descriptor in project felix by apache.
the class Basic method frameworklevel.
@Descriptor("query framework active start level")
public void frameworklevel() {
// Keep track of service references.
List<ServiceReference<?>> refs = new ArrayList<ServiceReference<?>>();
// Get start level service.
StartLevel sl = Util.getService(m_bc, StartLevel.class, refs);
if (sl == null) {
System.out.println("Start Level service is unavailable.");
}
System.out.println("Level is " + sl.getStartLevel());
Util.ungetServices(m_bc, refs);
}
Aggregations