Zesty.
6 years ago
The easy way to build service-oriented applications with OSGi
public class Activator extends BaseBundleActivator {
private HotdogVendor vendorService;
public Activator() {
super();
vendorService= new HotdogVendor();
}
protected String[] getImportedServiceNames() {
return new String[] {
BunService.SERVICE_NAME,
WienerService.SERVICE_NAME
};
}
protected void activate() {
System.out.println("Hotdog Vendor has been activated");
BunService bunService = getBunService();
WienerService wienerService = getWienerService();
vendorService.bind(bunService, wienerService);
addExportedService(VendorService.SERVICE_NAME, vendorService, null);
}
protected void deactivate() {
vendorService.unbind();
System.out.println("Hotdog Vendor has been deactivated");
}
private BunService getBunService() {
return (BunService) getImportedService(BunService.SERVICE_NAME);
}
private WienerService getWienerService() {
return (WienerService) getImportedService(WienerService.SERVICE_NAME);
}
}
getImportedServiceNames()
returns the names of the imported services. The SERVICE_NAME
field is the fully qualified name of the service interface and is an SAT convention.getBunService()
and getWienerService()
are helper methods; another SAT convention.activate()
method is a hook method that only gets called when all the bundle's imported services have been acquired. When called from the activate()
method, the getBunService()
and getWienerService()
method are guaranteed to not return null
.deactivate()
method is a hook method that only gets called when the bundle loses one of its imported services.activate()
and an unbind method in deactivate()
is another SAT convention that simplifies the binding and unbinding of imported services. It would be equally valid to call setter methods instead.activate()
and deactivate()
are a pair and will get called multiple times during the lifetime of the bundle as its imported services change.CommandProvider
service. SAT now includes such a bundle that adds the following commands to the console:
---SAT Bundle Dependencies---
depend <id> - show dependents the specified bundle
dependall <id> - show all dependents of the specified bundle
prereq <id> - show prerequisites of the specified bundle
prereqall <id> - show all prerequisites of the specified bundle
---SAT Logging---
loglevel {(debug|info|warning|error)} - query and control log level
trace {(on|off)} - query and control tracing
org.eclipse.soda.sat.equinox.console.cmdprov
, and is optional and specific to the Equinox console."Service-Oriented Device Architecture (SODA) is an initiative to standardize and simplify the integration of devices with enterprise solutions by introducing a services-based programming model. SODA leverages existing and emerging standards from both the embedded-device and IT domains to provide well-defined interfaces for hardware devices to a service-oriented architecture (SOA)."