If I'm correct this will get the behavior I'm after with any cfg file
associated with org.apache.cxf.bus-*.cfg triggering this. 

This seems to work correctly but is a rather different design than what I'd
envisioned but that may only be due to older understanding of services,
managed service factories, trackers, etc. It appears that I don't need that
really. Any org.apache.cxf.bus-*.cfg file will trigger the creation of a new
component and service.  And the update works correctly from what I can see.

In karaf, when I type the cxf:list-busses I see a bus per cfg file. If I do
something like change the id in the cfg file, I see that reflect in the
cxf:list-busses. 

This also means I can use an @Reference with id= filter to inject the Bus
interface into the correct location and then use that to instantiate CXF
components per the example DS code that JB put up.

It's possible I'm missing something here however as I have a lot more
experience with Blueprint and even regular Java activator based OSGi and
less with DS. 

The plugins implement an interface with a single method of init(Bus,
Map<String,Object>).  So each is testable independently.




@Component(
                service = Bus.class,
                configurationPid = "org.apache.cxf.bus"
                          
)
public class StandardBus extends ExtensionManagerBus implements Bus{

        public StandardBus() {
                super(null, null, StandardBus.class.getClassLoader());
    } 

    private List<BusConfiguratorPlugin> plugins = new
ArrayList<BusConfiguratorPlugin>();

    private void initPlugins() {
                // TODO Could take package/class list from the cfg associated 
with this
factory.
                plugins.add(new BusIdentifierPlugin());
                plugins.add(new LoggingBusConfiguratorPlugin());
                // TODO Add plugins for JAASAuthenticationFeature and others as 
needed..

        }
        


        @Activate
        public void init(Map<String, Object> properties) {
                initPlugins();
                init(this,properties);
        }
        @Modified
    public void modified(Map<String, Object> properties) {
        init(this,properties);
    }
 
    @Deactivate
    public void deactivate() {
        
    }
    
    private void init(Bus bus,Map<String, Object> properties) {
        plugins.forEach((plugin) -> plugin.init(bus, properties));
    }
   
}




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply via email to