Peter, hello
1) I have a factory component question, if I may:
re : http://www.osgi.org/download/r4v42/r4.enterprise.pdf
112.2.4 Factory Component
SCR must register a Component Factory service on behalf of the component as soon as the component factory is satisfied. The service properties must be:
• component.name – The name of the component.
• component.factory – The factory identifier.
The service properties of the Component Factory service must not include the component properties
2) why the decision "must NOT include the component properties" was made and can it be undone?
I need these properties, and I do get them, but to get them,
I need to jump through quite a few hoops, and I keep asking myself - why? :-)
here is the specific example I want to have it in DS:
https://gist.github.com/3608800
Thank you,
Andrei
I've noticed that there's significantly more documentation present in the Wiki than the published static site.For example look here: https://cwiki.apache.org/confluence/display/ACE/User+DocumentationIt seems that you should be able to drop "mangement agent bundle" into, say, Glasssfish or JBoss 7+ and have it connect to a provisioning server to pull application bundles from there. I haven't tried that though. Did you try asking on the ace-users list? The devs seem to be a friendly bunch.
@Reference( //target = "(component.factory=bench.*)", //cardinality = ReferenceCardinality.MULTIPLE, //policy = ReferencePolicy.DYNAMIC //)protected void bind(final Compon entFactory s,final Map<String, Object> props)
3) simple way to "unconfuse" would be to clarify this in the osgi spec
and provide one simple use case on www.osgi.org or osgi wiki;
currently missing topic there: "DS + ComponentFactory"
4) same applies to "DS + ConfigAdmin"
@Reference( //target = "(component.factory=bench.*)", //cardinality = ReferenceCardinality.MULTIPLE, //policy = ReferencePolicy.DYNAMIC //)protected void bind(final Compon entFactory s, final Map<String, Object> props)
protected void bind(final ComponentFactory s, final Map<String, Object> props)
@Reference( //target = "(component.factory=bench.*)", //cardinality = ReferenceCardinality.MULTIPLE, //policy = ReferencePolicy.DYNAMIC //)protected void bind(final Compon entFactory s, final Map<String, Object> props)
protected void bind(final ComponentFactory s, final Map<String, Object> props)
If it included the service properties the factory would be confused with the instances. The instances will have the service properties (and parameter properties).
posted 6 months ago • 76 votes
On Sep 12, 2012, at 16:39 , Andrei Pozolotin <andrei.p...@gmail.com> wrote:
BJ:
yes, book example is great, but does not answer my major complaint (see below):
------------------
6) specific problem is that [ target = "(component.factory=bench.*)" ] filter
is a very crude/static tool to collect appropriate ComponentFactory injections in the "factory manager";"
------------------
this is just one of few scenarios I can not do with ComponentFactory due to $ 112.2.4 limitation;
one more example you replied to already:
http://floriansblog.wordpress.com/category/osgi-3/
So more properties to describe the factory (besides the component.factory property whose value you get to set) is somehow less crude and less static?
How is 2 or n properties on the ComponentFactory service more useful than just 1? You can cram a lot of information in the 1 property.
As for static-ness, you don't have access to the ComponentFactory service to be able to alter its properties once the ComponentFactory service is registered by DS. So even if you could set more than one property, you could not change it dynamically.
DS is not designed to solve all service problems. It hopefully addresses the most common use cases of using OSGi services. But we understood that very special/complicated use cases will require the use of the service API.
--
BJ
The problems still contrived but I think I understand the point. The thing is that I do not think this is the optimal approach to this class of problems. The key rationale for services is that the provider can offer an implementation of a contract (the service interface) allowing the consumer of the contract to be completely oblivious of the provider, linking the two dynamically when they are hosted in the same system.
For a given problem this connection should only be made once, however in the blog the author wants to do the dynamic linking for each domain object. In my experience, it is much better to register single ShapeFactory service with createCircle, etc, than to try to instantiate each shape separately. A few years ago I tried to come up with a general model for this factory problem but in the end concluded that registering a service that's a factory makes a lot more sense. Suddenly you get all the type safety of the language and the corresponding IDE support. All these goodies are absent when you have to use the ComponentFactory.
In the case of Vaadin the component factory makes sense to give you a ShapeFactory because you need to maintain them by session, however, there is no need I think to have that overhead for each shape. Once you have a ShapeFactory bound to the session you're ok.
Peter Kriens
Sent from my iPad