SCAJ Issue - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

SCAJ Issue

Description:

P1: A service reference instance is actually a thread local proxy to the real reference ... Cannot share conversation config between threads ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 7
Provided by: mike344
Category:
Tags: scaj | issue | threads

less

Transcript and Presenter's Notes

Title: SCAJ Issue


1
SCA/J Issue 8Concurrency Model for Service
Reference Instances
www.oasis-open.org
Henning Blohm
2
Issue Statement
  • TARGET Java Common Annotations and APIs
    specification, section "Java API" /
    "ComponentContext", "ServiceReference" and
    section "Asynchronous and Conversational
    Programming".
  • DESCRIPTION While the current text says that a
    service reference represents a single
    conversation, it is not clear how a
    multi-threaded client should protect a
    non-conversational service reference's
    configuration (conversation id, callback, etc) so
    that it stays unmodified by other threads until
    an actual invocation is executed. Consider the
    following code snippet for example class
    AComponent   _at_Reference ItemCheckerService
    srv   void goCheckItem(long ticket, String
    itemId)         ServiceReference sr
    (ServiceReference) srv         sr.setConversatio
    nID(ticket)         srv.check(itemId)   
    A simple synchronization may lead to strict
    serialization of remote calls which is generally
    undesirable.

3
Previous Proposals
  • P1 A service reference instance is actually a
    thread local proxy to the real reference
  • () Foolproof for the simple cases
  • (-) Cannot share conversation config between
    threads
  • P2 A single service reference represents exactly
    one actual or potential conversation. Each call
    to ComponentContext.getService (and similar
    methods) returns a new instance of
    ServiceReference.
  • () Still simple
  • () Clear rule how to get to a new conversation
    and how to configure it (see sample below)
  • (-) Injection not applicable for configurable
    refs
  • Proposal Accept P2.

4
Sample 1
One conversation per call public interface
ItemChecker void check(String
id) public class AComponent _at_Context
ComponentContext ctx void goCheckItem(long
ticket, String itemId)
ServiceReferenceltItemCheckergt sr
ctx.getServiceReference(ItemChecker.class,
"checker") sr.setConversationID(ticket)
sr.getService().check(itemId)
5
Sample 2
Conversation initiated once and used
often public class BComponent _at_Reference
ServiceReferenceltItemCheckergt checker
_at_Context ComponentContext ctx private
boolean configured public void
setTicket(long ticket) synchronized
(this) checker.setConversationID(ticket) this.c
onfiguredtrue void
goCheckItem(String itemId) synchronized
(this) if (!this.configured)
throw new IllegalStateException("not
configured missing ticket!")
checker.getService().check(itemId)

6
Sample 3
It could be nice to have one more method on
ServiceReference public class CComponent
_at_Reference ServiceReferenceltItemCheckergt
checker void goCheckItem(long ticket,
String itemId) ServiceReferenceltItemChec
kergt sr checker.createNew()
sr.setConversationID(ticket)
sr.getService().check(itemId)
Write a Comment
User Comments (0)
About PowerShow.com