concept callback proxy in category system administration

appears as: callback proxy, callback proxies
Tuscany SCA in Action

This is an excerpt from Manning's book Tuscany SCA in Action.

To send a callback message, the service implementation has to obtain a proxy that points back to the calling component. When using a Java implementation, you can retrieve the proxy to the callback service by adding the SCA @Callback annotation to the field into which you want Tuscany to inject the callback proxy.

For the Java implementation type, a service makes a callback using a callback proxy. Callback proxies can be used by service implementations to make service calls in a similar way to the reference proxies we already described. The important difference is that a callback proxy’s destination is selected at runtime based on a previous call to the service, whereas a reference proxy’s destination is selected once at node start time based on reference wiring and binding configuration.

In listing 5.5, CreditCardPaymentConfirmImpl has a reference, cardCompany, for a service of type CardCompany that will make the real payment. The @Callback annotation is placed on a field of type CallableReference<CreditCardConfirm>, which causes Tuscany to inject a CallableReference object instead of a callback proxy. CreditCardPaymentConfirmImpl calls the CardCompany service to make the payment and passes the CallableReference object on this service call. The CardCompany service makes the payment, generates a payment reference, and makes a callback confirmation to the original client using the CallableReference object that it was passed. The code to make the callback would look like the following:

callbackRef.getService().confirmPayment(paymentRef);

This code uses the getService() method of the CallableReference object to obtain a callback proxy that’s used to call the client’s confirmPayment() method.

5.8.5. Getting the callback proxy from the request context

In listing 5.3, the callback proxy was injected into the service implementation instance. This works if a new service implementation instance is created for each request to the service, because each instance will contain injected callback proxies targeted at the service whose request created the instance. To put this another way, there will be a one-to-one relationship between service requests, implementation instances, and injected proxies.

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest