You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Florian Brunner (JIRA)" <ji...@apache.org> on 2015/03/18 00:43:38 UTC

[jira] [Comment Edited] (FELIX-4831) Simplify the declaration of capabilities

    [ https://issues.apache.org/jira/browse/FELIX-4831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14366317#comment-14366317 ] 

Florian Brunner edited comment on FELIX-4831 at 3/17/15 11:43 PM:
------------------------------------------------------------------

Point 1: Since the Maven Bundle Plugin picks up the instructions from the POM file, it should also be possible to pick them up from a properties file and merge them with the ones from the POM file

Point 2: While extenders are currently in my focus, I think the annotations should be generic enough to specify any kind of capability. All Provide-/Require-Capability instructions need this low-level syntax. Have a look at the sample below.

Point 3: OK, I'm not aware of the latest unreleased additions. Could you provide a sample how this is intended to work with the DS annotation processor? And I also didn't get what part you want to do in bnd (e.g. by using a bnd plugin or providing some support as you mentioned it).

I'm thinking of something like this:

@ProvideCapability(name=OsgiCDI.EXTENSION_CAPABILITY_NAME, 
    @CapabilityAttribute(name=OsgiCDI.EXTENSION_ATTRIBUTE_NAME, value="my-extension"))
package my.extension.package

and then in some other package:

@RequireCapability(name=Osgi.EXTENDER_CAPABILITY_NAME,
   @CapabilityDirective(name=OsgiCDI.FILTER_DIRECTIVE_NAME, value="(osgi.extender=pax.cdi)"))
@RequireCapability(name=OsgiCDI.EXTENSION_CAPABILITY_NAME,
   @CapabilityDirective(name=OsgiCDI.FILTER_DIRECTIVE_NAME, value="(extension=my-extension)"))
package some.other.package

You only need to know:
 - the filter syntax, but this syntax it used at many places in OSGi
 - the correct constant fields
 - the keys and values used in the filters
 - what to specify as an attribute and what as a directive

In this sample 
 - typos could only happen in the value attributes
 - you don't have to know how to separate capabilities
 - you don't have to know how to separate capability names from attributes and directives
 - you don't have to know that ":=" specifies a directive and "=" specifies an attribute

Maybe we can simplify this even further somehow?


was (Author: puce):
Point 1: Since the Maven Bundle Plugin picks up the instructions from the POM file, it should also be possible to pick them up from a properties file and merge them with the ones from the POM file

Point 2: While extenders are currently in my focus, I think the annotations should be generic enough to specify any kind of capability. All Provide-/Require-Capability instructions need this low-level syntax. Have a look at the sample below.

Point 3: OK, I'm not aware of the latest unreleased additions. Could you provide a sample how this is intended to work with the DS annotation processor? And I also didn't get what part you want to do in bnd (e.g. by using a bnd plugin or providing some support as you mentioned it).

I'm thinking of something like this:

@ProvideCapability(name=OsgiCDI.EXTENSION_CAPABILITY_NAME, 
    @CapabilityAttribute(name=OsgiCDI.EXTENSION_ATTRIBUTE_NAME, value="my-extension"))
package my.extension.package

and then in some other package:

@RequireCapability(name=Osgi.EXTENDER_CAPABILITY_NAME,
   @CapabilityDirective(name=OsgiCDI.FILTER_DIRECTIVE_NAME, value="(osgi.extender=pax.cdi)"))
@RequireCapability(name=OsgiCDI.EXTENSION_CAPABILITY_NAME,
   @CapabilityDirective(name=OsgiCDI.FILTER_DIRECTIVE_NAME, value="(extension=my-extension)"))
package some.other.package

You only need to know:
 - the filter syntax, but this syntax it used at many places in OSGi
 - the correct constant fields
 - the keys and values used in the filters

In this sample 
 - typos could only happen in the value attributes
 - you don't have to know how to separate capabilities
 - you don't have to know how to separate capability names from attributes and directives
 - you don't have to know that ":=" specifies a directive and "=" specifies an attribute

Maybe we can simplify this even further somehow?

> Simplify the declaration of capabilities
> ----------------------------------------
>
>                 Key: FELIX-4831
>                 URL: https://issues.apache.org/jira/browse/FELIX-4831
>             Project: Felix
>          Issue Type: Improvement
>          Components: Maven Bundle Plugin
>    Affects Versions: maven-bundle-plugin-2.5.3
>            Reporter: Florian Brunner
>
> Declaring capabilities is currently rather cryptic. It requires a specific syntax, which I believe is hard to remember for non-OSGi experts.
> E.g. to provide a CDI extension using PAX-CDI you would need something like this:
>                         <Provide-Capability>
>                             org.ops4j.pax.cdi.extension; extension=my-extension
>                         </Provide-Capability>
> To require the CDI extension you would need something like this:
>                     <instructions>
>                         <Require-Capability>
>                             osgi.extender; filter:="(osgi.extender=pax.cdi)", org.ops4j.pax.cdi.extension; filter:="(extension=my-extension)"
>                         </Require-Capability>
>                     </instructions>
> The proposed solutions consists of 3 parts:
>  - a new property for the bundle goal of the Maven Bundle Plugin: instructionsFile 
>   This property defines a properties file containing additional BND instructions to take into consideration when executing the goal
> - a annotation library, which provides annotations for declaring BND instructions
> - a custom annotation processor, which generates the instructionsFile from the annotations
> This approach would:
> - guide the developer what to specify
> - doesn't require the developer to know the exact syntax
> - helps avoiding typos



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)