当前位置: 首页>>代码示例>>Java>>正文


Java Handler类代码示例

本文整理汇总了Java中org.apache.camel.Handler的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Handler类属于org.apache.camel包,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(EventData eventData) {
  try {
    EventGenerator eg = EventGeneratorFactory.getEventGenerator(eventData.domainId,
        eventData.objectType);
    if(eventData.eventId == IEvent.DELETED) {
      DomainConfig dc = DomainConfig.getInstance(eventData.domainId);
      eg.generateDeleteEvent(eg, eventData.eventObject, eventData.objectId, dc.getLocale(), dc.getTimezone(), eventData.params);
    } else {
      eg.generate(eventData.eventId, eventData.params, eventData.objectId,
          eventData.customOptions);
    }
  } catch (Exception e) {
    log.severe("Issue with submitted task {0} with error {1}", eventData, e.getMessage(), e);
    throw new RuntimeException(e);
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:18,代码来源:EventProcessor.java

示例2: enhanceMessage

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public String enhanceMessage( String body,  Exchange exchange  ) {
	
	String[] topicParts = exchange.getIn().getHeader("CamelMQTTSubscribeTopic", String.class).split(TOPIC_SEPARTOR);

	if(topicParts.length != 4) {
		throw new IllegalArgumentException("Invalid number of topic components. Expected " + TOPIC_PART_SIZE + ". Was " + topicParts.length);
	}
	
	StringBuilder sb = new StringBuilder();
	sb.append(body);
	sb.append(COMMA);
	sb.append(topicParts[1]);
	sb.append(COMMA);
	sb.append(topicParts[2]);
	sb.append(COMMA);
	sb.append(topicParts[3]);
	
	return sb.toString();
}
 
开发者ID:sabre1041,项目名称:iot-ocp,代码行数:21,代码来源:MyHelper.java

示例3: processCsv

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void processCsv(Exchange exchange) {
    // We assume Camel CSV is used beforehand to set the body to a List<List<String>>
    @SuppressWarnings("unchecked")
    List<List<String>> list = (List<List<String>>) exchange.getIn().getBody();

    List<String> tokens = list.get(0);

    // Build up a model for Velocity to use
    Map<String, Object> model = new HashMap<String, Object>();

    String[] nameParts = tokens.get(0).split(" ");
    model.put("firstName", nameParts[0]);
    model.put("lastName", nameParts[1]);
    model.put("birthDate", tokens.get(1));

    exchange.getIn().setBody(model);

    // Set the header required by ml-xcc for ingestion
    exchange.getIn().setHeader("MlXccUri", tokens.get(0) + ".xml");
}
 
开发者ID:rjrudin,项目名称:ml-camel-client,代码行数:22,代码来源:CsvProcessor.java

示例4: fetch

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public FetchData fetch(ScrapeTemplate template,
                  Map<String, Object> actualParams) {
    LowerEnumSerializer.LOWER = false;
    final String uri = template.getUri();
    log.info("Fetching {} {} {} ...", template.getProtocol(), template.getProtocolVersion(),
            template.getUri());
    try {
        // FIXME: Use Retryer (with limit) when: Caused by: java.net.SocketException: Connection reset
        // at java.net.SocketInputStream.read(SocketInputStream.java:209)

        switch (template.getProtocol()) {
            case JSONRPC:
                return fetchJsonRpc(uri, template, actualParams);
            case HTTP:
                throw new UnsupportedOperationException("no HTTP support yet");
            default:
                throw new UnsupportedOperationException("Unsupported protocol: " + template.getProtocol());
        }
    } catch (Exception e) {
        throw new ScrapeException(e, "Cannot fetch %s", uri);
    }
}
 
开发者ID:soluvas,项目名称:soluvas-scrape,代码行数:24,代码来源:Fetcher.java

示例5: getDsMetaData

import org.apache.camel.Handler; //导入依赖的package包/类
/**
 * Return a {@link DsMetaData} response.
 * 
 * @param inputString
 *            input message body
 * @return meta data XML entity instance
 */
@Handler
@InOnly
public DsMetaData getDsMetaData(final String inputString)
{
	if (log.isDebugEnabled())
	{
		log.debug(getDataSourcePrefix() + "getDsMetaData()");
		// " inputString "
		// + inputString);
	}

	// For test assertion simplicity, the name field below does not depend on
	// the input string. Only the description field does.
	return new DsMetaData(name, name + ": " + inputString);
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:23,代码来源:DataSourceMock.java

示例6: lastFileProcessed

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public boolean lastFileProcessed(Exchange exchange) throws Exception {
    FileEntryWorkNote workNote = exchange.getIn().getBody(FileEntryWorkNote.class);

    String batchJobId = workNote.getBatchJobId();
    TenantContext.setJobId(batchJobId);

    if (batchJobDAO.updateFileEntryLatch(workNote.getBatchJobId(), workNote.getFileEntry().getFileName())) {

        RangedWorkNote wn = RangedWorkNote.createSimpleWorkNote(batchJobId);
        exchange.getIn().setBody(wn, RangedWorkNote.class);
        return true;

    }
    
    return false;
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:FileEntryLatch.java

示例7: processCommand

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void processCommand(Exchange exch) throws Exception {
    String command = exch.getIn().getBody().toString();
    LOG.info("Received: " + command);
    String[] chunks = command.split("\\|");

    if (JOB_COMPLETED.equals(chunks[0])) {

        LOG.info("Clearing cache at job completion.");


        dumpAspectTrackers(chunks);

    } else {
        LOG.error("Unsupported command");
    }
}
 
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:CommandProcessor.java

示例8: getRetweetsWithScreenNames

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public List<String> getRetweetsWithScreenNames(@Header("statusId") Long statusId)
		throws TwitterException {
	return twitter.getRetweets(statusId).stream()
			.map(tweet -> tweet.getUser().getScreenName())
			.collect(Collectors.toList());
}
 
开发者ID:donovanmuller,项目名称:camel-twitter-stream,代码行数:8,代码来源:RetweetService.java

示例9: log

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void log(@Body Object body){
    if(trace) {
        LOGGER.trace("Body is: {}",body);
    } else {
        LOGGER.info("Body is: {}",body);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:9,代码来源:__extension-name__Extension.java

示例10: execute

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(TaskOptions taskOptions) {
  jmsMeter.mark();
  log.info("Submitting task with parameter{0}", taskOptions);
  //localQueue.add(taskOptions);
  Task simpleTask = new SimpleTask(taskOptions);
  try {
    ((Runnable) simpleTask).run();
  } catch (Exception e) {
    log.severe("Issue with submitted task {0} with error {1}", taskOptions, e.getMessage(), e);
    throw e;
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:14,代码来源:JMSTaskProcessor.java

示例11: execute

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void execute(AssetStatusRequest assetStatusRequest) throws ServiceException {

  jmsMeter.mark();

  List<AssetStatusModel> assetStatusModelList = assetStatusRequest.data;
  if (assetStatusModelList != null && !assetStatusModelList.isEmpty()) {
    AssetManagementService assetManagementService = Services
        .getService(AssetManagementServiceImpl.class);
    assetManagementService
        .updateAssetStatus(build(assetStatusModelList, assetManagementService));

  }

}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:16,代码来源:AssetAlarmsMessagingProcessor.java

示例12: process

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void process(@XPath("//title") String title,
                    @XPath("//description") String description,
                    @XPath("//pubDate") String pubDate,
                    @XPath("//link") String link) {
  ZonedDateTime published = ZonedDateTime.parse(pubDate, DateTimeFormatter.RFC_1123_DATE_TIME);
  if (ChronoUnit.MINUTES.between(published,
      ZonedDateTime.now()) <= threshold) {
    bus.broadcast(parser.parse(description, title, link))
        .as("status.redhat");
  }
}
 
开发者ID:devnull-tools,项目名称:boteco,代码行数:13,代码来源:StatusRssProcessor.java

示例13: throwNonBpmnException

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void throwNonBpmnException() throws Exception {
    LOGGER.debug("throwing non bpmn bug");

    switch (getExceptionType()) {
    case NO_EXCEPTION:
        break;
    case NON_BPMN_EXCEPTION:
        throw new Exception("arbitrary non bpmn exception");
    case BPMN_EXCEPTION:
        throw new BpmnError("testError");
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:14,代码来源:ThrowBpmnExceptionBean.java

示例14: handler

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public void handler(@XPath("//response/text()") String response,
                    @XPath(headerName = "invoiceDetails", value = "//invoice/person/name/text()") String userName,
                    @XPath(headerName = "invoiceDetails", value = "//invoice/person/date", resultType = String.class) String date) {
    this.response = response;
    this.userName = userName;
    this.date = date;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:BeanWithXPathInjectionUsingHeaderValueTest.java

示例15: consume

import org.apache.camel.Handler; //导入依赖的package包/类
@Handler
public String consume() {
    StringBuilder result = new StringBuilder();

    Exchange exchange;
    while ((exchange = consumer.receive("activemq:queue", 2000)) != null) {
        result.append(exchange.getIn().getBody(String.class));
    }

    return result.toString();

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:JmsPollingConsumerTest.java


注:本文中的org.apache.camel.Handler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。