OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

sca-j message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [sca-j] Can a reference used with constructor be optional?

C Vamsi wrote:
> TARGET: sca-javaci-1.1-spec-wd03.doc
> Java C&I Spec
> Section 5: Implementation Instance Creation
> Lines 267-272:
>    Cyclic references between components may be handled by the container in
>    one of two ways:
>       If any reference in the cycle is optional, then the container may
>          inject a null value during construction, followed by injection of
>          a reference to the target before invoking any service.
>       The container may inject a proxy to the target service; invocation of
>          methods on the proxy may result in a ServiceUnavailableException
> I think "the container may inject a null value during construction" (or is
> it "any reference in the cycle is optional" that) no longer arises since
> from CAA spec, "For a @Reference annotation applied to a constructor
> parameter, the required attribute MUST have the value true.  [JCA90019]"
Thanks for finding this.  I wasn't aware of this being in the spec.

The first of these two paragraphs could only happen for a field
reference or setter method reference.  It couldn't happen for a
constructor parameter reference, because there is no opportunity
to do a follow-up injection of a constructor parameter reference
with the correct value.

For two components A and B that have cyclic references to each other
(as fields or setter methods), where A's reference to B is optional,
the above paragraph implies that the SCA runtime would need to do
something like the following:

  1. create instance of A
  2. inject null value for A's reference to B (according to
     the current spec paragraph above)
  3. create instance of B
  4. inject A instance into B's reference
  5. drive B's @Init method
  6. inject B instance into A's reference
  7. drive A's @Init method
  8. make B available for service invocations
  9. make A available for service invocations

You won't be surprised to hear that I think step 2 is redundant
and should not happen.

If we remove step 2, then I think we can also remove the
requirement for some reference in the cycle to be optional.
Instead, the paragraph would say:
  If any reference in the cycle is not a constructor parameter
  reference, the container may order the creation of implementation
  instances and reference injections so that this reference is
  injected last in the cycle of references.

This discussion affects the resolutions of JAVA-65 and JAVA-131.

> ++Vamsi
> Apache Tuscany Committer  http://tuscany.apache.org
> Apache Geronimo Committer and Member of PMC  http://geronimo.apache.org
> ---------------------------------------------------------------------
> To unsubscribe from this mail list, you must leave the OASIS TC that
> generates this mail.  Follow this link to all your TCs in OASIS at:
> https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php 

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]