Service implementation activator:
public void start(BundleContext bundleContext) throws Exception {Activator.context = bundleContext;
SongHibernateDAO df = new SongHibernateDAO();
//NewImplementation df = new NewImplementation();
sr=(ServiceRegistration<SongDAO>) context.registerService(SongDAO.class.getName(), (Object)df, null);
}
Service interface activator:
public class Activator implements BundleActivator {
public void start(BundleContext context) {
System.out.println("Starting the bundle");
}
public void stop(BundleContext context) {
System.out.println("Stopping the bundle");
}
Service consumer activator:
public void start(BundleContext bundleContext){
Activator.context = bundleContext;
ServiceReference reference = bundleContext.getServiceReference(SongDAO.class.getName());
//ServiceReference reference = bundleContext.getServiceReference(RandomQuoteService.class.getName());
if (reference == null) {
System.out.println("NULL");
} else {
// System.out.println("service found");
};
try {
service = (SongDAO)context.getService(reference); //??
}catch(Exception ex) {
ex.printStackTrace();
}
MyServiceTrackerCustomizer customTracker = new MyServiceTrackerCustomizer(bundleContext);
serviceTracker = new ServiceTracker(bundleContext, SongDAO.class.getName(), customTracker);
serviceTracker.open();
}
POM.XLS extra:
o <Embed‐Transitive>True</Embed‐Transitive>
o <Embed‐Dependency>*<Embed‐Dependency>
o <Import‐Package> org.osgi.framework, *;resolution:=optional </Import‐Package>
No comments:
Post a Comment