Java源码示例:org.apache.camel.util.IntrospectionSupport
示例1
@Override
protected Endpoint createEndpoint(String s, String s1, Map<String, Object> parameters) throws Exception {
ActivitiEndpoint ae = new ActivitiEndpoint(s, getCamelContext());
ae.setIdentityService(identityService);
ae.setRuntimeService(runtimeService);
ae.setRepositoryService(repositoryService);
ae.setCopyVariablesToProperties(this.copyVariablesToProperties);
ae.setCopyVariablesToBodyAsMap(this.copyVariablesToBodyAsMap);
ae.setCopyCamelBodyToBody(this.copyCamelBodyToBody);
Map<String, Object> returnVars = IntrospectionSupport.extractProperties(parameters, "var.return.");
if (returnVars != null && returnVars.size() > 0) {
ae.getReturnVarMap().putAll(returnVars);
}
return ae;
}
示例2
@Override
protected Endpoint createEndpoint(String s, String s1, Map<String, Object> parameters) throws Exception {
FlowableEndpoint ae = new FlowableEndpoint(s, getCamelContext());
ae.setIdentityService(identityService);
ae.setRuntimeService(runtimeService);
ae.setRepositoryService(repositoryService);
ae.setManagementService(managementService);
ae.setCopyVariablesToProperties(this.copyVariablesToProperties);
ae.setCopyVariablesToBodyAsMap(this.copyVariablesToBodyAsMap);
ae.setCopyCamelBodyToBody(this.copyCamelBodyToBody);
Map<String, Object> returnVars = IntrospectionSupport.extractProperties(parameters, "var.return.");
if (returnVars != null && returnVars.size() > 0) {
ae.getReturnVarMap().putAll(returnVars);
}
return ae;
}
示例3
@Override
protected CamelContext createCamelContext() throws Exception {
final CamelContext context = super.createCamelContext();
// read HiWorld component configuration from TEST_OPTIONS_PROPERTIES
final Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES));
} catch (Exception e) {
throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()),
e);
}
Map<String, Object> options = new HashMap<String, Object>();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
options.put(entry.getKey().toString(), entry.getValue());
}
final HiWorldConfiguration configuration = new HiWorldConfiguration();
IntrospectionSupport.setProperties(configuration, options);
// add HiWorldComponent to Camel context
final HiWorldComponent component = new HiWorldComponent(context);
component.setConfiguration(configuration);
context.addComponent("hiworld", component);
return context;
}
示例4
private void expressionOptions(String k, ExpressionDefinition exp, Map<String, String> options) {
// special for aggregate as it has naming clash
if ("completionSizeExpression".equals(k)) {
k = "completionSize";
} else if ("completionTimeoutExpression".equals(k)) {
k = "completionTimeout";
}
String text = exp.getExpression();
String lan = exp.getLanguage();
options.put(k, lan);
if (text != null) {
options.put(k + "_value", text);
}
// when using a language as an expression it can contain additional options which we
// cannot build a nice UI in forge as forge is not that dynamic. So instead we have an extra
// input field where we allow users to edit the values using a Camel multivalue uri style with
// key=value&key2=value2 ...
CollectionStringBuffer csb = new CollectionStringBuffer("&");
String json = getCamelCatalog().languageJSonSchema(lan);
if (json != null) {
List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("properties", json, true);
if (data != null) {
for (Map<String, String> map : data) {
String name = map.get("name");
// skip expression/id as we are not interested in those
if (name != null && !"id".equals(name) && !"expression".equals(name)) {
try {
Object value = IntrospectionSupport.getProperty(exp, name);
if (value != null) {
text = value.toString();
csb.append(name + "=" + text);
}
} catch (Exception e) {
// ignore
}
}
}
}
if (!csb.isEmpty()) {
String extra = csb.toString();
options.put(k + "_extra", extra);
}
}
}