@Override public boolean ungetService(AbstractBundle bundleState, ServiceState serviceState) { serviceState.ungetScopedValue(bundleState); int useCount = bundleState.removeServiceInUse(serviceState); if (useCount == 0) serviceState.removeUsingBundle(bundleState); return useCount >= 0; }
@Override public Object getService(AbstractBundle bundleState, ServiceState serviceState) { // If the service has been unregistered, null is returned. if (serviceState.isUnregistered()) return null; // Add the given service ref to the list of used services bundleState.addServiceInUse(serviceState); serviceState.addUsingBundle(bundleState); Object value = serviceState.getScopedValue(bundleState); // If the factory returned an invalid value // restore the service usage counts if (value == null) { bundleState.removeServiceInUse(serviceState); serviceState.removeUsingBundle(bundleState); } return value; }