You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Steven E. Harris" <se...@panix.com> on 2007/02/23 02:48:44 UTC

Bundle plugin/BND question -- Service-Component header

The BND documentation¹ states that a Service-Component reference with a
lowercase name provokes a bean-style "set" method to be mentioned in
the generated XML resource:

,----[ Service-Component Header section ]
| In that case the reference is augmented with a set<Name> method
| according to the standard bean rules. An unset<Name> method is added
| when the name appears in the list that is given to the dynamic
| directive.
`----

Note the second sentence, which says that a corresponding "unset"
method will be mentioned if the reference is noted as being of
"dynamic" policy.

Later the document states that the default policy is "static":

,----
| The defaults are therefore aligned with the SCR: a cardinality of
| 1..1, and static policy.
`----

However, I notice that with a maven-bundle-plugin directive like this:

  <Service-Component>com.foo.impl.BarImpl;
                     provide:=com.foo.Bar;
                     quux=com.foo.Quux</Service-Component>

The resulting OSGI-INF/com.foo.impl.BarImpl.xml file contains a
"reference" element like so:

    <reference name='quux'
               interface='com.foo.Quux'
               bind='setQuux'
               unbind='unsetQuux'/>

Note the presence of the "unbind" attribute. This conflicts with the
documentation above that states that the unbind method will only be
mentioned for "dynamic" policies.

Am I missing something, or is this a bug in BND?


Footnotes: 
¹ http://www.aqute.biz/Code/Bnd

-- 
Steven E. Harris

Re: Bundle plugin/BND question -- Service-Component header

Posted by "Steven E. Harris" <se...@panix.com>.
Peter Kriens <Pe...@aQute.biz> writes:

> It turned out that the ProSyst implementation of Declarative
> Services threw an exception if there was a bind method and no unbind
> method. I think this is wrong, but I was not up for a fight about it
> so I added the unbind method.

Perhaps there could be another switch added that would control whether
the bind methods were forced to be symmetric. Consider:

  binding ::= 'unbind_static:=' ( 'true' | 'false' )

to configure all references, or maybe

  binding ::= 'unbind_static:=' LIST

to configure specific references, though inconsistency is then
possible if the list intersects with the "dynamic" set.

If reference parameters could themselves take parameters, we could use
this:

  binding ::= 'bind:=' ( 'none' | 'set' | 'unset' | 'both' )

By default, an non-lowercase reference would have a value of "none", a
static reference "set", and a dynamic reference "both". Of course, the
ProSyst users would need to specify "bind" to "both" for their static
references.

-- 
Steven E. Harris

Re[2]: Bundle plugin/BND question -- Service-Component header

Posted by Peter Kriens <Pe...@aQute.biz>.
BH> The DS spec does not require you to specify both bind and unbind. So the
BH> ProSyst implementation is incorrect in this respect.
Thais exactly what I concluded ... just did not feel the need to go
into the fight :-)

Kind regards,

     Peter Kriens
     
BH> BJ Hargrave
BH> Senior Technical Staff Member, IBM
BH> OSGi Fellow and CTO of the OSGi Alliance
BH> hargrave@us.ibm.com

BH> office: +1 386 848 1781
BH> mobile: +1 386 848 3788




BH> Peter Kriens <Pe...@aQute.biz> 
BH> 02/23/2007 02:32 AM
BH> Please respond to
BH> felix-dev@incubator.apache.org


BH> To
BH> "Steven E. Harris" <se...@panix.com>
BH> cc
BH> felix-dev@incubator.apache.org
BH> Subject
BH> Re: Bundle plugin/BND question -- Service-Component header






BH> It turned out that the ProSyst implementation of Declarative Services
BH> threw an exception if there was a bind method and no unbind method. I
BH> think this is wrong, but I was not up for a fight about it so I added
BH> the unbind method. I'll update the documentation to reflect this.

BH> I find it is no real problem to not implement the unbind method even
BH> though it is i the XML file.

BH> Kind regards,

BH>      Peter Kriens
BH>  



SEH>> The BND documentation¹ states that a Service-Component reference with 
BH> a
SEH>> lowercase name provokes a bean-style "set" method to be mentioned in
SEH>> the generated XML resource:

SEH>> ,----[ Service-Component Header section ]
SEH>> | In that case the reference is augmented with a set<Name> method
SEH>> | according to the standard bean rules. An unset<Name> method is 
BH> added
SEH>> | when the name appears in the list that is given to the dynamic
SEH>> | directive.
SEH>> `----

SEH>> Note the second sentence, which says that a corresponding "unset"
SEH>> method will be mentioned if the reference is noted as being of
SEH>> "dynamic" policy.

SEH>> Later the document states that the default policy is "static":

SEH>> ,----
SEH>> | The defaults are therefore aligned with the SCR: a cardinality of
SEH>> | 1..1, and static policy.
SEH>> `----

SEH>> However, I notice that with a maven-bundle-plugin directive like 
BH> this:

SEH>>   <Service-Component>com.foo.impl.BarImpl;
SEH>>                      provide:=com.foo.Bar;
SEH>>                      quux=com.foo.Quux</Service-Component>

SEH>> The resulting OSGI-INF/com.foo.impl.BarImpl.xml file contains a
SEH>> "reference" element like so:

SEH>>     <reference name='quux'
SEH>>                interface='com.foo.Quux'
SEH>>                bind='setQuux'
SEH>>                unbind='unsetQuux'/>

SEH>> Note the presence of the "unbind" attribute. This conflicts with the
SEH>> documentation above that states that the unbind method will only be
SEH>> mentioned for "dynamic" policies.

SEH>> Am I missing something, or is this a bug in BND?


SEH>> Footnotes: 
SEH>> ¹ http://www.aqute.biz/Code/Bnd





-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599


Re: Bundle plugin/BND question -- Service-Component header

Posted by "Steven E. Harris" <se...@panix.com>.
BJ Hargrave <ha...@us.ibm.com> writes:

> The DS spec does not require you to specify both bind and unbind. So
> the ProSyst implementation is incorrect in this respect.

Yes, and the Equinox DS implementation logs a severe error if the XML
file mentions such a method, but it's not present in the
implementation class.

-- 
Steven E. Harris

Re: Bundle plugin/BND question -- Service-Component header

Posted by BJ Hargrave <ha...@us.ibm.com>.
The DS spec does not require you to specify both bind and unbind. So the 
ProSyst implementation is incorrect in this respect.

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
hargrave@us.ibm.com

office: +1 386 848 1781
mobile: +1 386 848 3788




Peter Kriens <Pe...@aQute.biz> 
02/23/2007 02:32 AM
Please respond to
felix-dev@incubator.apache.org


To
"Steven E. Harris" <se...@panix.com>
cc
felix-dev@incubator.apache.org
Subject
Re: Bundle plugin/BND question -- Service-Component header






It turned out that the ProSyst implementation of Declarative Services
threw an exception if there was a bind method and no unbind method. I
think this is wrong, but I was not up for a fight about it so I added
the unbind method. I'll update the documentation to reflect this.

I find it is no real problem to not implement the unbind method even
though it is i the XML file.

Kind regards,

     Peter Kriens
 



SEH> The BND documentation¹ states that a Service-Component reference with 
a
SEH> lowercase name provokes a bean-style "set" method to be mentioned in
SEH> the generated XML resource:

SEH> ,----[ Service-Component Header section ]
SEH> | In that case the reference is augmented with a set<Name> method
SEH> | according to the standard bean rules. An unset<Name> method is 
added
SEH> | when the name appears in the list that is given to the dynamic
SEH> | directive.
SEH> `----

SEH> Note the second sentence, which says that a corresponding "unset"
SEH> method will be mentioned if the reference is noted as being of
SEH> "dynamic" policy.

SEH> Later the document states that the default policy is "static":

SEH> ,----
SEH> | The defaults are therefore aligned with the SCR: a cardinality of
SEH> | 1..1, and static policy.
SEH> `----

SEH> However, I notice that with a maven-bundle-plugin directive like 
this:

SEH>   <Service-Component>com.foo.impl.BarImpl;
SEH>                      provide:=com.foo.Bar;
SEH>                      quux=com.foo.Quux</Service-Component>

SEH> The resulting OSGI-INF/com.foo.impl.BarImpl.xml file contains a
SEH> "reference" element like so:

SEH>     <reference name='quux'
SEH>                interface='com.foo.Quux'
SEH>                bind='setQuux'
SEH>                unbind='unsetQuux'/>

SEH> Note the presence of the "unbind" attribute. This conflicts with the
SEH> documentation above that states that the unbind method will only be
SEH> mentioned for "dynamic" policies.

SEH> Am I missing something, or is this a bug in BND?


SEH> Footnotes: 
SEH> ¹ http://www.aqute.biz/Code/Bnd



-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599




Re: Bundle plugin/BND question -- Service-Component header

Posted by Peter Kriens <Pe...@aQute.biz>.
It turned out that the ProSyst implementation of Declarative Services
threw an exception if there was a bind method and no unbind method. I
think this is wrong, but I was not up for a fight about it so I added
the unbind method. I'll update the documentation to reflect this.

I find it is no real problem to not implement the unbind method even
though it is i the XML file.

Kind regards,

     Peter Kriens
     



SEH> The BND documentation¹ states that a Service-Component reference with a
SEH> lowercase name provokes a bean-style "set" method to be mentioned in
SEH> the generated XML resource:

SEH> ,----[ Service-Component Header section ]
SEH> | In that case the reference is augmented with a set<Name> method
SEH> | according to the standard bean rules. An unset<Name> method is added
SEH> | when the name appears in the list that is given to the dynamic
SEH> | directive.
SEH> `----

SEH> Note the second sentence, which says that a corresponding "unset"
SEH> method will be mentioned if the reference is noted as being of
SEH> "dynamic" policy.

SEH> Later the document states that the default policy is "static":

SEH> ,----
SEH> | The defaults are therefore aligned with the SCR: a cardinality of
SEH> | 1..1, and static policy.
SEH> `----

SEH> However, I notice that with a maven-bundle-plugin directive like this:

SEH>   <Service-Component>com.foo.impl.BarImpl;
SEH>                      provide:=com.foo.Bar;
SEH>                      quux=com.foo.Quux</Service-Component>

SEH> The resulting OSGI-INF/com.foo.impl.BarImpl.xml file contains a
SEH> "reference" element like so:

SEH>     <reference name='quux'
SEH>                interface='com.foo.Quux'
SEH>                bind='setQuux'
SEH>                unbind='unsetQuux'/>

SEH> Note the presence of the "unbind" attribute. This conflicts with the
SEH> documentation above that states that the unbind method will only be
SEH> mentioned for "dynamic" policies.

SEH> Am I missing something, or is this a bug in BND?


SEH> Footnotes: 
SEH> ¹ http://www.aqute.biz/Code/Bnd



-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599