/* (non-Javadoc) * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) */ @Override public Object getService(Bundle bundle, ServiceRegistration registration) { if (serviceInstance == null) { IRepositoryService repositoryService = null; IMarketService marketService = null; try { BundleContext context = CoreActivator.getDefault().getBundle().getBundleContext(); ServiceReference serviceReference = context.getServiceReference(IRepositoryService.class.getName()); if (serviceReference != null) { repositoryService = (IRepositoryService) context.getService(serviceReference); context.ungetService(serviceReference); } serviceReference = context.getServiceReference(IMarketService.class.getName()); if (serviceReference != null) { marketService = (IMarketService) context.getService(serviceReference); context.ungetService(serviceReference); } serviceInstance = new CurrencyService(repositoryService, marketService); serviceInstance.startUp(null); } catch (Exception e) { CoreActivator.log("Error starting currency service", e); } } return serviceInstance; }
public void dispose() { if (serviceInstance != null) { try { serviceInstance.shutDown(null); } catch (Exception e) { CoreActivator.log("Error stopping currency service", e); } } }