use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConvertUtil method convertConnectorClass.
public static IcConnectorInfo convertConnectorClass(IcConnectorClass connectorAnnotation, Class<? extends IcConnector> clazz) {
IcConnectorKey key = new IcConnectorKeyImpl(connectorAnnotation.framework(), clazz.getName(), connectorAnnotation.version(), connectorAnnotation.name());
IcConnectorInfo info = new IcConnectorInfoImpl(MessageFormat.format("{0} {1}", connectorAnnotation.displayName(), connectorAnnotation.version()), connectorAnnotation.framework(), key);
return info;
}
use of eu.bcvsolutions.idm.ic.api.IcConnectorInfo in project CzechIdMng by bcvsolutions.
the class CzechIdMIcConfigurationService method getAvailableLocalConnectors.
/**
* Return available local connectors for this IC implementation
*
* @return
*/
@SuppressWarnings("unchecked")
@Override
public Set<IcConnectorInfo> getAvailableLocalConnectors() {
if (connectorInfos == null) {
connectorInfos = new HashSet<>();
connectorsConfigurations = new HashMap<>();
connectorsClass = new HashMap<>();
List<Class<?>> annotated = new ArrayList<>();
// Find all class with annotation IcConnectorClass under specific
// packages
localConnectorsPackages.forEach(packageWithConnectors -> {
Reflections reflections = new Reflections(packageWithConnectors);
annotated.addAll(reflections.getTypesAnnotatedWith(IcConnectorClass.class));
});
LOG.info(MessageFormat.format("Found annotated classes with IcConnectorClass [{0}]", annotated));
for (Class<?> clazz : annotated) {
IcConnectorClass connectorAnnotation = clazz.getAnnotation(IcConnectorClass.class);
if (!this.getFramework().equals(connectorAnnotation.framework())) {
continue;
}
if (!IcConnector.class.isAssignableFrom(clazz)) {
throw new IcException(MessageFormat.format("Cannot create instance of CzechIdM connector [{0}]! Connector class must be child of [{0}]!", IcConnector.class.getSimpleName()));
}
IcConnectorInfo info = CzechIdMIcConvertUtil.convertConnectorClass(connectorAnnotation, (Class<? extends IcConnector>) clazz);
Class<? extends ConfigurationClass> configurationClass = connectorAnnotation.configurationClass();
connectorInfos.add(info);
IcConnectorConfiguration configuration = initDefaultConfiguration(configurationClass);
// Put default configuration to cache
connectorsConfigurations.put(info.getConnectorKey().getFullName(), configuration);
// Put connector class to cache
connectorsClass.put(info.getConnectorKey().getFullName(), ((Class<? extends IcConnector>) clazz));
}
LOG.info(MessageFormat.format("Found all local connector connectorInfos [{0}]", connectorInfos.toString()));
}
return connectorInfos;
}
Aggregations