本文整理汇总了Java中org.apache.camel.builder.LoggingErrorHandlerBuilder类的典型用法代码示例。如果您正苦于以下问题:Java LoggingErrorHandlerBuilder类的具体用法?Java LoggingErrorHandlerBuilder怎么用?Java LoggingErrorHandlerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoggingErrorHandlerBuilder类属于org.apache.camel.builder包,在下文中一共展示了LoggingErrorHandlerBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final String avatarId = "nao1";
// from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.DATA_BATTERY.key(avatarId) + "&routingKey=" + AvatarChannel.DATA_BATTERY.key(avatarId))
// .sample(1, TimeUnit.SECONDS)
// .to("log:IN." + AvatarChannel.DATA_BATTERY.key(avatarId) + "?showHeaders=true&showAll=true&multiline=true")
// .process(it -> {
// final JsonNode inBodyJson = toJson.getMapper().readTree(it.getIn().getBody(byte[].class));
// final BatteryState batteryState = toJson.getMapper().convertValue(inBodyJson, BatteryState.class);
// final Node nodeResult = new TransactionTemplate(txMgr).execute(tx -> {
// final DateTime now = new DateTime();
// final Map<String, Object> props = new HashMap<String, Object>();
// final Node node = neo4j.createNode(props, ImmutableSet.of("JournalBatteryState"));
// log.debug("Created JournalBatteryState {} from {}", node, props);
// return node;
// });
// it.getOut().setBody(nodeResult.getId());
// })
// .bean(toJson)
// .to("log:OUT." + AvatarChannel.DATA_BATTERY.key(avatarId) + "?showAll=true&multiline=true");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:24,代码来源:JournalBatteryRouter.java
示例2: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
errorHandler(new LoggingErrorHandlerBuilder(log));
from("direct:" + LumenChannel.PERSISTENCE_FACT.key())
.process(exchange -> {
final BeanInvocation invocation = exchange.getIn().getBody(BeanInvocation.class);
final FactRequest factRequest = new FactRequest();
factRequest.setOperation(FactServiceOperation.valueOf(invocation.getMethod().getName()));
log.info("Invoking {} {}", invocation.getMethod(), invocation.getArgs());
for (int i = 0; i < invocation.getArgs().length; i++) {
final String simpleExpr = invocation.getMethod().getParameters()[i].getAnnotation(Simple.class).value();
final String paramName = StringUtils.substringAfter(simpleExpr, "body.");
PropertyUtils.setProperty(factRequest, paramName, invocation.getArgs()[i]);
}
exchange.getIn().setBody(factRequest);
exchange.setPattern(ExchangePattern.InOut);
//exchange.getIn().setHeader(RabbitMQConstants.REPLY_TO, );
})
.bean(toJson)
.to("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&skipQueueDeclare=true&routingKey=" +
LumenChannel.PERSISTENCE_FACT.key())
.to("log:REPLY." + LumenChannel.PERSISTENCE_FACT.key());
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:24,代码来源:ServicesRouter.java
示例3: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final int period = 1000;
log.info("robotPose capture timer with period = {}ms", period);
for (final String avatarId : naoConfig.getControllerAvatarIds()) {
final NaoController nao = naoConfig.get(avatarId);
final ALRobotPoseProxy robotPoseProxy = nao.getRobotPose();
from("timer:robotPose?period=" + period)
.process(exchange -> {
final RobotPoseState robotPoseState = new RobotPoseState();
for (int i = 0; i < robotPoseProxy.getPoseNames().getSize(); i++) {
robotPoseState.getPoseNames().add(robotPoseProxy.getPoseNames().getElement(i).toString());
}
robotPoseState.setActualPoseName(robotPoseProxy.getActualPoseAndTime().getElement(0).toString());
robotPoseState.setActualPoseTime(robotPoseProxy.getActualPoseAndTime().getElement(1).toFloat());
exchange.getIn().setBody(robotPoseState);
})
.bean(toJson)
.to("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&skipQueueDeclare=true&routingKey=avatar." + avatarId + ".data.robotpose")
.to("log:" + PoseRouter.class.getName() + "." + avatarId + "?level=TRACE&showAll=true&multiline=true");
}
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:25,代码来源:PoseRouter.java
示例4: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final int period = 1000;
log.info("Battery capture timer with period = {}ms", period);
for (final String avatarId : naoConfig.getControllerAvatarIds()) {
final NaoController nao = naoConfig.get(avatarId);
final ALBatteryProxy batteryProxy = nao.getBattery();
from("timer:battery?period=" + period)
.process(exchange -> {
final BatteryState batteryState = new BatteryState();
batteryState.setPercentage((double) batteryProxy.getBatteryCharge());
batteryState.setDateCreated(new DateTime());
exchange.getIn().setBody(batteryState);
})
.bean(toJson)
.to("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&skipQueueDeclare=true&autoDelete=false&routingKey=avatar." + avatarId + ".data.battery")
.to("log:" + BatteryRouter.class.getName() + "." + avatarId + "?level=TRACE&showAll=true&multiline=true");
}
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:22,代码来源:BatteryRouter.java
示例5: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final int period = 1000;
log.info("Sonar capture timer with period = {}ms", period);
for (final String avatarId : naoConfig.getControllerAvatarIds()) {
final NaoController nao = naoConfig.get(avatarId);
final ALSonarProxy sonarProxy = nao.getSonar();
from("timer:sonar?period=" + period)
.process(exchange -> {
final SonarState sonarState = new SonarState();
// sonarState. setPercentage((double) batteryProxy.getBatteryCharge());
sonarState.setLeftSensor((double) sonarProxy.getCurrentPrecision());
sonarState.setRightSensor((double) sonarProxy.getCurrentPrecision());
// sonarState.setDateCreated(new DateTime());
sonarState.setDateCreated(new DateTime());
exchange.getIn().setBody(sonarState);
})
.bean(toJson)
.to("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&skipQueueDeclare=true&autoDelete=false&routingKey=avatar." + avatarId + ".data.sonar")
.to("log:" + SonarRouter.class.getName() + "." + avatarId + "?level=TRACE&showAll=true&multiline=true");
}
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:25,代码来源:SonarRouter.java
示例6: testCustomErrorHandler
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Test @Ignore
public void testCustomErrorHandler() throws InterruptedException {
final AtomicBoolean fired = new AtomicBoolean();
_camelContext.getWritebleRegistry().put("custom error handler", new LoggingErrorHandlerBuilder() {
@Override
public Processor createErrorHandler(RouteContext routeContext, final Processor processor) {
fired.compareAndSet(false, true);
return super.createErrorHandler(routeContext, processor);
}
});
ServiceReference ref = registerInOutService("inOut", new RuntimeErrorInHandler());
Exchange exchange = sendMessage(ref, TEST_CONTENT);
assertTrue(fired.get());
assertCause("Runtime error", exchange);
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:17,代码来源:CamelExchangeBusTest.java
示例7: create
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public ErrorHandlerBuilder create(CreationalContext<ErrorHandlerBuilder> creationalContext) {
try {
ErrorHandlerBuilder builder = handler.getType().getTypeAsClass().newInstance();
switch (handler.getType()) {
case DefaultErrorHandler:
case DeadLetterChannel:
setProperties((DefaultErrorHandlerBuilder) builder);
break;
case LoggingErrorHandler:
setProperties((LoggingErrorHandlerBuilder) builder);
break;
case NoErrorHandler:
// No configuration required
break;
case TransactionErrorHandler:
break;
}
return builder;
} catch (Exception cause) {
throw new CreationException("Error while creating instance for " + this, cause);
}
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:26,代码来源:XmlErrorHandlerFactoryBean.java
示例8: create
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public ErrorHandlerBuilder create(CreationalContext<ErrorHandlerBuilder> creationalContext) {
try {
ErrorHandlerBuilder builder = handler.getType().getTypeAsClass().newInstance();
switch (handler.getType()) {
case DefaultErrorHandler:
case DeadLetterChannel:
setProperties((DefaultErrorHandlerBuilder) builder);
break;
case LoggingErrorHandler:
setProperties((LoggingErrorHandlerBuilder) builder);
break;
case NoErrorHandler:
// No configuration required
break;
case TransactionErrorHandler:
break;
default:
break;
}
return builder;
} catch (Exception cause) {
throw new CreationException("Error while creating instance for " + this, cause);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:XmlErrorHandlerFactoryBean.java
示例9: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
// from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&durable=false&autoDelete=true&routingKey=avatar.nao1.data.joint")
// .sample(1, TimeUnit.SECONDS)
// .to("log:IN.avatar.nao1.data.joint?showHeaders=true&showAll=true&multiline=true")
// .process(it -> {
// final JsonNode inBodyJson = toJson.getMapper().readTree(it.getIn().getBody(byte[].class));
// final JointSetLegacy jointSet = toJson.getMapper().convertValue(inBodyJson, JointSetLegacy.class);
// final List<Node> nodesResult = new TransactionTemplate(txMgr).execute(tx -> {
// final DateTime now = new DateTime();
// final List<Node> nodes = new ArrayList<>();
// for (String jointName : jointSet.getNames()) {
// final Map<String, Object> props = new HashMap<String, Object>();
// final Node node = neo4j.createNode(props, new ArrayList<String>(Arrays.asList("JournalJoint")));
// nodes.add(node);
// }
// log.debug("Created {} JournalJoint(s) {} from {}", nodes, jointSet);
// return nodes;
// });
// it.getOut().setBody(nodesResult.stream().map(Node::getId).collect(Collectors.toList()));
// }
// )
// .bean(toJson)
// .to("log:OUT.avatar.nao1.data.joint?showAll=true&multiline=true");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:28,代码来源:JointRouter.java
示例10: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final String avatarId = "nao1";
// from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.DATA_TACTILE.key(avatarId) + "&routingKey=" + AvatarChannel.DATA_TACTILE.key(avatarId))
// .sample(1, TimeUnit.SECONDS)
// .to("log:IN." + AvatarChannel.DATA_TACTILE.key(avatarId) + "?showHeaders=true&showAll=true&multiline=true")
// .process(it -> {
// final JsonNode inBodyJson = toJson.getMapper().readTree(it.getIn().getBody(byte[].class));
// final TactileSetLegacy tactileSet = toJson.getMapper().convertValue(inBodyJson, TactileSetLegacy.class);
// final List<Node> nodesResult = new TransactionTemplate(txMgr).execute(tx -> {
// final DateTime now = new DateTime();
// final List<Node> nodes = new ArrayList<>();
// for (String tactileName : tactileSet.getNames()) {
// final Map<String, Object> props = new HashMap<>();
// final Node node = neo4j.createNode(props, ImmutableSet.of("JournalTactile"));
// nodes.add(node);
// }
// log.debug("Created {} JournalTactile(s) {} from {}", nodes, tactileSet);
// return nodes;
// });
// it.getOut().setBody(nodesResult.stream().map(Node::getId).collect(Collectors.toList()));
// })
// .bean(toJson)
// .to("log:OUT." + AvatarChannel.DATA_TACTILE.key(avatarId) + "?showAll=true&multiline=true");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:28,代码来源:TactileRouter.java
示例11: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final String avatarId = "nao1";
// from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.DATA_SONAR.key(avatarId) + "&routingKey=" + AvatarChannel.DATA_SONAR.key(avatarId))
// .sample(1, TimeUnit.SECONDS)
// .to("log:IN." + AvatarChannel.DATA_SONAR.key(avatarId) + "?showHeaders=true&showAll=true&multiline=true")
// .process(it -> {
// final JsonNode inBodyJson = toJson.getMapper().readTree(it.getIn().getBody(byte[].class));
// final SonarState sonarState = toJson.getMapper().convertValue(inBodyJson, SonarState.class);
// final Node nodeResult = new TransactionTemplate(txMgr).execute(tx -> {
// final DateTime now = new DateTime();
// final Map<String, Object> props = new HashMap<String, Object>();
// final Node node = neo4j.createNode(props, ImmutableSet.of("JournalSonarState"));
// log.debug("Created JournalSonarState {} from {}", node, props);
// return node;
// });
// it.getOut().setBody(nodeResult.getId());
//
//// it.out.headers['rabbitmq.ROUTING_KEY'] = Preconditions.checkNotNull(it.in.headers['rabbitmq.REPLY_TO'],
//// '"rabbitmq.REPLY_TO" header must be specified, found headers: %s', it.in.headers)
//// it.out.headers['rabbitmq.EXCHANGE_NAME'] = ''
// })
// .bean(toJson)
// .to("log:OUT." + AvatarChannel.DATA_SONAR.key(avatarId) + "?showAll=true&multiline=true");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:28,代码来源:JournalSonarRouter.java
示例12: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final String avatarId = "nao1";
from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.CAMERA_MAIN.key(avatarId) + "&routingKey=" + AvatarChannel.CAMERA_MAIN.key(avatarId))
.process(exchange -> {
final ImageObject imageObject = toJson.getMapper().readValue(
exchange.getIn().getBody(byte[].class), ImageObject.class);
final DataUri dataUri = DataUri.parse(imageObject.getContentUrl(), StandardCharsets.UTF_8);
cameraMain = dataUri.getData();
cameraMainType = dataUri.getMime();
log.debug("Got nao1.camera.main {} {} bytes", cameraMainType, cameraMain.length);
});
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:16,代码来源:VisualCaptureRouter.java
示例13: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
from("seda:greetingReceived")
.process(exchange -> {
final GreetingReceived greetingReceived = exchange.getIn().getBody(GreetingReceived.class);
kieSession.insert(greetingReceived);
kieSession.fireAllRules();
})
.to("log:echo");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:13,代码来源:DroolsRouter.java
示例14: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
FluentIterable.from(agentRepo.findAll())
.forEach(ag -> {
final String facebookFeed = UriComponentsBuilder.fromUriString("facebook://postStatusMessage?oAuthAppId={facebookAppId}&oAuthAppSecret={facebookAppSecret}&oAuthAccessToken={facebookAccessToken}")
.buildAndExpand(ag.getFacebookSys().getFacebookAppId(), ag.getFacebookSys().getFacebookAppSecret(), ag.getFacebookSys().getFacebookAccessToken()).toString();
final String twitterTimelineUser = UriComponentsBuilder.fromUriString("twitter://timeline/user?consumerKey={twitterApiKey}&consumerSecret={twitterApiSecret}&accessToken={twitterToken}&accessTokenSecret={twitterTokenSecret}")
.buildAndExpand(ag.getTwitterSys().getTwitterApiKey(), ag.getTwitterSys().getTwitterApiSecret(), ag.getTwitterSys().getTwitterToken(), ag.getTwitterSys().getTwitterTokenSecret()).toString();
from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + LumenChannel.FACEBOOK_TIMELINE_OUT.key(ag.getId()) + "&routingKey=" + LumenChannel.FACEBOOK_TIMELINE_OUT.key(ag.getId()))
.to("log:" + LumenChannel.FACEBOOK_TIMELINE_OUT.key(ag.getId()))
.process((Exchange it) -> {
final CommunicateAction communicateAction = toJson.getMapper().readValue((byte[]) it.getIn().getBody(), CommunicateAction.class);
it.getIn().setHeader("network.id", "facebook");
it.getIn().setHeader("CamelFacebook.message", communicateAction.getObject());
it.getIn().setBody(null);
// final StatusUpdate statusUpdate = toJson.mapper.readValue((byte[]) it.getIn().getBody(), StatusUpdate.class);
// switch (statusUpdate.getChannel().getThingId()) {
// case "facebook":
// it.getIn().setHeader("network.id", "facebook");
// it.getIn().setHeader("CamelFacebook.message", statusUpdate.getMessage());
// it.getIn().setBody(null);
// break;
// case "twitter":
// it.getIn().setHeader("network.id", "twitter");
// it.getIn().setBody(statusUpdate.getMessage());
// break;
// }
}).choice()
.when(header("network.id").isEqualTo("facebook")).to(facebookFeed).to("log:" + LumenChannel.FACEBOOK_TIMELINE_OUT.key(ag.getId()) + "-postStatusMessage")
.when(header("network.id").isEqualTo("twitter")).to(twitterTimelineUser).to("log:twitter-timeline-user")
.otherwise().to("log:socmed-unknown");
});
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:36,代码来源:FacebookTimelineRouter.java
示例15: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final int period = 1000;
log.info("Motion capture timer with period = {}ms", period);
for (final String avatarId : naoConfig.getControllerAvatarIds()) {
final NaoController nao = naoConfig.get(avatarId);
final ALMotionProxy motionProxy = nao.getMotion();
final String[] angleNames = motionProxy.getJointNames("Body");
from("timer:motion?period=" + period)
.process(exchange -> {
final MotionState motionState = new MotionState();
final float[] angles = motionProxy.getAngles(new Variant("Body"), true);
for (int i = 0; i < angles.length; i++) {
final JointState jointState = new JointState();
jointState.setName(angleNames[i]);
jointState.setAngle((double) angles[i]);
motionState.getAngles().add(jointState);
}
motionState.setDateCreated(new DateTime());
exchange.getIn().setBody(motionState);
})
.bean(toJson)
.to("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&skipQueueDeclare=true&autoDelete=false&routingKey=avatar." + avatarId + ".data.motion")
.to("log:" + MotionRouter.class.getName() + "." + avatarId + "?level=TRACE&showAll=true&multiline=true");
}
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:30,代码来源:MotionRouter.java
示例16: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
for (final String avatarId : naoConfig.getControllerAvatarIds()) {
final NaoController nao = naoConfig.get(avatarId);
final ALLedsProxy ledsProxy = nao.getLeds();
from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.LEDS.key(avatarId) + "&routingKey=" + AvatarChannel.LEDS.key(avatarId))
.to("log:IN." + AvatarChannel.LEDS.key(avatarId) + "?showHeaders=true&showAll=true&multiline=true")
.process(exchange -> {
final LumenThing thing = toJson.getMapper().readValue(exchange.getIn().getBody(byte[].class), LumenThing.class);
log.info("Got LED command: {}", thing);
if (thing instanceof LedOperation) {
final LedOperation ledOp = (LedOperation) thing;
final String ledName = ledOp.getNames().stream().findFirst().orElse("FaceLeds");
if (ledOp.getKind() == LedOperationKind.OFF) {
ledsProxy.off(ledName);
} else if (ledOp.getKind() == LedOperationKind.ON) {
ledsProxy.on(ledName);
} else if (ledOp.getKind() == LedOperationKind.FADE) {
//final Color rgb = Color.web(ledOp.getColor());
ledsProxy.fade(ledName, ledOp.getIntensity().floatValue(), ledOp.getDuration().floatValue());
} else if (ledOp.getKind() == LedOperationKind.FADE_RGB) {
final Color rgb = Color.web(ledOp.getColor());
final int rgbi = ((int) (rgb.getRed() * 0xff) << 16) | ((int) (rgb.getGreen() * 0xff) << 8) | (int) (rgb.getBlue() * 0xff);
ledsProxy.fadeRGB(ledName, rgbi, ledOp.getDuration().floatValue());
} else if (ledOp.getKind() == LedOperationKind.RANDOM_EYES) {
ledsProxy.randomEyes(ledOp.getDuration().floatValue());
} else if (ledOp.getKind() == LedOperationKind.RASTA) {
ledsProxy.rasta(ledOp.getDuration().floatValue());
}
exchange.getIn().setBody(new Status());
} else {
exchange.getOut().setBody(null);
}
})
.bean(toJson);
}
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:40,代码来源:LedsRouter.java
示例17: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
// lumen.speech.expression
// TODO: we should delay e.g. 500ms to see if speech-expression handles it (and notifies with actionStatus=ACTIVE_ACTION_STATUS),
// otherwise NAO TTS will handle it
from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + LumenChannel.SPEECH_SYNTHESIS.key() + "&routingKey=" + LumenChannel.SPEECH_SYNTHESIS.key())
.to("log:IN.lumen.speech.synthesis?showHeaders=true&showAll=true&multiline=true")
.process(exchange -> {
final LumenThing thing = toJson.getMapper().readValue(
exchange.getIn().getBody(byte[].class), LumenThing.class);
log.info("Got speech.synthesis command: {}", thing);
if (thing instanceof CommunicateAction) {
final CommunicateAction communicateAction = (CommunicateAction) thing;
if (naoConfig.getControllerAvatarIds().contains(communicateAction.getAvatarId())) {
final Locale lang = Optional.ofNullable(communicateAction.getInLanguage()).orElse(Locale.US);
if ("en".equals(lang.getLanguage())) {
log.info("Speaking {} for {}: {}", lang.toLanguageTag(), communicateAction.getAvatarId(), communicateAction.getObject());
naoConfig.get(communicateAction.getAvatarId()).getTts().say(communicateAction.getObject());
log.debug("Spoken {} for {}: {}", lang.toLanguageTag(), communicateAction.getAvatarId(), communicateAction.getObject());
} else {
log.info("Language '{}' not supported by {}, skipping: {}",
lang.toLanguageTag(), communicateAction.getAvatarId(), communicateAction.getObject());
}
}
exchange.getIn().setBody(new Status());
} else {
exchange.getOut().setBody(null);
}
})
.bean(toJson);
// .to("log:OUT.lumen.speech.synthesis");
}
开发者ID:lumenrobot,项目名称:avatar-nao,代码行数:35,代码来源:NaoSpeechSynthesisRouter.java
示例18: setProperties
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
private void setProperties(LoggingErrorHandlerBuilder builder) {
builder.setLevel(handler.getLevel());
builder.setLogName(handler.getLogName());
}
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:XmlErrorHandlerFactoryBean.java
示例19: testLoggingErrorHandler
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
public void testLoggingErrorHandler() {
LoggingErrorHandlerBuilder errorHandler = ctx.getBean("loggingErrorHandler", LoggingErrorHandlerBuilder.class);
assertNotNull(errorHandler);
assertEquals("The log level should be INFO", LoggingLevel.INFO, errorHandler.getLevel());
assertEquals("The log name should be foo", "foo", errorHandler.getLogName());
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:ErrorHandlerDefinitionParserTest.java
示例20: configure
import org.apache.camel.builder.LoggingErrorHandlerBuilder; //导入依赖的package包/类
@Override
public void configure() throws Exception {
onException(Exception.class).bean(asError).bean(toJson).handled(true);
errorHandler(new LoggingErrorHandlerBuilder(log));
final String avatarId = "nao1";
// from("rabbitmq://localhost/amq.topic?connectionFactory=#amqpConnFactory&exchangeType=topic&autoDelete=false&queue=" + AvatarChannel.CAMERA_MAIN.key(avatarId) + "&routingKey=" + AvatarChannel.CAMERA_MAIN.key(avatarId))
// .sample(1, TimeUnit.SECONDS)
// .to("log:IN." + AvatarChannel.CAMERA_MAIN.key(avatarId) + "?showHeaders=true&showAll=true&multiline=true")
// .process(it -> {
// final JsonNode inBodyJson = toJson.getMapper().readTree(it.getIn().getBody(byte[].class));
// final ImageObjectLegacy imageObject = toJson.getMapper().convertValue(inBodyJson, ImageObjectLegacy.class);
// new TransactionTemplate(txMgr).execute(tx -> {
// final DateTime now = new DateTime();// FIXME: NaoServer should send ISO formatted timestamp
// final Map<String, Object> props = new HashMap<>();
// final String contentType = Preconditions.checkNotNull(imageObject.getContentType(), "ImageObject.contentType must be specified");
// final String upContentUrl = imageObject.getContentUrl();
// if (upContentUrl != null && upContentUrl.startsWith("data:")) {
// final String base64 = StringUtils.substringAfter(upContentUrl, ",");
// final byte[] content = Base64.decodeBase64(base64);
// final String ext = Preconditions.checkNotNull(extensionMap.get(contentType),
// "Cannot get extension for MIME type \"%s\". Known MIME types: %s", contentType, extensionMap.keySet());
// // IIS disables double escaping, so avoid '+0700' in filename
// final String fileName = avatarId + "_journalimage_" + new DateTime(DateTimeZone.UTC).toString("yyyy-MM-dd'T'HH-mm-ssZ") + "." + ext;
// final File file = new File(mediaUploadPath, fileName);
// log.debug("Writing {} ImageObject to {} ...", contentType, file);
// try {
// FileUtils.writeByteArrayToFile(file, content);
// } catch (IOException e) {
// throw new RuntimeException("Cannot write to " + file, e);
// }
// props.put("contentUrl", mediaUploadPrefix + fileName);
// } else {
// props.put("contentUrl", upContentUrl);
// }
//
// final Node node = neo4j.createNode(props, ImmutableList.of("JournalImageObject"));
// log.debug("Created JournalImageObject {} from {} {}", node, imageObject.getName(), now);
// return node;
// });
// it.getIn().setBody(new Status());
// })
// .bean(toJson)
// .to("log:OUT." + AvatarChannel.CAMERA_MAIN.key(avatarId) + "?showAll=true&multiline=true");
}
开发者ID:lumenrobot,项目名称:lumen,代码行数:45,代码来源:ImageRouter.java
注:本文中的org.apache.camel.builder.LoggingErrorHandlerBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论