java - Multithreaded bundle and service instances -


assume have 3 bundles a, b , b1. bundle a starting point of application. bundle b provides api of service used a. bundle b1 implementation of service.

basically, bundle a has set of records processes 1 after other. there no order processing records.

i improve performance of application processing subsets of records concurrently.

i thought 2 different ways: multiple instances of bundle and, bundle multiple threads.

afaik, not possible add multiple instances of same bundle (i.e. same osgi identity) in osgi container.

regarding second possibility, each thread created bundle a have own identity. , service exported b1 needs know identity of thread uses it. thus, thought servicefactoy fit here. however, i've read once service instance obtained bundle, cached. therefore, threads same service instance.

am right? if yes, "right way" implement model? feel free propose me different approach more osgi friendly.

thanks, mickael


edit:

another possibility modify service interface allow service's consumers pass identity service. service become "stateless" , use of servicefactory not required. however, fact identity required implementation detail (i.e. required specific implementation), therefore future implementations, parameters added interface not used. why prefer not touch interface.

the "right way" in osgi provide service stateless.

as have discovered, servicefactory concept not you, differentiates between invoking bundles, not threads, contexts or else can container state.

if service must keep track of state, best way make explicit , provide kind of parameter pass state. rfc balazs mentions option in future (provided makes specification).


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -