String className, Class<?> interfaceName, String targetComponent)
throws ComponentUpdaterException, ComponentNotFoundException {
StAXArtifactProcessorExtensionPoint staxProcessors = registry
.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
MetaComponentProcessor processor = (MetaComponentProcessor) staxProcessors
.getProcessor(Component.class);
Contribution contrib = contributionService.getContribution(contribURI);
List<DeployedArtifact> artifacts = contrib.getArtifacts();
RuntimeComponent source = null;
Composite composite = ArtifactsFinder.findComposite(compositeURI,
artifacts);
// 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..");
}