Hi, Andrea Zoppello schrieb: > Hi all, > > I want to have a DS Component Factories that will be able to create > different instances of my > component. > > My component class implement the EventHandler interface, so it will > receive event notification by > Event Admin Service. > > An example of one of my component factory is this one: > <?xml version="1.0" encoding="UTF-8"?> > <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" > name="org.my.components.mycomponentFactory" > factory="my.mycomponent"> > <implementation class="org.my.components.MyComponent"/> > <service> > <provide interface="org.osgi.service.cm.ManagedService"/> > <provide interface="org.osgi.service.event.EventHandler"/> > </service> > > </scr:component>
First: You don't want to register your component as a ManagedService because the Declarative Services implementation will grab configurations on behalf of the component and provided the configuration to the components. > > As i've learn an Event Handler could specify a topic filter with the > property: "event.topics or EventConstants.EVENT TOPIC" > > My problem is that i want my components will subscribe to different > topics according to a value that i set in the > properties when i'll call ComponentFactory.newInstance. > > For example if in my properties there a topic id i want my component > generatye with the factory to subscribe to something like: > > BASE_TOPIC/TOPI_ID > > It's enough to create the property "event.topics or EventConstants.EVENT > TOPIC" with the right value before calling the newInstance method > or i need additional step??. Nothing more needed, I would say, because the properties you hand to the newInstance method should also be used as service registration properties. Regards Felix > > Thanks > > Andrea Zoppello > > > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev > _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
