public interface Usbinfo { String getDeviceInfo(String vendorId, String productId); } public class UsbinfoImpl implements Usbinfo { public String getDeviceInfo(String vendorId, String productId) { // ... return deviceInfo; } } public class Activator implements BundleActivator { public void start(BundleContext bundleContext) throws Exception { Usbinfo usbinfo = new UsbinfoImpl(); bundleContext.registerService(Usbinfo.class.getName(), usbinfo, null); } public void stop(BundleContext bundleContext) throws Exception { bundleContext.ungetService(bundleContext.getServiceReference(Usbinfo.class.getName())); } } <usbinfo> <device vendorId="1234" productId="5678" /> <device vendorId="abcd" productId="efgh" /> </usbinfo>


上一篇:
下一篇:
切换中文