0

I have the following service class:

@Component(immediate = true)
@Service
public class Myclass implements MyInterface
{
    @Override
    public String doIt()
    {
        return "This is default bean";
    }
}

In pom file I have:

<dependency>
    <groupId>org.apache.felix</groupId>
    <artifactId>org.apache.felix.scr.annotations</artifactId>
    <version>1.9.6</version>
    <scope>provided</scope>
</dependency>
...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.4.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <_include>
                        -target/classes/META-INF/beans.bnd
                    </_include>
                    <Export-Package></Export-Package>
                    <Private-Package>com.company.temp.*</Private-Package>
                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-scr-plugin</artifactId>
            <version>1.21.0</version>
            <executions>
                <execution>
                    <id>generate-scr-scrdescriptor</id>
                    <goals>
                        <goal>scr</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    <plugins>
</build>

The problem is xml file for DS is not generated. Besides, there is no Service-Component line in manifest file. Where is my mistake (PS java8)?

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
Pavel_K
  • 10,748
  • 13
  • 73
  • 186

1 Answers1

1

In case you are planning to use the standard DS annotations (not the felix ones). Then simply use the config below.

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.5.4</version>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <_dsannotations>*</_dsannotations>
        </instructions>
    </configuration>
</plugin>

I also have a DS tutorial if you need a complete example.

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Thank you. It did the trick. As always... one small line of code. Could you explain what is Blueprint? I can't understand how to translate this word to my native language. – Pavel_K Jul 10 '15 at 12:30
  • Blueprint is another dependency injection framework for OSGi. It is derived from the spring syntax and quite similar to it. You can find some examples for it in my other tutorials. – Christian Schneider Jul 10 '15 at 12:33
  • Could you say - what is the right method to add properties to @Component? when I do `@Component(immediate = false,properties = {"name=stub"})` or `@Component(immediate = false,properties = {"stub"})` I get felix xml entry parser exception. – Pavel_K Jul 10 '15 at 12:57
  • I got an example in my tutorial: property="osgi.remote.interfaces:String=*" – Christian Schneider Jul 10 '15 at 13:05
  • Thank you. I tried @Component(immediate = false,properties = {"name:String=stub"}) but have thre same problem. – Pavel_K Jul 10 '15 at 13:41