Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
maven-scr-plugin-1.7.2, maven-scr-plugin-1.7.4
-
None
Description
When maven-scr-plugin processes components that are implemented as nested classes, SCR annotations @Activate @Deactivate @Modified in these nested classes are ignored. Annotations in the outer class are used instead:
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@Component
public class Outer {
@Activate
private void activateOuter() {
}
@Component
public static class Nested1 {
}
@Component
public static class Nested2 {
@Activate
private void activateNested2() {
}
}
}
results in this component description:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
<scr:component enabled="true" name="Outer" activate="activateOuter">
<implementation class="Outer"/>
<property name="service.pid" value="Outer"/>
</scr:component>
<scr:component enabled="true" name="Outer$Nested1" activate="activateOuter">
<implementation class="Outer$Nested1"/>
<property name="service.pid" value="Outer$Nested1"/>
</scr:component>
<scr:component enabled="true" name="Outer$Nested2" activate="activateOuter">
<implementation class="Outer$Nested2"/>
<property name="service.pid" value="Outer$Nested2"/>
</scr:component>
</components>
All components have an activate="activateOuter" attribute. Similar problems occur if the outer class is not a component or does not have an @Activate annotation:
public class Outer {
@Component
public static class Nested {
@Activate
private void activateNested() {
}
}
}
Here the activate attribute is missing:
<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
<scr:component enabled="true" name="Outer$Nested">
<implementation class="Outer$Nested"/>
<property name="service.pid" value="Outer$Nested"/>
</scr:component>
</components>