org.apache.camel.util.IntrospectionSupport Java Examples

The following examples show how to use org.apache.camel.util.IntrospectionSupport. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitiComponent.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: FlowableComponent.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: AbstractHiWorldTestSupport.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #4
Source File: CamelEditNodeXmlCommand.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
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);
        }
    }
}