https://github.com/apache/karaf/tree/master/examples/karaf-rest-example/karaf-rest-example-scr

I was just checking out this latest example and have to say I like it quite
a bit. One thing I'm trying to focus on is being able to set up more than
one Bus in a bus-centric bundle and then reuse them via injection. It would
seem that this mechanism should permit that if I export the Busses to the
registry with a JNDI filter name and then inject it here instead of using
the BusFactory.getDefaultBus()

Would this be on the right track? I know that with Hibernate and PAX JDBC I
have to set a "capability" statement in the features file but that may be
because of Hibernate and PAX JDBC interoperation and be unnecessary in this
case. If I set up the Busses and use an @Service with a name. I'm a bit
uncertain though about the Service/Refence syntax that would be correct. 

        <capability>

osgi.service;effective:=active;objectClass=javax.sql.DataSource;osgi.jndi.service.name=jdbc/fooDS
        </capability>


@Component
public class RestService {

@Reference(target = "(&(objectclass=org.cxf.Bus)(bus.name=foo))"))
Bus bus;
    @Activate
    public void activate() throws Exception {
        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
        bean.setAddress("/booking");
       // bean.setBus(BusFactory.getDefaultBus());
bean.setBus(bus);
       // Providers, interceptors set up in Bus bundle...
       // bean.setProvider(new JacksonJsonProvider());
        bean.setServiceBean(new BookingServiceRest());
        bean.create();
    }

}





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

Reply via email to