Hi everyone,
I'm back with my issue for an erratum: the solution I provided does not
completely work. When I use:
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE)
private List<FileReaderService> availableServices;
Only one of the file reader services is inserted in the list. Output of
the code is:
Reading: test.txt
null
Reading: test.properties
[key6=value6, key5=value5, key4=value4]
However, when using:
@Reference(cardinality = ReferenceCardinality.MULTIPLE)
private List<MeshReader> availableServices;
The output is correct:
Reading: test.txt
[key1 value1, key2 value2, key3 value3]
Reading: test.properties
[key6=value6, key5=value5, key4=value4]
Any idea why? Is this a bug or a feature?
Kind regards,
Ben
Le 14.01.2016 15:53, b...@petinou.fr a écrit :
Hi David,
By looking in Felix SCR source code I found the lines causing the
exception:
// field value type
if ( !m_isMultiple )
{
// value type must not be specified for unary references
if ( m_field_collection_type != null )
{
throw componentMetadata.validationFailure( "Field value type
must not be set for unary field references." );
}
}
It seems Felix SCR is not happy because the attribute
m_field_collection_type is set to "service" in the component XML (i.e.
not null), while no cardinality is specified...
I thus changed my annotation like this:
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE)
private List<FileReaderService> availableServices;
I also added a factory service consumer in order to test the
application and it works!
For those interested, the fixed source code is available here:
https://github.com/neopium/FileReader
Kind regards,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org