public void start(Component component) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Starting component: " + component.getURI());
}
RuntimeComponent runtimeComponent = ((RuntimeComponent)component);
if(runtimeComponent.isStarted()) {
return;
}
configureComponentContext(runtimeComponent);
for (ComponentReference reference : component.getReferences()) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Starting component reference: " + component.getURI() + "#" + reference.getName());
}
RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
runtimeRef.setComponent(runtimeComponent);
for (Endpoint endpoint : reference.getEndpoints()) {
final EndpointResolver endpointResolver = runtimeRef.getEndpointResolver(endpoint);
if (endpointResolver != null) {
// Allow endpoint resolvers to do any startup reference manipulation
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
endpointResolver.start();
return null;
}
});
}
}
for (Binding binding : reference.getBindings()) {
final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(binding);
if (bindingProvider != null) {
// Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
bindingProvider.start();
return null;
}
});
}
}
}
for (ComponentService service : component.getServices()) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
}
RuntimeComponentService runtimeService = (RuntimeComponentService)service;
for (Binding binding : service.getBindings()) {
final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(binding);
if (bindingProvider != null) {
// bindingProvider.start();
// Allow bindings to add shutdown hooks. Requires RuntimePermission shutdownHooks in policy.
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
bindingProvider.start();
return null;
}
});
}
}
}
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
start((Composite)implementation);
} else {
ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
if (implementationProvider != null) {
implementationProvider.start();
}
}
if (component instanceof ScopedRuntimeComponent) {
ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component;
if (scopedRuntimeComponent.getScopeContainer() != null) {
scopedRuntimeComponent.getScopeContainer().start();
}
}
runtimeComponent.setStarted(true);
}