Re: [sca-j] Why is @Property.required attribute MUST be true forconstructor parameter?

From
Mike Edwards <>
Date
2009-02-25T10:17:33+00:00
ID
Thread
Re: [sca-j] Why is @Property.required attribute MUST be true forconstructor parameter?
Vamsi,

You make a good point in reminding me
that the Java TC has not voted through a resolution to remove the use

of componentType side files for Java
POJOs.  I have now raised a new issue to do this - which will remove

Section 10 entirely.

I note that the Liaison committee posted
a recommendation that implementation types either use pure introspection

OR purely use a side file and never
try to combine the information from two sources.  Java POJOs can have
all

their component type metadata derived
via introspection - as a result side files are not useful and add complexity.

Yours,  Mike.

Strategist - Emerging Technologies, SCA & SDO.

Co Chair OASIS SCA Assembly TC.

IBM Hursley Park, Mail Point 146, Winchester, SO21 2JN, Great Britain.

Phone & FAX: +44-1962-818014    Mobile: +44-7802-467431  

Email:  

From:
C Vamsi <>

To:
Mike Edwards/UK/IBM@IBMGB

Cc:


Date:
24/02/2009 10:15

Subject:
Re: [sca-j] Why is @Property.required
attribute MUST be true for constructor parameter?

Comments inline in <vamsi> tags.

++Vamsi

Apache Tuscany Committer  http://tuscany.apache.org

Apache Geronimo Committer and Member of PMC  http://geronimo.apache.org

                    
                     
                     
          

             Mike Edwards      
                     
                     

             <mike_edwards@uk.  
                     
                    

             ibm.com>      
                     
                     
To 

                    
                  
         

             24/02/2009 15:22    
                     
                cc 

                    
                     
                     
          

                    
                     
                     
  Subject 

                    
                  Re: [sca-j]
Why is                  

                    
                  @Property.required
attribute MUST   

                    
                  be true
for constructor parameter?  

                    
                     
                     
          

                    
                     
                     
          

                    
                     
                     
          

                    
                     
                     
          

                    
                     
                     
          

                    
                     
                     
          

Folks,

When using constructor parameters for injection, there are a couple of

considerations to bear in mind:

1) Each constructor parameter MUST be annotated with either @Reference
or

with @Property, depending

on the type of the parameter.  This is required in order that each

parameter has a NAME which then appears

in the componentType - without this, it is impossible to get a name for
the

constructor parameter (none is

available via introspection)

2) Clearly, each constructor parameter MUST supply a value, even if that

value is NULL.  There is no

avoiding this.  The runtime MUST pass in some value when it invokes
the

constructor.  This is the reason

behind the requirement for required=true on the @Property annotation.  The

using component can set

any value it likes for the property - potentially including "nil"
- but it

must set something.

On the point that Raymond makes that the property value "can be inherited

from the componentType" - this

is not correct.  The componentType is entirely derived from the

implementation itself, not from some other

metadata.  In fact, there is no separate componentType file any longer
for

Java implementations.  So the

<vamsi>

Have we done away with componentType side files for Java implementations?

Is there an issue resolution pending to be applied?  In

sca-javaci-1.1-spec-wd02.pdf, section 10, lines 509 thru 512, I still see
a

description of componentType side file for Java implementations.  What
am I

missing?

</vamsi>

only place for a property value to come from for a constructor parameter
is

from the component configuration

that uses the Java implementation.

Yours,  Mike.

Strategist - Emerging Technologies, SCA & SDO.

Co Chair OASIS SCA Assembly TC.

IBM Hursley Park, Mail Point 146, Winchester, SO21 2JN, Great Britain.

Phone & FAX: +44-1962-818014    Mobile: +44-7802-467431

Email:  

                    
                     
                     
          

 From:     Raymond Feng <>    
                     
      

                    
                     
                     
          

 To:             
                     
         

                    
                     
                     
          

 Date:     23/02/2009 21:09          
                     
               

                    
                     
                     
          

 Subject:  Re: [sca-j] Why is @Property.required attribute MUST be
true    

           for constructor parameter?    
                     
           

                    
                     
                     
          

My understanding is that @required=true means the property MUST be set
with

a value which can be either configured at the component level or inherited

from the componentType.

For example, if we have a constructor as follows:

public MyServiceImpl(@Property(name="myProp") String myProp)
{

       ...

}

The injection for "myProp" is required no matter what value it
is set.

Thanks,

Raymond

                    
                     
                     
          

 From:   C Vamsi <>      
                     
       

                    
                     
                     
          

 To:             
                     
         

                    
                     
                     
          

 Date:   02/23/2009 10:41 AM            
                     
            

                    
                     
                     
          

 Subject [sca-j] Why is @Property.required attribute MUST be true for  
   

 :       constructor parameter?        
                     
             

                    
                     
                     
          

sca-javacaa-1.1-spec-cd02-rev2.doc:

Sec 9.15 @Property

Lines 1622-1623:

required (optional) – specifies whether injection is required, defaults
to

true. For a constructor parameter annotation, this attribute MUST have
the

value true.

Q: Why is, "For a constructor parameter annotation, this attribute
MUST

have the value true." required?

The componentType can define a default value for the property. In this

case, even if a property is not specified in the component definition,
the

runtime will still have a value to pass as an argument to the constructor.

++Vamsi

Apache Tuscany Committer  http://tuscany.apache.org

Apache Geronimo Committer and Member of PMC  http://geronimo.apache.org

Unless stated otherwise above:

IBM United Kingdom Limited - Registered in England and Wales with number

741598.

Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU

Unless stated otherwise above:

IBM United Kingdom Limited - Registered in England and Wales with number
741598. 

Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU