Home » Archived » Buckminster » os conditional artifact targets (UI action filter ?)
|
Re: os conditional artifact targets (UI action filter ?) [message #380401 is a reply to message #380399] |
Sun, 26 October 2008 11:36 |
Guillaume Chatelet Messages: 146 Registered: July 2009 |
Senior Member |
|
|
Just to give a bit of feedback on this issue, after digging in the code a
little bit : the filter text area is matched against a
org.osgi.framework.Filter interface. This is done while checking if the
Artifact is enabled, ie : if the filter matches negatively it's as if the
artifact were disabled.
More informations about the Filter class here :
http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
The Filter is ldap style filter. I did a test to select an action
according to the platform.
I created 3 actions in a CSpec : test, test.linux and test.windows. test
has test.linux and test.windows as prerequisites to trigger them as needed
and hide the platform choice to the outside world. Here it is :
<?xml version="1.0" encoding="UTF-8"?>
<cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
name="cppunit-1.12.0" componentType="buckminster">
<cs:actions>
<cs:public name="test" actor="null">
<cs:prerequisites>
<cs:attribute name="test.linux"/>
<cs:attribute name="test.windows"/>
</cs:prerequisites>
</cs:public>
<cs:private name="test.linux" filter="(target.os=linux)"
actor="executor">
<cs:actorProperties>
<cs:property key="shell" value="echo linux"/>
</cs:actorProperties>
</cs:private>
<cs:private name="test.windows" filter="(target.os=win32)"
actor="executor">
<cs:actorProperties>
<cs:property key="shell" value="echo windows"/>
</cs:actorProperties>
</cs:private>
</cs:actions>
</cs:cspec>
Actually this doesn't work as expected so I dug into the code and found
this :
In the component org.eclipse.buckminster.core, package
org.eclipse.buckminster.core.cspec.model, class Attribute, Function
isEnabled.
The filter is matched against ctx.getProperties(). This property is empty
and so the filter's matching returns false.
I corrected this behavior like this :
public boolean isEnabled(IModelCache ctx) throws CoreException
{
if(m_filter == null)
return true;
final Map<String, String> properties = ctx.getProperties();
properties.putAll(RMContext.getGlobalPropertyAdditions());
return FilterUtils.isMatch(m_filter, properties);
}
Thomas, do you think this is a bug ? Is this the right fix ? Or should it
be handled in GlobalContext (the IModelCache implementation of ctx in this
case).
Tell me but I think Artifacts filtering according to platform could be of
great benefits.
Best regards,
Guillaume
|
|
|
Re: os conditional artifact targets (UI action filter ?) [message #380408 is a reply to message #380401] |
Mon, 27 October 2008 08:13 |
|
Hi Guillaume,
This looks like a bug, yes. The GlobalContext should override the
ModelCache.getProperties() method.
Regards,
Thomas Hallgren
Guillaume CHATELET wrote:
> Just to give a bit of feedback on this issue, after digging in the code
> a little bit : the filter text area is matched against a
> org.osgi.framework.Filter interface. This is done while checking if the
> Artifact is enabled, ie : if the filter matches negatively it's as if
> the artifact were disabled.
>
> More informations about the Filter class here :
> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>
> The Filter is ldap style filter. I did a test to select an action
> according to the platform.
>
> I created 3 actions in a CSpec : test, test.linux and test.windows. test
> has test.linux and test.windows as prerequisites to trigger them as
> needed and hide the platform choice to the outside world. Here it is :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
> name="cppunit-1.12.0" componentType="buckminster">
> <cs:actions>
> <cs:public name="test" actor="null">
> <cs:prerequisites>
> <cs:attribute name="test.linux"/>
> <cs:attribute name="test.windows"/>
> </cs:prerequisites>
> </cs:public>
> <cs:private name="test.linux" filter="(target.os=linux)"
> actor="executor">
> <cs:actorProperties>
> <cs:property key="shell" value="echo linux"/>
> </cs:actorProperties>
> </cs:private>
> <cs:private name="test.windows" filter="(target.os=win32)"
> actor="executor">
> <cs:actorProperties>
> <cs:property key="shell" value="echo windows"/>
> </cs:actorProperties>
> </cs:private>
> </cs:actions>
> </cs:cspec>
>
> Actually this doesn't work as expected so I dug into the code and found
> this :
> In the component org.eclipse.buckminster.core, package
> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
> isEnabled.
> The filter is matched against ctx.getProperties(). This property is
> empty and so the filter's matching returns false.
>
> I corrected this behavior like this :
> public boolean isEnabled(IModelCache ctx) throws CoreException
> {
> if(m_filter == null)
> return true;
>
> final Map<String, String> properties = ctx.getProperties();
> properties.putAll(RMContext.getGlobalPropertyAdditions());
> return FilterUtils.isMatch(m_filter, properties);
> }
>
> Thomas, do you think this is a bug ? Is this the right fix ? Or should
> it be handled in GlobalContext (the IModelCache implementation of ctx in
> this case).
>
> Tell me but I think Artifacts filtering according to platform could be
> of great benefits.
>
> Best regards,
> Guillaume
>
|
|
|
Re: os conditional artifact targets (UI action filter ?) [message #380412 is a reply to message #380408] |
Mon, 27 October 2008 09:11 |
Guillaume Chatelet Messages: 146 Registered: July 2009 |
Senior Member |
|
|
I opened an entry in Bugzilla : https://bugs.eclipse.org/bugs/show_bug.cgi?id=252146
I'll fix this ASAP.
Regards,
Guillaume
Thomas Hallgren wrote:
> Hi Guillaume,
> This looks like a bug, yes. The GlobalContext should override the
> ModelCache.getProperties() method.
>
> Regards,
> Thomas Hallgren
>
>
>
> Guillaume CHATELET wrote:
>> Just to give a bit of feedback on this issue, after digging in the
>> code a little bit : the filter text area is matched against a
>> org.osgi.framework.Filter interface. This is done while checking if
>> the Artifact is enabled, ie : if the filter matches negatively it's as
>> if the artifact were disabled.
>>
>> More informations about the Filter class here :
>> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>>
>> The Filter is ldap style filter. I did a test to select an action
>> according to the platform.
>>
>> I created 3 actions in a CSpec : test, test.linux and test.windows.
>> test has test.linux and test.windows as prerequisites to trigger them
>> as needed and hide the platform choice to the outside world. Here it is :
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
>> name="cppunit-1.12.0" componentType="buckminster">
>> <cs:actions>
>> <cs:public name="test" actor="null">
>> <cs:prerequisites>
>> <cs:attribute name="test.linux"/>
>> <cs:attribute name="test.windows"/>
>> </cs:prerequisites>
>> </cs:public>
>> <cs:private name="test.linux" filter="(target.os=linux)"
>> actor="executor">
>> <cs:actorProperties>
>> <cs:property key="shell" value="echo linux"/>
>> </cs:actorProperties>
>> </cs:private>
>> <cs:private name="test.windows" filter="(target.os=win32)"
>> actor="executor">
>> <cs:actorProperties>
>> <cs:property key="shell" value="echo windows"/>
>> </cs:actorProperties>
>> </cs:private>
>> </cs:actions>
>> </cs:cspec>
>>
>> Actually this doesn't work as expected so I dug into the code and
>> found this :
>> In the component org.eclipse.buckminster.core, package
>> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
>> isEnabled.
>> The filter is matched against ctx.getProperties(). This property is
>> empty and so the filter's matching returns false.
>>
>> I corrected this behavior like this :
>> public boolean isEnabled(IModelCache ctx) throws CoreException
>> {
>> if(m_filter == null)
>> return true;
>>
>> final Map<String, String> properties = ctx.getProperties();
>> properties.putAll(RMContext.getGlobalPropertyAdditions());
>> return FilterUtils.isMatch(m_filter, properties);
>> }
>>
>> Thomas, do you think this is a bug ? Is this the right fix ? Or should
>> it be handled in GlobalContext (the IModelCache implementation of ctx
>> in this case).
>>
>> Tell me but I think Artifacts filtering according to platform could be
>> of great benefits.
>>
>> Best regards,
>> Guillaume
>>
|
|
|
Re: os conditional artifact targets (UI action filter ?) [message #380414 is a reply to message #380412] |
Mon, 27 October 2008 16:35 |
Guillaume Chatelet Messages: 146 Registered: July 2009 |
Senior Member |
|
|
Hi Thomas,
The isEnabled function is called on attributes that are prerequisites for other attributes only.
So if the attribute is a root action for instance ( not a prerequisites for another group/action ) the filter will not be tested and the action will be executed anyway.
Is this the expected behavior ?
I suspect this is also a bug, do you agree ?
Regards,
Guillaume
Guillaume CHATELET wrote:
> I opened an entry in Bugzilla :
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=252146
> I'll fix this ASAP.
>
> Regards,
> Guillaume
>
> Thomas Hallgren wrote:
>> Hi Guillaume,
>> This looks like a bug, yes. The GlobalContext should override the
>> ModelCache.getProperties() method.
>>
>> Regards,
>> Thomas Hallgren
>>
>>
>>
>> Guillaume CHATELET wrote:
>>> Just to give a bit of feedback on this issue, after digging in the
>>> code a little bit : the filter text area is matched against a
>>> org.osgi.framework.Filter interface. This is done while checking if
>>> the Artifact is enabled, ie : if the filter matches negatively it's
>>> as if the artifact were disabled.
>>>
>>> More informations about the Filter class here :
>>> http://www.osgi.org/javadoc/r4v41/org/osgi/framework/Filter. html
>>>
>>> The Filter is ldap style filter. I did a test to select an action
>>> according to the platform.
>>>
>>> I created 3 actions in a CSpec : test, test.linux and test.windows.
>>> test has test.linux and test.windows as prerequisites to trigger them
>>> as needed and hide the platform choice to the outside world. Here it
>>> is :
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <cs:cspec xmlns:cs="http://www.eclipse.org/buckminster/CSpec-1.0"
>>> name="cppunit-1.12.0" componentType="buckminster">
>>> <cs:actions>
>>> <cs:public name="test" actor="null">
>>> <cs:prerequisites>
>>> <cs:attribute name="test.linux"/>
>>> <cs:attribute name="test.windows"/>
>>> </cs:prerequisites>
>>> </cs:public>
>>> <cs:private name="test.linux" filter="(target.os=linux)"
>>> actor="executor">
>>> <cs:actorProperties>
>>> <cs:property key="shell" value="echo linux"/>
>>> </cs:actorProperties>
>>> </cs:private>
>>> <cs:private name="test.windows" filter="(target.os=win32)"
>>> actor="executor">
>>> <cs:actorProperties>
>>> <cs:property key="shell" value="echo windows"/>
>>> </cs:actorProperties>
>>> </cs:private>
>>> </cs:actions>
>>> </cs:cspec>
>>>
>>> Actually this doesn't work as expected so I dug into the code and
>>> found this :
>>> In the component org.eclipse.buckminster.core, package
>>> org.eclipse.buckminster.core.cspec.model, class Attribute, Function
>>> isEnabled.
>>> The filter is matched against ctx.getProperties(). This property is
>>> empty and so the filter's matching returns false.
>>>
>>> I corrected this behavior like this :
>>> public boolean isEnabled(IModelCache ctx) throws CoreException
>>> {
>>> if(m_filter == null)
>>> return true;
>>>
>>> final Map<String, String> properties = ctx.getProperties();
>>> properties.putAll(RMContext.getGlobalPropertyAdditions());
>>> return FilterUtils.isMatch(m_filter, properties);
>>> }
>>>
>>> Thomas, do you think this is a bug ? Is this the right fix ? Or
>>> should it be handled in GlobalContext (the IModelCache implementation
>>> of ctx in this case).
>>>
>>> Tell me but I think Artifacts filtering according to platform could
>>> be of great benefits.
>>>
>>> Best regards,
>>> Guillaume
>>>
|
|
|
Re: os conditional artifact targets (UI action filter ?) [message #380419 is a reply to message #380414] |
Tue, 28 October 2008 07:33 |
|
Guillaume CHATELET wrote:
> Hi Thomas,
>
> The isEnabled function is called on attributes that are prerequisites
> for other attributes only.
> So if the attribute is a root action for instance ( not a prerequisites
> for another group/action ) the filter will not be tested and the action
> will be executed anyway.
>
> Is this the expected behavior ?
> I suspect this is also a bug, do you agree ?
>
Yes. That sounds like a bug. Calling a disabled action should be a no-op in all cases.
Regards,
Thomas Hallgren
|
|
|
Goto Forum:
Current Time: Fri Apr 19 00:29:59 GMT 2024
Powered by FUDForum. Page generated in 0.03155 seconds
|