@Override public void start(BundleContext context) throws Exception { RKMessagingConfigUtils.registerAvroSerializationConfig( SpeechRecConfig.class, SpeechRecConfigRecord.class, SpeechRecConfigRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.CONFIG_MIME_TYPE, null, new OSGiComponentFactory(context)); RKMessagingConfigUtils.registerAvroSerializationConfig( SpeechRecEventList.class, SpeechRecEventListRecord.class, SpeechRecEventListRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); }
CameraConfig.class, CameraConfig.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.CONFIG_MIME_TYPE, null, new OSGiComponentFactory(context)); ImageRecord.class, ImageRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); FaceDetectConfig.class, FaceDetectConfig.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.CONFIG_MIME_TYPE, null, new OSGiComponentFactory(context)); ImageRegionListRecord.class, ImageRegionListRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context));
private static void startSpeechMessengers(BundleContext context, Properties groupProps, String connectionId, String speechReqDestId, String speechRequestSenderId, String speechEventsDestId, String speechEventsReceiverId){ JMSAvroMessageSenderLifecycle speechRequestSender = new JMSAvroMessageSenderLifecycle( new EmptyAdapter(), SpeechRequest.class, SpeechRequestRecord.class, speechRequestSenderId, connectionId, speechReqDestId); new OSGiComponent(context, speechRequestSender, groupProps).start(); JMSAvroAsyncReceiverLifecycle speechEventsReceiver = new JMSAvroAsyncReceiverLifecycle( new EmptyAdapter(), SpeechEventList.class, SpeechEventListRecord.class, SpeechEventListRecord.SCHEMA$, speechEventsReceiverId, connectionId, speechEventsDestId); new OSGiComponent(context, speechEventsReceiver, groupProps).start(); }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } Destination accelValReceiver = ConnectionContext.getTopic(theAccelInputDest); myConnectionContext.addAsyncReceiver(ACCEL_VALUE_RECEIVER, session, accelValReceiver, FilteredVector3Record.class, FilteredVector3Record.SCHEMA$, new EmptyAdapter<FilteredVector3Record, FilteredVector3Record>()); Destination accelCfgSender = ConnectionContext.getTopic(theAccelConfigDest); myConnectionContext.addSender(ACCEL_CONFIG_SENDER, session, accelCfgSender, new EmptyAdapter<AccelerometerConfigRecord, AccelerometerConfigRecord>()); Destination accelPerSender = ConnectionContext.getTopic(theAccelReadDest); myConnectionContext.addSender(ACCEL_READ_PERIOD_SENDER, session, accelPerSender, new EmptyAdapter<DeviceReadPeriodRecord, DeviceReadPeriodRecord>()); myConnectionsFlag = true; }
GpioConfigRecord.class, GpioConfigRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); DeviceBoolRecord.class, DeviceBoolRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); DeviceReadPeriodRecord.class, DeviceReadPeriodRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); AccelerometerConfigRecord.class, AccelerometerConfigRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); FilteredVector3Record.class,
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } Destination compassValReceiver = ConnectionContext.getTopic(theCompassInputDest); myConnectionContext.addAsyncReceiver(COMPASS_VALUE_RECEIVER, session, compassValReceiver, FilteredVector3Record.class, FilteredVector3Record.SCHEMA$, new EmptyAdapter<FilteredVector3Record, FilteredVector3Record>()); Destination compassCfgSender = ConnectionContext.getTopic(theCompassConfigDest); myConnectionContext.addSender(COMPASS_CONFIG_SENDER, session, compassCfgSender, new EmptyAdapter<CompassConfigRecord, CompassConfigRecord>()); Destination compassPerSender = ConnectionContext.getTopic(theCompassReadDest); myConnectionContext.addSender(COMPASS_READ_PERIOD_SENDER, session, compassPerSender, new EmptyAdapter<DeviceReadPeriodRecord, DeviceReadPeriodRecord>()); myConnectionsFlag = true; }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } Destination gyroValReceiver = ConnectionContext.getTopic(theGyroInputDest); myConnectionContext.addAsyncReceiver(GYRO_VALUE_RECEIVER, session, gyroValReceiver, FilteredVector3Record.class, FilteredVector3Record.SCHEMA$, new EmptyAdapter<FilteredVector3Record, FilteredVector3Record>()); Destination gyroCfgSender = ConnectionContext.getTopic(theGyroConfigDest); myConnectionContext.addSender(GYRO_CONFIG_SENDER, session, gyroCfgSender, new EmptyAdapter<GyroConfigRecord, GyroConfigRecord>()); Destination gyroPerSender = ConnectionContext.getTopic(theGyroReadDest); myConnectionContext.addSender(GYRO_READ_PERIOD_SENDER, session, gyroPerSender, new EmptyAdapter<DeviceReadPeriodRecord, DeviceReadPeriodRecord>()); myConnectionsFlag = true; }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } Destination gpioValReceiver = ConnectionContext.getTopic(theGpioInputDest); myConnectionContext.addAsyncReceiver(GPIO_VALUE_RECEIVER, session, gpioValReceiver, DeviceBoolRecord.class, DeviceBoolRecord.SCHEMA$, new EmptyAdapter<DeviceBoolRecord, DeviceBoolRecord>()); Destination gpioDirSender = ConnectionContext.getTopic(theGpioDirectionDest); myConnectionContext.addSender(GPIO_DIRECTION_SENDER, session, gpioDirSender, new EmptyAdapter<GpioConfigRecord, GpioConfigRecord>()); Destination gpioPerSender = ConnectionContext.getTopic(theGpioReadDest); myConnectionContext.addSender(GPIO_READ_PERIOD_SENDER, session, gpioPerSender, new EmptyAdapter<DeviceReadPeriodRecord, DeviceReadPeriodRecord>()); Destination gpioValSender = ConnectionContext.getTopic(theGpioOutputDest); myConnectionContext.addSender(GPIO_VALUE_SENDER, session, gpioValSender, new EmptyAdapter<DeviceBoolRecord, DeviceBoolRecord>()); myConnectionsFlag = true; }
private void launchRemoteClient(BundleContext context, String speechClientId, String speechHostId, String connectionId, String commandDestId, String commandSenderId, String configDestId, String configSenderId, String errorDestId, String errorReceiverId, String speechReqDestId, String speechRequestSenderId, String speechEventsDestId, String speechEventsReceiverId){ Properties props = new Properties(); props.put(SpeechService.PROP_ID, speechClientId); startClientMessengers(context, props, connectionId, commandDestId, commandSenderId, configDestId, configSenderId, new EmptyAdapter(), SpeechConfig.class, SpeechConfigRecord.class, errorDestId, errorReceiverId); startSpeechMessengers(context, props, connectionId, speechReqDestId, speechRequestSenderId, speechEventsDestId, speechEventsReceiverId); launchRemoteSpeechClient(context, speechClientId, speechHostId, commandSenderId, configSenderId, errorReceiverId, speechRequestSenderId, speechEventsReceiverId); }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } Destination cmdDest = ConnectionContext.getQueue(myCommandDest); Destination confDest = ConnectionContext.getQueue(myConfigDest); Destination errDest = ConnectionContext.getTopic(myErrorDest); Destination reqDest = ConnectionContext.getQueue(myRequestDest); Destination evtDest = ConnectionContext.getTopic(myEventDest); myConnectionContext.addSender(CMD_SENDER, session, cmdDest, new EmptyAdapter()); myConnectionContext.addSender(CONFIG_SENDER, session, confDest, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(ERROR_RECEIVER, session, errDest, ServiceErrorRecord.class, ServiceErrorRecord.SCHEMA$, new EmptyAdapter()); myConnectionContext.addSender(SPEECH_SENDER, session, reqDest, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(EVENT_RECEIVER, session, evtDest, SpeechEventListRecord.class, SpeechEventListRecord.SCHEMA$, new EmptyAdapter()); myConnectionsFlag = true; }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } readCameraId(); Destination cmdDest = ConnectionContext.getQueue(myCommandDest); Destination confDest = ConnectionContext.getQueue(myConfigDest); Destination errDest = ConnectionContext.getTopic(myErrorDest); Destination evtDest = ConnectionContext.getTopic(myEventDest); myConnectionContext.addSender(CMD_SENDER, session, cmdDest, new EmptyAdapter()); myConnectionContext.addSender(CONFIG_SENDER, session, confDest, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(ERROR_RECEIVER, session, errDest, ServiceErrorRecord.class, ServiceErrorRecord.SCHEMA$, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(EVENT_RECEIVER, session, evtDest, ImageRecord.class, ImageRecord.SCHEMA$, new EmptyAdapter()); myConnectionsFlag = true; }
@Override protected synchronized void addConnection(Session session) throws JMSException, URISyntaxException{ if(myConnectionContext == null || myConnectionsFlag){ return; } readCameraId(); Destination cmdDest = ConnectionContext.getQueue(myCommandDest); Destination confDest = ConnectionContext.getQueue(myConfigDest); Destination errDest = ConnectionContext.getTopic(myErrorDest); Destination evtDest = ConnectionContext.getTopic(myEventDest); myConnectionContext.addSender(CMD_SENDER, session, cmdDest, new EmptyAdapter()); myConnectionContext.addSender(CONFIG_SENDER, session, confDest, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(ERROR_RECEIVER, session, errDest, ServiceErrorRecord.class, ServiceErrorRecord.SCHEMA$, new EmptyAdapter()); myConnectionContext.addAsyncReceiver(EVENT_RECEIVER, session, evtDest, ImageRegionListRecord.class, ImageRegionListRecord.SCHEMA$, new EmptyAdapter()); myConnectionsFlag = true; }
private static <Msg,Rec> void startClientMessengers(BundleContext context, Properties groupProps, String connectionId, String commandDestId, String commandSenderId, String configDestId, String configSenderId, Adapter<Msg,Rec> configMsgRecAdapter, Class<Msg> msgClass, Class<Rec> recClass, String errorDestId, String errorReceiverId){ JMSAvroMessageSenderLifecycle commandSender = new JMSAvroMessageSenderLifecycle( new EmptyAdapter(), ServiceCommand.class, ServiceCommandRecord.class, commandSenderId, connectionId, commandDestId); new OSGiComponent(context, commandSender, groupProps).start(); JMSAvroMessageSenderLifecycle configSender = new JMSAvroMessageSenderLifecycle( configMsgRecAdapter, msgClass, recClass, configSenderId, connectionId, configDestId); new OSGiComponent(context, configSender, groupProps).start(); JMSAvroAsyncReceiverLifecycle errorReceiver = new JMSAvroAsyncReceiverLifecycle( new EmptyAdapter(), ServiceError.class, ServiceErrorRecord.class, ServiceErrorRecord.SCHEMA$, errorReceiverId, connectionId, errorDestId); new OSGiComponent(context, errorReceiver, groupProps).start(); }
private static MessageAsyncReceiver<SpeechRequest> createSpeechReceiver( Session session, Destination dest){ DefaultMessageAsyncReceiver<SpeechRequest, SpeechRequestRecord> receiver = new DefaultMessageAsyncReceiver<SpeechRequest, SpeechRequestRecord>(); MessageConsumer consumer; try{ consumer = session.createConsumer(dest); }catch(JMSException ex){ theLogger.log(Level.SEVERE, "Error starting message receiver.", ex); return null; } RecordAsyncReceiver<SpeechRequestRecord> recReceiver = new JMSAvroRecordAsyncReceiver<SpeechRequestRecord>( SpeechRequestRecord.class, SpeechRequestRecord.SCHEMA$, consumer); receiver.setRecordReceiver(recReceiver); receiver.setAdapter(new EmptyAdapter()); return receiver; }
@Override public void start(BundleContext context) throws Exception { RKMessagingConfigUtils.registerAvroSerializationConfig( ServiceCommand.class, ServiceCommandRecord.class, ServiceCommandRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.COMMAND_MIME_TYPE, null, new OSGiComponentFactory(context)); RKMessagingConfigUtils.registerAvroSerializationConfig( ServiceError.class, ServiceErrorRecord.class, ServiceErrorRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); new OSGiComponent(context, new SimpleLifecycle(new PortableServiceCommand.Factory(), ServiceCommandFactory.class)).start(); }
private ProducerNode<SpeechRecEventList<SpeechRecEvent>> buildSpeechRecChain( Session session, Destination dest){ JMSAvroMessageAsyncReceiver<SpeechRecEventList<SpeechRecEvent>, SpeechRecEventListRecord> rec = new JMSAvroMessageAsyncReceiver<SpeechRecEventList<SpeechRecEvent>, SpeechRecEventListRecord>( session, dest, SpeechRecEventListRecord.class, SpeechRecEventListRecord.SCHEMA$); rec.setAdapter(new EmptyAdapter()); try{ rec.start(); }catch(Exception ex){ theLogger.log(Level.SEVERE, "Unable to start Message Receiver", ex); return null; } return new DefaultProducerNode<SpeechRecEventList<SpeechRecEvent>>(rec); // try{ // return JMSAvroUtils.buildEventReceiverChain( // SpeechRecEventListRecord.class, // SpeechRecEventListRecord.SCHEMA$, // new EmptyAdapter(), // session, dest); // }catch(JMSException ex){ // theLogger.log(Level.WARNING,"Error connecting to Speech Rec.",ex); // return null; // } }
private ProducerNode<SpeechRecEventList<SpeechRecEvent>> buildSpeechRecChain( Session session, Destination dest){ JMSAvroMessageAsyncReceiver<SpeechRecEventList<SpeechRecEvent>, SpeechRecEventListRecord> rec = new JMSAvroMessageAsyncReceiver<SpeechRecEventList<SpeechRecEvent>, SpeechRecEventListRecord>( session, dest, SpeechRecEventListRecord.class, SpeechRecEventListRecord.SCHEMA$); rec.setAdapter(new EmptyAdapter()); try{ rec.start(); }catch(Exception ex){ theLogger.log(Level.SEVERE, "Unable to start Message Receiver", ex); return null; } return new DefaultProducerNode<SpeechRecEventList<SpeechRecEvent>>(rec); // try{ // return JMSAvroUtils.buildEventReceiverChain( // SpeechRecEventListRecord.class, // SpeechRecEventListRecord.SCHEMA$, // new EmptyAdapter(), // session, dest); // }catch(JMSException ex){ // theLogger.log(Level.WARNING,"Error connecting to Speech Rec.",ex); // return null; // } }
SpeechConfigRecord.class, SpeechConfigRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.CONFIG_MIME_TYPE, null, new OSGiComponentFactory(context)); SpeechEventRecord.class, SpeechEventRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); SpeechEventListRecord.class, SpeechEventListRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context)); SpeechRequestRecord.class, SpeechRequestRecord.SCHEMA$, new EmptyAdapter(), new EmptyAdapter(), JMSAvroServiceFacade.AVRO_MIME_TYPE, null, new OSGiComponentFactory(context));
private ConsumerNode<SpeechRequest> buildTTSNodeChain( Session session, Destination dest){ try{ JMSAvroMessageSender<SpeechRequest,SpeechRequestRecord> sender = new JMSAvroMessageSender<SpeechRequest, SpeechRequestRecord>(session, dest); sender.setAdapter(new EmptyAdapter()); sender.setDefaultContentType("application/speechRequest"); sender.start(); return new DefaultConsumerNode<SpeechRequest>(sender); // return NodeChainBuilder.build( // EncodeRequest.factory(SpeechRequest.class, new JMSAvroUtils.ByteOutputStreamFactory())) // .getConsumerChain(JMSAvroUtils.buildEventSenderChain( // SpeechRequestRecord.class, // SpeechRequestRecord.SCHEMA$, // new EmptyAdapter(), // session, dest, // new MessageHeaderAdapter("application/speechRequest"))); }catch(Exception ex){ theLogger.log(Level.WARNING,"Error connecting to TTS.",ex); return null; } }
private ConsumerNode<ServiceCommand> buildServiceCommandNodeChain( Session session, Destination dest){ try{ JMSAvroMessageSender<ServiceCommand,ServiceCommandRecord> sender = new JMSAvroMessageSender<ServiceCommand, ServiceCommandRecord>(session, dest); sender.setAdapter(new EmptyAdapter()); sender.setDefaultContentType("application/service-command"); sender.start(); return new DefaultConsumerNode<ServiceCommand>(sender); }catch(Exception ex){ theLogger.log(Level.WARNING,"Error connecting to TTS.",ex); return null; } // try{ // return NodeChainBuilder.build( // EncodeRequest.factory(ServiceCommand.class, new JMSAvroUtils.ByteOutputStreamFactory())) // .getConsumerChain(JMSAvroUtils.buildEventSenderChain( // ServiceCommandRecord.class, // ServiceCommandRecord.SCHEMA$, // new EmptyAdapter(), // session, dest, // new MessageHeaderAdapter("application/service-command"))); // }catch(JMSException ex){ // theLogger.log(Level.WARNING,"Error connecting to TTS.",ex); // return null; // } }