Skip to content

Commit

Permalink
Pre-testing checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Dec 5, 2024
1 parent f0ecf4a commit 5bf5f7a
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
*/
public class MqttRequestResponse {

private final String topic;
private final byte[] payload;
private String topic;
private byte[] payload;

private MqttRequestResponse(String topic, byte []payload) {
this.topic = topic;
this.payload = payload;
private MqttRequestResponse() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@
{
"name": "<init>",
"parameterTypes": []
},
{
"name": "get",
"parameterTypes": [
"int"
]
},
{
"name": "size",
"parameterTypes": []
}
]
},
Expand Down Expand Up @@ -956,6 +966,23 @@
}
]
},
{
"name": "software.amazon.awssdk.crt.iot.MqttRequestResponse",
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
],
"fields": [
{
"name": "topic"
},
{
"name": "payload"
}
]
},
{
"name": "software.amazon.awssdk.crt.iot.RequestResponseOperation",
"fields": [
Expand Down
19 changes: 19 additions & 0 deletions src/native/java_class_ids.c
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,24 @@ static void s_cache_request_response_operation_properties(JNIEnv *env) {
AWS_FATAL_ASSERT(request_response_operation_properties.correlation_token_field_id);
}

struct java_mqtt_request_response_properties mqtt_request_response_properties;

static void s_cache_mqtt_request_response_properties(JNIEnv *env) {
jclass cls = (*env)->FindClass(env, "software/amazon/awssdk/crt/iot/MqttRequestResponse");
AWS_FATAL_ASSERT(cls);

mqtt_request_response_properties.mqtt_request_response_class = (*env)->NewGlobalRef(env, cls);

mqtt_request_response_properties.constructor_method_id =
(*env)->GetMethodID(env, mqtt_request_response_properties.mqtt_request_response_class, "<init>", "()V");

mqtt_request_response_properties.topic_field_id = (*env)->GetFieldID(env, cls, "topic", "Ljava/lang/String;");
AWS_FATAL_ASSERT(mqtt_request_response_properties.topic_field_id);

mqtt_request_response_properties.payload_field_id = (*env)->GetFieldID(env, cls, "payload", "[B");
AWS_FATAL_ASSERT(mqtt_request_response_properties.payload_field_id);
}

static void s_cache_java_class_ids(void *user_data) {
JNIEnv *env = user_data;
s_cache_http_request_body_stream(env);
Expand Down Expand Up @@ -2482,6 +2500,7 @@ static void s_cache_java_class_ids(void *user_data) {
s_cache_topic_aliasing_options(env);
s_cache_response_path_properties(env);
s_cache_request_response_operation_properties(env);
s_cache_mqtt_request_response_properties(env);
}

static aws_thread_once s_cache_once_init = AWS_THREAD_ONCE_STATIC_INIT;
Expand Down
9 changes: 9 additions & 0 deletions src/native/java_class_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,15 @@ struct java_request_response_operation_properties {
};
extern struct java_request_response_operation_properties request_response_operation_properties;

/* MqttRequestResponse */
struct java_mqtt_request_response_properties {
jclass mqtt_request_response_class;
jmethodID constructor_method_id;
jfieldID topic_field_id;
jfieldID payload_field_id;
};
extern struct java_mqtt_request_response_properties mqtt_request_response_properties;

/**
* All functions bound to JNI MUST call this before doing anything else.
* This caches all JNI IDs the first time it is called. Any further calls are no-op; it is thread-safe.
Expand Down
Loading

0 comments on commit 5bf5f7a

Please sign in to comment.