* @param interfaze
* @throws TargetResolutionException
*/
private void handleCallback(Message msg, RuntimeWire wire, Object currentConversationID)
throws TargetResolutionException {
ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
parameters.setCallbackID(getCallbackID());
if (msg.getFrom() == null || msg.getFrom().getCallbackEndpoint() == null) {
return;
}
parameters.setCallbackReference(msg.getFrom().getCallbackEndpoint());
// If we are passing out a callback target
// register the calling component instance against this
// new conversation id so that stateful callbacks will be
// able to find it
Object callbackObject = getCallbackObject();
if (conversational && callbackObject == null) {
// the component instance is already registered
// so add another registration
ScopeContainer<Object> scopeContainer = getConversationalScopeContainer(wire);
if (scopeContainer != null && currentConversationID != null) {
scopeContainer.addWrapperReference(currentConversationID, conversation.getConversationID());
}
}
Interface interfaze = msg.getFrom().getCallbackEndpoint().getInterfaceContract().getInterface();
if (callbackObject != null) {
if (callbackObject instanceof ServiceReference) {
EndpointReference callbackRef = ((CallableReferenceExt<?>)callbackObject).getEndpointReference();
parameters.setCallbackReference(callbackRef);
} else {
if (interfaze != null) {
if (!interfaze.isConversational()) {
throw new IllegalArgumentException(
"Callback object for stateless callback is not a ServiceReference");
} else {
if (!(callbackObject instanceof Serializable)) {
throw new IllegalArgumentException(
"Callback object for stateful callback is not Serializable");
}
ScopeContainer scopeContainer = getConversationalScopeContainer(wire);
if (scopeContainer != null) {
InstanceWrapper wrapper = new CallbackObjectWrapper(callbackObject);
scopeContainer.registerWrapper(wrapper, conversation.getConversationID());
}
parameters.setCallbackObjectID(callbackObject);
}
}
}
}
}