ComponentContextHelper componentContextHelper = ComponentContextHelper.getCurrentComponentContextHelper();
if (componentContextHelper != null) {
CompositeActivator currentActivator = ComponentContextHelper.getCurrentCompositeActivator();
this.compositeActivator = currentActivator;
this.conversationManager = this.compositeActivator.getConversationManager();
Component c;
if (xmlReader != null) {
c = componentContextHelper.fromXML(xmlReader);
xmlReader = null; // OK to GC this now
} else {
c = componentContextHelper.fromXML(scdl);
scdl = null; // OK to GC this now
}
this.component = (RuntimeComponent)c;
currentActivator.configureComponentContext(this.component);
this.reference = (RuntimeComponentReference)c.getReferences().get(0);
this.reference.setComponent(this.component);
clonedRef = reference;
ReferenceParameters parameters = null;
for (Object ext : reference.getExtensions()) {
if (ext instanceof ReferenceParameters) {
parameters = (ReferenceParameters)ext;
break;
}
}
if (parameters != null) {
refParams = parameters;
this.callbackID = parameters.getCallbackID();
if (parameters.getConversationID() != null){
ExtendedConversation conversation = conversationManager.getConversation(parameters.getConversationID());
if (conversation == null){
conversation = conversationManager.startConversation(parameters.getConversationID());
}
this.conversation = conversation;
} else {
this.conversation = null;
}
}
for (Binding binding : reference.getBindings()) {
if (binding instanceof OptimizableBinding) {
String targetURI = binding.getURI();
if (targetURI.startsWith("/")) {
targetURI = targetURI.substring(1);
}
int index = targetURI.lastIndexOf('/');
String serviceName = "";
if (index > -1) {
serviceName = targetURI.substring(index + 1);
targetURI = targetURI.substring(0, index);
}
Component targetComponent = compositeActivator.resolve(targetURI);
ComponentService targetService = null;
if (targetComponent != null) {
if ("".equals(serviceName)) {
targetService = ComponentContextHelper.getSingleService(targetComponent);
} else {
for (ComponentService service : targetComponent.getServices()) {
if (service.getName().equals(serviceName)) {
targetService = service;
break;
}
}