Вопрос

I have created a small sample project to have a reference implementation of OSGi with Spring (i.e. Blueprint), and I can get all bundles to install, resolve and start OK, but my service is not registered when the bundle starts.

I've made the entire project available on github so you can take a look at the source - the jars output from the build are in the artifacts folder, but you can also build the project yourself by running gradle assemble.

As I've understood the Blueprint specification, and particularly this guide, there is no need for an activator class to register the services if the configuration files are in the right place - in my jar, I have the following under OSGI-INF/blueprint/sillyservice.xml:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <bean id="sillyService" class="se.sunstone.silly.service.ServiceImpl"
        init-method="startService">
    </bean>

    <service ref="helloservice"
        interface="com.sample.blueprint.helloworld.api.HelloWorldService" />
</blueprint>

When deploying this bundle, JBoss reports the bundle as ACTIVE.

When I then deploy the client bundle, there is an activator class that runs the following snippet to list all registered services:

ServiceReference[] refs = context.getAllServiceReferences(null, null);
if (refs != null) {
    logger.info(String.format("There are %s references", refs.length));

    for (ServiceReference ref : refs) {
        logger.info(ref);
    }
} else {
    logger.info("There are no registered services.");
}

A bunch of services that are registered by the OSGi framework inside JBoss are listed, but not my SillyService.

What do I need to do to make this work?

Это было полезно?

Решение

To enable Blueprint functionality, you need to install a Blueprint Extender bundle. There are two implementations available: Apache Aries and Eclipse Gemini. I recommend Aries, which is available from http://aries.apache.org/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top