in modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java [735:836]
public void stop(Component component) {
if (!((RuntimeComponent)component).isStarted()) {
return;
}
if (logger.isLoggable(Level.FINE)) {
logger.fine("Stopping component: " + component.getURI());
}
for (ComponentService service : component.getServices()) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Stopping component service: " + component.getURI() + "#" + service.getName());
}
for (Binding binding : service.getBindings()) {
final ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service).getBindingProvider(binding);
if (bindingProvider != null) {
try {
// Allow bindings to read properties. Requires PropertyPermission read in security policy.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
bindingProvider.stop();
return null;
}
});
} catch (Throwable ex){
error("StopException", bindingProvider, ex);
}
}
}
}
for (ComponentReference reference : component.getReferences()) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Starting component reference: " + component.getURI() + "#" + reference.getName());
}
RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
for (Binding binding : reference.getBindings()) {
final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(binding);
if (bindingProvider != null) {
try {
// Allow bindings to read properties. Requires PropertyPermission read in security policy.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
bindingProvider.stop();
return null;
}
});
} catch (Throwable ex){
error("StopException", bindingProvider, ex);
}
}
}
for (Endpoint endpoint : reference.getEndpoints()) {
final EndpointResolver endpointResolver = runtimeRef.getEndpointResolver(endpoint);
if (endpointResolver != null) {
try {
// Allow endpoint resolvers to do any shutdown reference manipulation
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
endpointResolver.stop();
return null;
}
});
} catch (Throwable ex){
error("StopException", endpointResolver, ex);
}
}
}
}
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
stop((Composite)implementation);
} else {
final ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider();
if (implementationProvider != null) {
try {
// Allow bindings to read properties. Requires PropertyPermission read in security policy.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
implementationProvider.stop();
return null;
}
});
} catch (Throwable ex){
error("StopException", implementationProvider, ex);
}
}
}
if (component instanceof ScopedRuntimeComponent) {
ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
if (runtimeComponent.getScopeContainer() != null &&
runtimeComponent.getScopeContainer().getLifecycleState() != ScopeContainer.STOPPED) {
try {
runtimeComponent.getScopeContainer().stop();
} catch (Throwable ex){
error("StopException", runtimeComponent, ex);
}
}
}
((RuntimeComponent)component).setStarted(false);
}