// TODO error handling
if (composite != null)
source = (RuntimeComponent) ArtifactsFinder.findComponent(
composite, componentName);
else {
throw new ComponentNotFoundException("Not found component "
+ componentName + " for update");
}
if (source != null) {
// Debig this
RuntimeComponentReference targetReference = (RuntimeComponentReference) assemblyFactory
.createComponentReference();
targetReference.setName(referenceName);
targetReference.setUnresolved(true);
Reference reference = null;
try {
reference = buildReference(referenceName, className,
interfaceName, true);
} catch (Exception e) {
throw new ComponentUpdaterException(e.getMessage());
}
source.getImplementation().getReferences().add(reference);
// targetService.
ComponentService targetService = assemblyFactory
.createComponentService();
targetService.setUnresolved(true);
targetService.setName(targetComponent);
targetReference.getTargets().add(targetService);
// reconciliate
reconcileReference(reference, targetReference, componentName);
// create component reference for the reference
source.getReferences().add(targetReference);
try {
processor.resolveReference(targetReference, contrib
.getModelResolver());
} catch (ContributionResolveException e) {
throw new ComponentUpdaterException(
"Contribution Resolving Exception while updating..");
}
CompositeActivatorImpl activator = (CompositeActivatorImpl) compositeActivator;
compositeBuilder.attachWire(source, composite, targetReference);
activator.activate(source, targetReference);
synchronized (source) {
activator.configureComponentContext(source);
}
// RuntimeComponentReference runtimeRef =
// ((RuntimeComponentReference)ref);
// runtimeRef.setComponent(component);
for (Binding binding : targetReference.getBindings()) {
ReferenceBindingProvider bindingProvider = targetReference
.getBindingProvider(binding);
if (bindingProvider != null) {
bindingProvider.start();
}
}
ImplementationProvider implementationProvider = source
.getImplementationProvider();
if (implementationProvider != null) {
/*
* con la reflection cosi tolgo la dipendneza if
* ((implementationProvider.getClass().getName().equals("JavaImplementationProvider")) {
* Clazz cget } implementationProvider.getClass(). if
* (implementationProvider instanceof
* JavaImplementationProvider) { ((JavaImplementationProvider)
* implementationProvider). startReference(targetReference); }
*/
}
return targetReference;
} else {
throw new ComponentNotFoundException("Not found component "
+ componentName + " for update");
}
}