use of org.apache.camel.catalog.CollectionStringBuffer in project camel by apache.
the class ConnectorCatalogNexusRepository method addCustomCamelConnectorFromArtifact.
/**
* Adds any discovered third party Camel connectors from the artifact.
*/
private void addCustomCamelConnectorFromArtifact(NexusArtifactDto dto, URL jarUrl) {
try (URLClassLoader classLoader = new URLClassLoader(new URL[] { jarUrl })) {
String[] json = loadConnectorJSonSchema(classLoader);
if (json != null) {
ObjectMapper mapper = new ObjectMapper();
JsonNode tree = mapper.readTree(json[0]);
String name = tree.get("name").textValue();
String scheme = tree.get("scheme").textValue();
String javaType = tree.get("javaType").textValue();
String description = tree.get("description").textValue();
Iterator<JsonNode> it = tree.withArray("labels").iterator();
CollectionStringBuffer csb = new CollectionStringBuffer(",");
while (it.hasNext()) {
String text = it.next().textValue();
csb.append(text);
}
addConnector(dto, name, scheme, javaType, description, csb.toString(), json[0], json[1], json[2]);
}
} catch (IOException e) {
log.warn("Error scanning JAR for custom Camel components", e);
}
}
use of org.apache.camel.catalog.CollectionStringBuffer in project camel by apache.
the class DefaultMavenArtifactProvider method scanCamelConnectors.
protected void scanCamelConnectors(CamelConnectorCatalog camelConnectorCatalog, ClassLoader classLoader, String groupId, String artifactId, String version, Set<String> names) {
String[] json = loadJSonSchemas(classLoader);
if (json != null) {
if (!camelConnectorCatalog.hasConnector(groupId, artifactId, version)) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode tree = mapper.readTree(json[0]);
String name = tree.get("name").textValue();
String scheme = tree.get("scheme").textValue();
String javaType = tree.get("javaType").textValue();
String description = tree.get("description").textValue();
Iterator<JsonNode> it = tree.withArray("labels").iterator();
CollectionStringBuffer csb = new CollectionStringBuffer(",");
while (it.hasNext()) {
String text = it.next().textValue();
csb.append(text);
}
LOG.debug("Adding connector: {} with scheme: {}", name, scheme);
camelConnectorCatalog.addConnector(groupId, artifactId, version, name, scheme, javaType, description, csb.toString(), json[0], json[1], json[2]);
names.add(name);
} catch (Throwable e) {
LOG.warn("Error parsing Connector JSon due " + e.getMessage(), e);
}
}
}
}
Aggregations