Hi
I am evaluating Tuscany 2.0 Beta1 and am trying to learn more about
Callbacks (Bi-Directional interface) of SCA 1.1.
I downloaded the Tuscany Sample files and started to explore the callback
implementations with webservice binding, i.e. the Search and SearchCallback
interfaces.
It took me a while before I realized that the Tuscany SCA Samples were based
on SCA v1.0. Tuscany 2.0 Beta1 is based on the SCA v1.1 specs.
After studying the sample sources, I have written my own callback.
Unfortunately, I kept on getting a runtime exception after I installed and
deployed my contribution. By the way, I am using Eclipse and the maven
tuscany plugin.
I can't find the problem and hope if someone can point me in the right
direction.
This is the error (printed on my console) I am getting when I try to run my
program:
[ERROR] Failed to execute goal
org.apache.tuscany.maven.plugins:maven-tuscany-plugin:2.0-Beta1:run
(default-cli) on project handler-agent: Execution default-cli of goal
org.apache.tuscany.maven.plugins:maven-tuscany-plugin:2.0-Beta1:run failed:
org.oasisopen.sca.ServiceRuntimeException: [Composite: {
http://docs.oasis-open.org/ns/opencsa/sca/200912}, Component:
MessageInterpreterComponent] - [ASM60033] No targets for reference:
Composite = {http://docs.oasis-open.org/ns/opencsa/sca/200912} Reference =
messageInterpreterCallback -> [Help 1]
I suspect that I am doing something wrong in the composite file. I can't
imagine I did something wrong in the java sources. (See below for the
sources.)
Kind Regards,
Urso
-------------------- THE SERVICE Interface With Callback Interface
association ----------
/**
*
*/
package org.acme.logix;
import org.acme.logix.message.Message;
import org.oasisopen.sca.annotation.Callback;
import org.oasisopen.sca.annotation.OneWay;
import org.oasisopen.sca.annotation.Remotable;
/**
*
*
*/
@Remotable
@Callback(MessageInterpreterCallback.class)
public interface MessageInterpreter {
@OneWay
void interpret(Message msg);
}
/**
*
*/
package org.acme.logix;
import org.oasisopen.sca.annotation.OneWay;
import org.oasisopen.sca.annotation.Remotable;
/**
*
*
*/
@Remotable
public interface MessageInterpreterCallback {
void onInterpret(Interpretation ipr);
}
---------- THE CLIENT implementing the callback interface ------------
/**
*
*/
package org.acme.logix;
import org.acme.logix.message.Message;
import org.oasisopen.sca.annotation.Reference;
/**
*
*/
public class LogisticCenterImpl implements LogisticCenter,
MessageInterpreterCallback {
private AuditService auditService;
@Reference
protected MessageInterpreter messageInterpreter;
/* (non-Javadoc)
* @see
org.acme.logix.LogisticCenter#processMessage(org.acme.logix.message.Message)
*/
public void processMessage(Message message) {
System.out.println("Processing message with payload " +
message.getPayload() );
auditService.logSentMessage(message);
messageInterpreter.interpret(message);
}
/**
* @return the auditService
*/
public AuditService getAuditService() {
return auditService;
}
/**
* @param auditService the auditService to set
*/
@Reference
public void setAuditService(AuditService auditService) {
this.auditService = auditService;
}
/**
* @param messageInterpreter the messageInterpreter to set
*/
public void setMessageInterpreter(MessageInterpreter messageInterpreter) {
this.messageInterpreter = messageInterpreter;
}
/**
* @return the messageInterpreter
*/
public MessageInterpreter getMessageInterpreter() {
return messageInterpreter;
}
/**
* THE CALLBACK method of MessageInterpreterCallback interface
*/
public void onInterpret(Interpretation ipr) {
System.out.println("Message has been interpreted.");
}
}
---------THE SERVICE WHICH IS CALLED BY THE CLIENT THROUGH WEBSERVICE
BINDING ---------
/**
*
*/
package org.acme.logix;
import org.acme.logix.message.Message;
import org.oasisopen.sca.RequestContext;
import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.annotation.Callback;
import org.oasisopen.sca.annotation.Context;
import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Service;
/**
*
*
*/
public class MessageInterpreterImpl implements MessageInterpreter{
@Callback
protected MessageInterpreterCallback messageInterpreterCallback;
/* (non-Javadoc)
* @see
org.acme.logix.MessageInterpreter#interpret(org.acme.logix.message.Message)
*/
public void interpret(Message msg) {
System.out.println("The message is being interpreted..");
Interpretation ipr = new Interpretation();
messageInterpreterCallback.onInterpret(ipr);
}
/**
* @return the messageInterpreterCallback
*/
public MessageInterpreterCallback getMessageInterpreterCallback() {
return messageInterpreterCallback;
}
/**
* @param messageInterpreterCallback the messageInterpreterCallback to set
*/
public void setMessageInterpreterCallback(
MessageInterpreterCallback messageInterpreterCallback) {
this.messageInterpreterCallback = messageInterpreterCallback;
}
}
---- THE COMPOSITE -----------
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://logistix"
xmlns:logistix="http://logistix"
name="AfnemerLogisticCenter">
<component name="AfnemerHandlingAgentComponent">
<implementation.java class="org.acme.logix.HandlingAgentImpl"/>
<reference name="logisticCenter" >
<binding.ws uri="
http://127.0.0.1:8087/AfnemerHandlingAgentComponent"/>
</reference>
<reference name="auditService" target="AuditServiceComponent"/>
</component>
<component name="AfnemerLogisticCenterComponent">
<implementation.java class="org.acme.logix.LogisticCenterImpl"/>
<reference name="messageInterpreter">
<interface.java interface="org.acme.logix.MessageInterpreter"
callbackInterface="org.acme.logix.MessageInterpreterCallback"/>
<binding.ws uri="
http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
<callback >
<binding.ws
uri="http://localhost:8084/Client/MessageInterpreterCallback<http://localhost:8081/Client/MessageInterpreterCallback>
" />
</callback>
</reference>
<reference name="auditService">
<binding.jms
initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
jndiURL="tcp://localhost:61616">
<destination jndiName="AuditServiceQueue" />
</binding.jms>
</reference>
</component>
<component name="MessageInterpreterComponent">
<implementation.java class="org.acme.logix.MessageInterpreterImpl"/>
<service name="MessageInterpreter">
<interface.java interface="org.acme.logix.MessageInterpreter"
callbackInterface="org.acme.logix.MessageInterpreterCallback"/>
<binding.ws uri="
http://localhost:8081/MessageInterpreterComponent/MessageInterpreter"/>
<callback>
<binding.ws
uri="http://localhost:8084/Client/MessageInterpreterCallback<http://localhost:8081/Client/MessageInterpreterCallback>
"/>
</callback>
</service>
</component>
<component name="AuditServiceComponent">
<implementation.java class="org.acme.logix.AuditServiceImpl"/>
<service name="AuditService">
<binding.jms
initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
jndiURL="tcp://localhost:61616">
<destination jndiName="AuditServiceQueue" />
</binding.jms>
</service>
</component>
</composite>