java - OSGI: DS and component factories issues -


what need new instance of service every time when consumer needs service + using cdi. i've read lot of articles , can't find answer 2 questions.

  1. if use factories, why in service consumer call factory (http://www.rpgnextgen.com/wiki/doku.php?id=component_factory ) , after reference service. mean

    // factory componentfactory factory = (componentfactory) context.getservice(servicereferences[0]); // instance componentinstance instance = factory.newinstance(null); 

is there no way set factory interface , in service consumer call service when osgi inside calls factory?

  1. if in service consumer call factory why mark service component when de facto factory component?

the problem without factory @inject @osgiservice (javase) or@osgiservice (javaee) , can use different filters , code clear. using component factory (as understand) loose ability.

componentfactory exists consumers want use factory, because want control lifecycle of individual components. example, if want create instance of component every web request.

if don't want use componentfactory... don't.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -