Lines 325-353
Link Here
|
325 |
|
325 |
|
326 |
break; |
326 |
break; |
327 |
case ServiceEvent.UNREGISTERING : |
327 |
case ServiceEvent.UNREGISTERING : |
|
|
328 |
Vector componentsToDispose; |
329 |
synchronized (syncLock) { |
330 |
//check for components with static reference to this service |
331 |
componentsToDispose = selectStaticUnBind(scpEnabled, event.getServiceReference(), false); |
332 |
} |
333 |
//dispose instances from staticUnbind |
334 |
if (componentsToDispose != null) { |
335 |
instanceProcess.disposeInstances(componentsToDispose, ComponentConstants.DEACTIVATION_REASON_REFERENCE); |
336 |
} |
337 |
|
328 |
Vector newlyUnsatisfiedSCPs; |
338 |
Vector newlyUnsatisfiedSCPs; |
329 |
synchronized (syncLock) { |
339 |
synchronized (syncLock) { |
330 |
serviceReferenceTable.remove(event.getServiceReference()); |
340 |
serviceReferenceTable.remove(event.getServiceReference()); |
331 |
if (scpEnabled.isEmpty()) |
341 |
if (scpEnabled.isEmpty()) |
332 |
return; // check for any enabled configurations |
342 |
return; // check for any enabled configurations |
333 |
|
343 |
|
334 |
newlyUnsatisfiedSCPs = selectNewlyUnsatisfied(); |
344 |
newlyUnsatisfiedSCPs = selectNewlyUnsatisfied(event.getServiceReference()); |
335 |
} |
345 |
} |
336 |
if (!newlyUnsatisfiedSCPs.isEmpty()) { |
346 |
if (!newlyUnsatisfiedSCPs.isEmpty()) { |
337 |
// synchronously dispose newly unsatisfied components |
347 |
// synchronously dispose newly unsatisfied components |
338 |
instanceProcess.disposeInstances(newlyUnsatisfiedSCPs, ComponentConstants.DEACTIVATION_REASON_REFERENCE); |
348 |
instanceProcess.disposeInstances(newlyUnsatisfiedSCPs, ComponentConstants.DEACTIVATION_REASON_REFERENCE); |
339 |
} |
349 |
} |
340 |
|
350 |
|
341 |
Vector componentsToDispose; |
|
|
342 |
synchronized (syncLock) { |
343 |
//check for components with static reference to this service |
344 |
componentsToDispose = selectStaticUnBind(scpEnabled, event.getServiceReference(), false); |
345 |
} |
346 |
//dispose instances from staticUnbind |
347 |
if (componentsToDispose != null) { |
348 |
instanceProcess.disposeInstances(componentsToDispose, ComponentConstants.DEACTIVATION_REASON_UNSPECIFIED); |
349 |
} |
350 |
|
351 |
synchronized (syncLock) { |
351 |
synchronized (syncLock) { |
352 |
// Pass in the set of currently resolved components, check each one - |
352 |
// Pass in the set of currently resolved components, check each one - |
353 |
// do we need to unbind |
353 |
// do we need to unbind |
Lines 375-381
Link Here
|
375 |
|
375 |
|
376 |
// check for newly unsatisfied components and synchronously |
376 |
// check for newly unsatisfied components and synchronously |
377 |
// dispose them |
377 |
// dispose them |
378 |
newlyUnsatisfiedSCPs = selectNewlyUnsatisfied(); |
378 |
newlyUnsatisfiedSCPs = selectNewlyUnsatisfied(event.getServiceReference()); |
379 |
} |
379 |
} |
380 |
|
380 |
|
381 |
if (!newlyUnsatisfiedSCPs.isEmpty()) { |
381 |
if (!newlyUnsatisfiedSCPs.isEmpty()) { |
Lines 534-540
Link Here
|
534 |
} |
534 |
} |
535 |
} |
535 |
} |
536 |
|
536 |
|
537 |
private Vector selectNewlyUnsatisfied() { |
537 |
private Vector selectNewlyUnsatisfied(ServiceReference serviceRef) { |
538 |
try { |
538 |
try { |
539 |
Vector result = (Vector) scpEnabled.clone(); |
539 |
Vector result = (Vector) scpEnabled.clone(); |
540 |
for (int k = result.size() - 1; k >= 0; k--) { |
540 |
for (int k = result.size() - 1; k >= 0; k--) { |
Lines 547-553
Link Here
|
547 |
// scp and re-run the algorithm |
547 |
// scp and re-run the algorithm |
548 |
Reference reference = (Reference) refs.elementAt(i); |
548 |
Reference reference = (Reference) refs.elementAt(i); |
549 |
if (reference != null) { |
549 |
if (reference != null) { |
550 |
boolean resolved = !reference.isRequiredFor(scp.serviceComponent) || reference.hasProviders(null); |
550 |
if (serviceRef != null && reference.reference.bind != null && scp.getState() == Component.STATE_ACTIVE && !(reference.dynamicUnbindReference(serviceRef) || reference.staticUnbindReference(serviceRef)) && !isPossibleMatch(reference, serviceRef)) { |
|
|
551 |
//make quick test - the service reference is not bound to the current component reference |
552 |
continue; |
553 |
} |
554 |
boolean resolved = !reference.isRequiredFor(scp.serviceComponent) || reference.hasProviders(this.serviceReferenceTable); |
551 |
|
555 |
|
552 |
if (!resolved && scp.isBuilt()) { |
556 |
if (!resolved && scp.isBuilt()) { |
553 |
if (Activator.DEBUG) { |
557 |
if (Activator.DEBUG) { |
Lines 569-574
Link Here
|
569 |
} |
573 |
} |
570 |
} |
574 |
} |
571 |
|
575 |
|
|
|
576 |
private boolean isPossibleMatch(Reference reference, ServiceReference serviceRef) { |
577 |
String[] serviceNames = (String[]) serviceRef.getProperty(Constants.OBJECTCLASS); |
578 |
boolean hasName = false; |
579 |
for (int i = 0; i < serviceNames.length; i++) { |
580 |
if (serviceNames[i].equals(reference.interfaceName)) { |
581 |
hasName = true; |
582 |
break; |
583 |
} |
584 |
} |
585 |
if (!hasName) { |
586 |
return false; |
587 |
} |
588 |
// check target filter |
589 |
try { |
590 |
Filter filter = FrameworkUtil.createFilter(reference.target); |
591 |
if (!filter.match(serviceRef)) { |
592 |
return false; |
593 |
} |
594 |
} catch (InvalidSyntaxException e) { |
595 |
return false; |
596 |
} |
597 |
return true; |
598 |
} |
599 |
|
572 |
// -- begin *disable* component routines |
600 |
// -- begin *disable* component routines |
573 |
/** |
601 |
/** |
574 |
* Disable list of ComponentDescriptions |
602 |
* Disable list of ComponentDescriptions |