The getProperty() method on ComponentContext does not work
----------------------------------------------------------

                 Key: TUSCANY-1823
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1823
             Project: Tuscany
          Issue Type: Bug
          Components: Java SCA Core Runtime
    Affects Versions: Java-SCA-1.0
         Environment: SVN revision #579110
Linux
            Reporter: Mark Combellack
            Priority: Minor
             Fix For: Java-SCA-Next


As far as I can tell, it should be possible to get a property via:

   * Injection using @Property 
   * ComponentContext.getProperty() method (Java Annotations spec - line 807 & 
808)

The value returned by both of these methods should be equal.


The ComponentContext.getProperty() method currently does not work as detailed 
above.

The code for the ComponentContext.getProperty() method can be found in the 
ComponentContextImpl class of the core project.


There appears to be more than one problem:


Incorrectly comparing property name:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The code contains the following:

    public <B> B getProperty(Class<B> type, String propertyName) {
        for (ComponentProperty p : component.getProperties()) {
            if (propertyName.equals(propertyName)) {


Notice that the if statement is comparing property name with itself. They will 
always be equal! This means that the first property is always being used rather 
than finding the correct one based on it's name.


The code should be updated so that the if statement reads (i.e. use the 
p.getName() method)

            if (propertyName.equals(p.getName())) {

I have attached a patch to fix this comparison problem.



Properties appear not to be working:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

To test ComponentContext.getProperty(), I updated the properties iTest by 
adding a test that gets the location from the ComponentContext and compares it 
with the injected version. 

The problem is that the property value returned from the ComponentContext is 
null.

I have attached a patch for this test but as it does not pass so I would not 
apply it yet until this bug is fixed.

Unfortunately, I do not know the cause of this problem.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to