I am using scr annotations in my project. Can anybody explain the usecase of metatype attribute in @Component annotation?
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
@Component (name = "SampleComponent", label = "TestLabel", description = "This is a test application", ds = true, immediate = false, metatype = true, factory = "com.java.test.sampleComponent")
@Service
As stated in the documentation for Felix SCR Annotations: "If this parameter is set to true Metatype Service data is generated in the metatype.xml file for this component. Otherwise no Metatype Service data is generated for this component."
Metatype data can be used by administrative systems or GUIs such as Felix Web Console to present a much more helpful way to configure your component.
I think you should always turn this flag on, since it may be useful in the future, and has basically zero cost even if you never use it.
By the way you should probably stop using the Felix SCR annotations since they are being phased out in favour of the standard DS annotations from OSGi. See section 112.8 of the OSGi Compendium specification (release 5 or later) for details.