/** * Class: org_opensplice_dds_dcps_TopicDescriptionImpl * Method: jniGetTypeName * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL SAJ_FUNCTION(jniGetTypeName)( JNIEnv *env, jobject jdescription) { gapi_topicDescription description; jstring jtypeName; gapi_string typeName; description = (gapi_topicDescription) saj_read_gapi_address(env, jdescription); typeName = gapi_topicDescription_get_type_name(description); if(typeName != NULL){ jtypeName = (*env)->NewStringUTF(env, typeName); gapi_free(typeName); } return jtypeName; }
bool DDS::DomainParticipant_impl::createBuiltinReader( gapi_subscriber subscriber_handle, const char *name ) { char *type_name; bool status = false; gapi_dataReader reader_handle = NULL; gapi_topic topic_handle; DDS::DataReader_ptr a_reader = NULL; DDS::ccpp_UserData_ptr myUD = NULL; gapi_typeSupport ts_handle = NULL; reader_handle = gapi_subscriber_lookup_datareader(subscriber_handle, name); if (reader_handle) { topic_handle = gapi_dataReader_get_topicdescription(reader_handle); if (topic_handle) { type_name = gapi_topicDescription_get_type_name(topic_handle); ts_handle = gapi_domainParticipant_get_typesupport(_gapi_self, type_name); gapi_free(type_name); if (ts_handle) { void *tsf = gapi_object_get_user_data(ts_handle); if (tsf) { DDS::Object_ptr anObject; DDS::TypeSupportFactory_impl_ptr factory; anObject = static_cast<DDS::Object_ptr>(tsf); factory = dynamic_cast<DDS::TypeSupportFactory_impl_ptr>(anObject); if (factory) { a_reader = factory->create_datareader(reader_handle); } if (a_reader) { myUD = new ccpp_UserData(a_reader, NULL); if (myUD) { gapi_object_set_user_data(reader_handle, (DDS::Object *)myUD, ccpp_CallBack_DeleteUserData,NULL); status = true; } } } } else { OS_REPORT_1(OS_ERROR, "DDS::DomainParticipant_impl::createBuiltinReader", 0, "Lookup TypeSupport Failed for DataReader <%s>", name); } } else { OS_REPORT_1(OS_ERROR, "DDS::DomainParticipant_impl::createBuiltinReader", 0, "Lookup Topic Failed for DataReader <%s>", name); } } else if (name) { OS_REPORT_1(OS_ERROR, "DDS::DomainParticipant_impl::createBuiltinReader", 0, "Lookup DataReader <%s> Failed", name); } else { OS_REPORT(OS_ERROR, "DDS::DomainParticipant_impl::createBuiltinReader", 0, "Lookup DataReader <NULL> Failed"); } return status; }
/** * Class: org_opensplice_dds_dcps_PublisherImpl * Method: jniCreateDatawriter * Signature: (LDDS/Topic;LDDS/DataWriterQos;LDDS/DataWriterListener;)LDDS/DataWriter; */ JNIEXPORT jobject JNICALL SAJ_FUNCTION(jniCreateDatawriter)( JNIEnv *env, jobject jpublisher, jobject jtopic, jobject jqos, jobject jlistener, jint jmask) { jobject jwriter; gapi_publisher publisher; gapi_dataWriter writer; gapi_dataWriterQos* writerQos; gapi_topic topic; gapi_domainParticipant participant; gapi_typeSupport typeSupport; const struct gapi_dataWriterListener *listener; gapi_char* dataWriterClassName; saj_returnCode rc; gapi_string typeName; gapi_char* signature; jobject jtypeSupport; jwriter = NULL; listener = NULL; writer = GAPI_OBJECT_NIL; publisher = (gapi_publisher) saj_read_gapi_address(env, jpublisher); participant = gapi_publisher_get_participant(publisher); topic = (gapi_topic) saj_read_gapi_address(env, jtopic); typeName = gapi_topicDescription_get_type_name((gapi_topicDescription)topic); typeSupport = gapi_domainParticipant_get_typesupport(participant, (const gapi_char*) typeName); gapi_free(typeName); jtypeSupport = saj_read_java_address((gapi_object)typeSupport); rc = saj_LookupTypeSupportDataWriter(env, jtypeSupport, &dataWriterClassName); if(rc == SAJ_RETCODE_OK){ if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAWRITER_QOS_DEFAULT)) == JNI_TRUE) { writerQos = (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_DEFAULT; rc = SAJ_RETCODE_OK; } else if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAWRITER_QOS_USE_TOPIC_QOS)) == JNI_TRUE) { writerQos = (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_USE_TOPIC_QOS; rc = SAJ_RETCODE_OK; } else { writerQos = gapi_dataWriterQos__alloc(); rc = saj_DataWriterQosCopyIn(env, jqos, writerQos); } if(rc == SAJ_RETCODE_OK){ listener = saj_dataWriterListenerNew(env, jlistener); writer = gapi_publisher_create_datawriter(publisher, topic, writerQos, listener, (gapi_statusMask)jmask); if (writer != GAPI_OBJECT_NIL){ rc = saj_LookupTypeSupportConstructorSignature(env, jtypeSupport, &signature); if(rc == SAJ_RETCODE_OK){ gapi_publisherQos *pqos = gapi_publisherQos__alloc(); rc = saj_construct_typed_java_object(env, dataWriterClassName, (PA_ADDRCAST)writer, &jwriter, signature, jtypeSupport); gapi_free(signature); if(listener != NULL){ saj_write_java_listener_address(env, writer, listener->listener_data); } if(pqos){ if(gapi_publisher_get_qos(publisher, pqos) == GAPI_RETCODE_OK){ if(pqos->entity_factory.autoenable_created_entities) { gapi_entity_enable(writer); } } gapi_free(pqos); } } } else if(listener != NULL){ saj_listenerDataFree(env, saj_listenerData(listener->listener_data)); } } if ((writerQos != (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_DEFAULT) && (writerQos != (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_USE_TOPIC_QOS)) { gapi_free(writerQos); } gapi_free(dataWriterClassName); } return jwriter; }
/** * Class: org_opensplice_dds_dcps_SubscriberImpl * Method: jniCreateDatareader * Signature: (LDDS/TopicDescription;LDDS/DataReaderQos;LDDS/DataReaderListener;)LDDS/DataReader; */ JNIEXPORT jobject JNICALL SAJ_FUNCTION(jniCreateDatareader)( JNIEnv *env, jobject jsubscriber, jobject jdescription, jobject jqos, jobject jlistener, jint jmask) { jobject jreader; jobject jtypeSupport; gapi_subscriber subscriber; gapi_dataReader reader; gapi_dataReaderQos* readerQos; gapi_domainParticipant participant; gapi_typeSupport typeSupport; gapi_string typeName; gapi_topicDescription description; struct gapi_dataReaderListener *listener; gapi_char* dataReaderClassName; gapi_char* signature; saj_returnCode rc; listener = NULL; jreader = NULL; reader = GAPI_OBJECT_NIL; subscriber = (gapi_subscriber) saj_read_gapi_address(env, jsubscriber); participant = gapi_subscriber_get_participant(subscriber); description = (gapi_topicDescription) saj_read_gapi_address(env, jdescription); typeName = gapi_topicDescription_get_type_name(description); typeSupport = gapi_domainParticipant_get_typesupport(participant, (const gapi_char*) typeName); gapi_free(typeName); jtypeSupport = saj_read_java_address((gapi_object)typeSupport); rc = saj_LookupTypeSupportDataReader(env, jtypeSupport, &dataReaderClassName); if(rc == SAJ_RETCODE_OK){ if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAREADER_QOS_DEFAULT)) == JNI_TRUE) { readerQos = (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_DEFAULT; rc = SAJ_RETCODE_OK; } else if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAREADER_QOS_USE_TOPIC_QOS)) == JNI_TRUE) { readerQos = (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_USE_TOPIC_QOS; rc = SAJ_RETCODE_OK; } else { readerQos = gapi_dataReaderQos__alloc(); rc = saj_DataReaderQosCopyIn(env, jqos, readerQos); } if(rc == SAJ_RETCODE_OK){ listener = saj_dataReaderListenerNew(env, jlistener); reader = gapi_subscriber_create_datareader(subscriber, description, readerQos, listener, (gapi_statusMask)jmask); if (reader != GAPI_OBJECT_NIL){ rc = saj_LookupTypeSupportConstructorSignature(env, jtypeSupport, &signature); if(rc == SAJ_RETCODE_OK){ gapi_subscriberQos *sqos = gapi_subscriberQos__alloc(); rc = saj_construct_typed_java_object(env, dataReaderClassName, (PA_ADDRCAST)reader, &jreader, signature, jtypeSupport); gapi_free(signature); if(listener != NULL){ saj_write_java_listener_address(env, reader, listener->listener_data); } if(sqos){ if(gapi_subscriber_get_qos(subscriber, sqos) == GAPI_RETCODE_OK){ if(sqos->entity_factory.autoenable_created_entities) { gapi_entity_enable(reader); } } gapi_free(sqos); } } } else if(listener != NULL){ saj_listenerDataFree(env, saj_listenerData(listener->listener_data)); } } if ((readerQos != (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_DEFAULT) && (readerQos != (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_USE_TOPIC_QOS)) { gapi_free(readerQos); } gapi_free(dataReaderClassName); } return jreader; }