[
https://issues.apache.org/jira/browse/TUSCANY-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531616
]
Raymond Feng commented on TUSCANY-1823:
---------------------------------------
Hi,
I think it requires the SCA spec clarification here. In the following case:
@Property
public String location = "RTP";
Do we take the "RTP" as the default value? Should
ComponentContext.getProperty(String.class, "location") return "RTP"? If so,
then it will be inconsistent with the setter method because it cannot access
the default value.
private String location ="RTP";
@Property
public void setLocation(String location) {
this.location = location;
}
It's not clear in the spec (assembly and java).
Thanks,
Raymond
> 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
>
> Attachments: ComponentContextGetPropertyComparisonFix.patch,
> ComponentContextGetPropertyTest_FAILS.patch
>
>
> 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]