I am trying to deploy an iPojo bundle with a property. The bundle looks like this:
@Component
public class Greeter {
@Property(name = "greeting")
private String greeting;
@Validate
public void start() {
System.out.println(greeting);
}
}
The pom.xml looks like this:
<groupId>com.example.my</groupId>
<artifactId>osgi-greeter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.annotations</artifactId>
<version>1.12.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- BND Maven Plugin Configuration -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<!--<Private-Package>$YOUR_PRIVATE_PACKAGE</Private-Package> <Export-Package>$YOUR_EXPORTED_PACKAGE</Export-Package> -->
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
<version>1.12.1</version>
<executions>
<execution>
<goals>
<goal>ipojo-bundle</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am using Apache Felix as OSGi runtime. I added the fileinstall bundle and configured its path. To the path I added the osgi-greeter bundle and a configuration file named com.example.my.Greeter.cfg looking like this:
greeting = Hello World
I turned on the debug log of Felix and can see, that the fileinstall bundle is loaded with its parameters. However, it is not doing anything. I can install and start the bundle manually, however it obviously only outputs null to the console. The goal would be to add multiple configuration files and let fileinstall start the instances from them. Any ideas how to achieve that or what I can do to make fileinstall work that way?
I managed to fix it. Basically, I added multiple configuration files to the watched fileinstall folder named:
I think the instance identifier after the class name was simply needed here in the file name to make it work.