Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[osgi-users] Question on interacting with PROTOTYPE scoped components from an external actor

Dear all,

 

In an interesting thread on JAX-RS Whiteboard, Ray commented:

 

 

PROTOTYPE scopes is intended to align with those cases where unique instances are needed, where the instance might keep state and/or be modified (injection in this case) by an external actor along an axis which OSGi does not have insight into or control over (e.g. like DS).

 

For example, JAX-RS implementations would normally only know the classname of the resource and do a _new_ to get an instance _on demande_ then do some things like injection or proxy and then execute it and then throw away the instance at the end of the request. So the vehicle to protect against that usage in OSGi is to implement the "production" of these instances using PROTOTYPE scope.

 

HTH,

- Ray

 

This touches on a situation we've often encountered before: how to interact with a DS component from something that is not an OSGi component?

Typical developer-decision is then to introduce some static setInstance/getInstance methods somewhere where the DS component registers itself when activated.

Which of course only works for singleton components.

 

For PROTOTYPE it appears the DS infrastructure is able to understand when a new instance is needed and/or there is some facility somewhere in DS to allow an external actor to ask for a new component creation and get a reference to it to inject/interact with it. Is this the case and if so could you point me to some info about this?

 

Or do I misunderstand the above and is the only standard approach always to have a consumer component with ReferenceScope.PROTOTYPE_REQUIRED in the @Reference?

 

Many thanks,

erwin

 

_______________________________________________
osgi-users mailing list
osgi-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/osgi-users

Back to the top