One more question.  What is the code in the worker that makes a
callback to the workpool?  Does it use an injected reference
annotated with @Callback, or does it make the callback using a
CallableReference for the callback that it obtains from the
RequestContext using the getCallback() method?

  Simon

Simon Nash wrote:


Giorgio Zoppi wrote:

2007/11/27, Simon Nash <[EMAIL PROTECTED]>:

This should work.  I am trying to understand the code example you
gave.  In the code snippet you have a call to setCallback() that
passes a ServiceReference<WorkpoolService> as the callback for a
service of type WorkpoolService.  However, your sample service is
of type AComponent and its callback service is of type
AComponentCallback.  Somewhere you need to call setCallback() on
a service reference of type AComponent, passing a callback service
reference of type AComponentCallback.  Is there any code that
does this?


Let me explain, the example was a proof of concept.
Actually in my code I have a component of name
WorkerComponentdc2c3b13d2aaa45d33c779af064c447f460d89f3, which is
dynamically generated, which it has no reference to other components.
Its definition is given by a template:
private StringTemplate t = new StringTemplate("<component
xmlns=\"http://www.osoa.org/xmlns/sca/1.0\";
name=\"$componentName$\">\n" +
            "<implementation.java class=\"$className$\"/>"+
            "<property name=\"workerName\">$componentName$</property>"+
            "</component>");
I process it with my own component processor and then i add it to the
composite.(replacing $name$, with appropriate values)

This is my worker.This worker implements an interface:

@Remotable
@Callback(WorkerServiceCallback.class)
@DataBinding("org.apache.tuscany.sca.databinding.job.Job")
public interface WorkerService<T,E> {
    @OneWay
    void compute(Job<T,E> job);
    void start();
    void stop();
}

Instead WorkpoolService implements WorkerServiceCallback:

@Remotable
public interface WorkerServiceCallback {
    void receiveResult(Job resultType,  boolean reuse,
ServiceReferenceImpl<WorkerService> serviceReference);
}

I generate a reference to a given worker component, i pass it as
CallableReference to
another component,

@Service(WorkpoolService.class)
@Scope("COMPOSITE")
@DataBinding("org.apache.tuscany.sca.databinding.job.Job")


public class WorkpoolServiceImpl implements WorkpoolService,
WorkerServiceCallback .


All of this looks OK to me.

Now my requirement is to add dynamically a callback to the worker, but
it fails.So when a callback gets wired to a component?

 >
I think your code should work.  The callback service reference that
you have dynamically set into the service reference for the worker
will be passed to the worker on the compute() call.  The worker
will store the callback address in a thread-local area and use it
when it makes the callback.  Are you by any chance switching threads
in the worker and making the callback from a different thread?  This
will not work with the current implementation.  I am intending to
remove this thread sensitivity but at the moment it is a limitation.

  Simon

I have a pair of hypothesis: the first is that a worker needs to set a
callback in its own runtime (in my case i set the callback in the
workpool runtime, which is in another host), the second is that's
something that i don't understand :).

Cheers,
Giorgio.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]









---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to