in atomos.utils/atomos.utils.core/src/main/java/org/apache/felix/atomos/utils/core/plugins/ComponentDescriptionPlugin.java [30:118]
public void doComponentMetaData(ComponentDescription c, Context context,
ClassLoader classLoader)
{
Class<?> clazz;
try
{
clazz = classLoader.loadClass(c.implementationClass());
// Activate Deactivate Modify
Optional.ofNullable(c.activate()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
Optional.ofNullable(c.modified()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
Optional.ofNullable(c.deactivate()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
if (c.activationFields() != null)
{
for (String fName : c.activationFields())
{
context.addReflectionField(fName, clazz);
}
}
//Reference
String[] constrParams = new String[c.numberOfConstructorParameters()];
if (c.references() != null && !c.references().isEmpty())
{
for (ReferenceDescription r : c.references())
{
Optional.ofNullable(r.parameter()).ifPresent(
(i) -> constrParams[i] = r.interfaceName());
Optional.ofNullable(r.field()).ifPresent(
(f) -> context.addReflectionField(f, clazz));
Optional.ofNullable(r.bind()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
Optional.ofNullable(r.updated()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
Optional.ofNullable(r.unbind()).ifPresent(
(m) -> context.addReflectionMethod(m, clazz));
Optional.ofNullable(r.interfaceName()).ifPresent(
(i) -> context.addReflectionClass(i));
}
}
boolean foundConstructor = false;
if (c.numberOfConstructorParameters() == 0)
{
context.addReflectionConstructorDefault(clazz);
foundConstructor = true;
}
else
{
for (Constructor<?> constructor : clazz.getConstructors())
{
if (constructor.getParameterCount() != c.numberOfConstructorParameters())
{
continue;
}
boolean match = true;
for (int j = 0; j < constructor.getParameterCount(); j++)
{
String p = constructor.getParameters()[j].getType().getName();
String s = constrParams[j];
if (s != null && !p.equals(s))
{
match = false;
break;
}
}
if (match)
{
String[] ps = Stream.of(constructor.getParameters()).map(
p -> p.getType().getName()).toArray(String[]::new);
context.addReflectionConstructor(clazz, ps);
foundConstructor = true;
break;
}
}
if (!foundConstructor)
{
context.addReflectionConstructorAllPublic(clazz);
}
}
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}