Commit 95912b24 authored by Ryan Berkheimer's avatar Ryan Berkheimer
Browse files

remove inadvertently added resources.

parent 509c9e35
Pipeline #5806 failed with stage
in 0 seconds
#ifndef _CONDITIONUTILS_H
#define _CONDITIONUTILS_H
#include <jni.h>
#include <stdbool.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include <iostream>
#include <string>
#include "JniUtils.h"
#include "ListUtils.h"
#include "MapUtils.h"
/**
* This is the header for the ConditionUtils class.
* A record contains fields and conditions.
*/
class ConditionUtils
{
public:
/*Default constructor/destructors*/
ConditionUtils(JNIEnv *javaEnv, TypeUtils *typeUtils, ListUtils *listUtils, MapUtils *mapUtils);
~ConditionUtils();
/*API Methods*/
const char *getId(struct condition *condition);
const char *getType(struct condition *condition);
const char *getOperator(struct condition *condition);
bool isNull(struct condition *condition);
struct val *getVal(struct condition *condition);
int getIntVal(struct condition *condition);
long getLongVal(struct condition *condition);
float getFloatVal(struct condition *condition);
double getDoubleVal(struct condition *condition);
signed char getByteVal(struct condition *condition);
const char *getStringVal(struct condition *condition);
bool getBoolVal(struct condition *condition);
short getShortVal(struct condition *condition);
struct val_list *getListVal(struct condition *condition);
struct val_map *getMapVal(struct condition *condition);
void setVal(struct condition *condition, struct val *value);
void setIntVal(struct condition *condition, int value);
void setLongVal(struct condition *condition, long value);
void setFloatVal(struct condition *condition, float value);
void setDoubleVal(struct condition *condition, double value);
void setByteVal(struct condition *condition, signed char value);
void setStringVal(struct condition *condition, const char *value);
void setBoolVal(struct condition *condition, bool value);
void setShortVal(struct condition *condition, short value);
void setListVal(struct condition *condition, struct val_list *value);
void setMapVal(struct condition *condition, struct val_map *value);
private:
/*Vars*/
JNIEnv *jvm;
ListUtils *listUtils;
TypeUtils *typeUtils;
MapUtils *mapUtils;
/*Condition Methods*/
jmethodID getIdMethodId;
jmethodID getTypeMethodId;
jmethodID getOperatorMethodId;
jmethodID getValueMethodId;
jmethodID setValueMethodId;
/*Load method IDS for reuse. MethodIDS do not count against the jref count and do need to be released.*/
void loadMethodIds();
void loadGlobalRefs(JNIEnv *env, TypeUtils *typeUtils, ListUtils *listUtils, MapUtils *mapUtils);
/*Grouped methods for returning the matching method signature string for a given interface*/
const char *getMethodSignature(const char *methodName);
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _ENDPOINTUTILS_H
#define _ENDPOINTUTILS_H
#include <jni.h>
#include <stdbool.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include <iostream>
#include <string>
#include "JniUtils.h"
#include "ListUtils.h"
#include "TypeUtils.h"
/**
* This is the header for the EndpointUtils class.
* An endpoint, or endpoint connection, is a terminus for a given process. Endpoint connections
* consume records, evaluate containers, send and/or retrieve data, and create and return
* packets containing a return record/rejection set. This set of utils contains all API methods
* exposed to the user that can manipulate system properties directly managed by endpoints.
* Native endpoint connections also have access to a special construct called a state container.
* This state container is a regular record that is persistent through multiple endpoint connection
* calls.
*
* @author Ryan Berkheimer
*/
class EndpointUtils
{
public:
/*Default constructor/destructors*/
EndpointUtils(JNIEnv *javaEnv, jobject endpoint, TypeUtils *typeUtils, ListUtils *listUtils);
~EndpointUtils();
/*Endpoint Methods*/
struct record *getStateContainer();
struct field_list *getDefaultFields();
struct val_map *getConstructor();
struct packet *createPacket();
struct record *createRecord();
struct rejection *createRejection(struct record *record, const char *reason);
private:
/*Vars*/
JNIEnv *jvm;
jobject endpoint;
TypeUtils *typeUtils;
ListUtils *listUtils;
/*Endpoint Methods*/
jmethodID getStateContainerMethodId;
jmethodID getDefaultFieldsMethodId;
jmethodID getConstructorMethodId;
jmethodID createPacketMethodId;
jmethodID createRecordMethodId;
jmethodID createRejectionMethodId;
/*Load method IDS for reuse. MethodIDS do not count against the jref count and do need to be released.*/
void loadMethodIds();
void loadGlobalRefs(JNIEnv *env, jobject endpoint, TypeUtils *typeUtils, ListUtils *listUtils);
const char *getMethodSignature(const char *methodName);
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _FIELDUTILS_H
#define _FIELDUTILS_H
#include <jni.h>
#include <stdbool.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include <iostream>
#include <string>
#include "JniUtils.h"
#include "TypeUtils.h"
#include "ListUtils.h"
#include "MapUtils.h"
/**
* This is the header for the FieldUtils class.
* A record contains fields and conditions.
*/
class FieldUtils
{
public:
/*Default constructor/destructors*/
FieldUtils(JNIEnv *javaEnv, TypeUtils *typeUtils, ListUtils *listUtils, MapUtils *mapUtils);
~FieldUtils();
/*Field Methods*/
const char *getId(struct field *field);
const char *getType(struct field *field);
bool isValid(struct field *field);
bool isRequired(struct field *field);
bool isNull(struct field *field);
struct val *getVal(struct field *field);
int getIntVal(struct field *field);
long getLongVal(struct field *field);
float getFloatVal(struct field *field);
double getDoubleVal(struct field *field);
signed char getByteVal(struct field *field);
const char *getStringVal(struct field *field);
bool getBoolVal(struct field *field);
short getShortVal(struct field *field);
struct val_list *getListVal(struct field *field);
struct val_map *getMapVal(struct field *field);
void setVal(struct field *field, struct val *value);
void setIntVal(struct field *field, int value);
void setLongVal(struct field *field, long value);
void setFloatVal(struct field *field, float value);
void setDoubleVal(struct field *field, double value);
void setByteVal(struct field *field, signed char value);
void setStringVal(struct field *field, const char *value);
void setBoolVal(struct field *field, bool value);
void setShortVal(struct field *field, short value);
void setListVal(struct field *field, struct val_list *value);
void setMapVal(struct field *field, struct val_map *value);
private:
/*Vars*/
JNIEnv *jvm;
TypeUtils *typeUtils;
ListUtils *listUtils;
MapUtils *mapUtils;
/*Field Methods*/
jmethodID getIdMethodId;
jmethodID getTypeMethodId;
jmethodID getValueMethodId;
jmethodID isValidMethodId;
jmethodID isRequiredMethodId;
jmethodID setValueMethodId;
/*Load method IDS for reuse. MethodIDS do not count against the jref count and do need to be released.*/
void loadMethodIds();
void loadGlobalRefs(JNIEnv *env, TypeUtils *typeUtils, ListUtils *listUtils, MapUtils *mapUtils);
/*Grouped methods for returning the matching method signature string for a given interface*/
const char *getMethodSignature(const char *methodName);
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _JNIUTILS_H
#define _JNIUTILS_H
#include <jni.h>
#include <string.h>
#ifdef __cplusplus
#include <iostream>
#include <stdlib.h>
/**
* The JniUtils namespace contains methods for general use for JNI interoperability,
* such as retrieving classes, method ids, and throwing java errors.
*/
namespace JniUtils
{
/*Handles errors allowing throws in java code.*/
void checkAndThrow(JNIEnv *jvm, std::string errorMessage);
/*Return a jclass for the provided class name and the jvm context. The passed jvm must have the class loaded already in the classpath.*/
jclass getNamedClass(JNIEnv *jvm, const char *javaClassName);
/*Returns a global class ref from JNI using a static cast. The global ref needs to be explicitly removed.*/
jclass getGlobalClassRef(JNIEnv *jvm, const char *classname);
/*Return a jclass for the provided jobject held by the provided jvm context.*/
jclass getObjectClass(JNIEnv *jvm, jobject javaObject);
/*Lookup a java methodID for the given class, method name, and signature string. Also pass in whether method is class static or not.*/
jmethodID getMethod(JNIEnv *jvm, jclass javaClass, const char *methodName, const char *methodSignature, bool isStatic);
} /*namespace JniUtils*/
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _LISTUTILS_H
#define _LISTUTILS_H
#include <jni.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include "JniUtils.h"
#include "TypeUtils.h"
#include <stdlib.h>
#include <iostream>
/**
* This is the header for the ListUtils object class. ListUtils contains a set of methods used for manipulation of Java Lists
* in C++ or C code. ListUtils is a class to be instantiated so that it remains thread safe for implementors,
* while being able
*/
class ListUtils
{
public:
/* Default constructor for ListUtils */
ListUtils(JNIEnv *env, TypeUtils *typeUtils);
/* Default destructor for ListUtils */
~ListUtils();
/* Utility methods */
struct val_list *createList();
int getListLength(jobject jList);
struct string_list *translateStringList(jobject jList);
/*List Item Retrieval Methods*/
struct list_item *getItem(struct val_list *list, int index);
jobject getObjectItem(struct val_list *list, int index);
int getIntItem(struct val_list *list, int index);
long getLongItem(struct val_list *list, int index);
float getFloatItem(struct val_list *list, int index);
double getDoubleItem(struct val_list *list, int index);
signed char getByteItem(struct val_list *list, int index);
const char *getStringItem(struct val_list *list, int index);
bool getBoolItem(struct val_list *list, int index);
short getShortItem(struct val_list *list, int index);
struct val_list *getListItem(struct val_list *list, int index);
struct val_map *getMapItem(struct val_list *list, int index);
/*List Item Insertion Methods*/
void addItem(struct val_list *list, struct list_item *item);
void addObjectItem(struct val_list *list, jobject val);
void addIntItem(struct val_list *list, int val);
void addLongItem(struct val_list *list, long val);
void addFloatItem(struct val_list *list, float val);
void addDoubleItem(struct val_list *list, double val);
void addByteItem(struct val_list *list, signed char val);
void addStringItem(struct val_list *list, const char *val);
void addBoolItem(struct val_list *list, bool val);
void addShortItem(struct val_list *list, short val);
void addListItem(struct val_list *list, struct val_list *val);
void addMapItem(struct val_list *list, struct val_map *map);
jmethodID createListMethod();
jmethodID getListSizeMethod();
jmethodID getListItemMethod();
jmethodID addListItemMethod();
private:
JNIEnv *jvm;
TypeUtils *typeUtils;
jmethodID createListMethodId;
jmethodID getListSizeMethodId;
jmethodID getListItemMethodId;
jmethodID addListItemMethodId;
/* Initialization Methods */
void loadGlobalRefs(JNIEnv *env, TypeUtils *TypeUtils);
void loadMethodIds();
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _MAPUTILS_H
#define _MAPUTILS_H
#include <jni.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include <stdlib.h>
#include <iostream>
#include "JniUtils.h"
#include "TypeUtils.h"
#include "ListUtils.h"
/**
* This is the header for the MapUtils object class. MapUtils contains a set of methods used for manipulation of Java Maps
* in C++ or C code. MapUtils is a class to be instantiated so that it remains thread safe for implementors.
*/
class MapUtils
{
public:
/* Default constructor for ListUtils */
MapUtils(JNIEnv *env, TypeUtils *typeUtils);
/* Default destructor for ListUtils */
~MapUtils();
/* Utility methods */
struct val_map *createMap();
int getSize(struct val_map *map);
bool hasKey(struct val_map *map, const char *key);
/*Map Value Retrieval Methods*/
struct map_val *getVal(struct val_map *map, const char *key);
jobject getObjectVal(struct val_map *map, const char *key);
int getIntVal(struct val_map *map, const char *key);
long getLongVal(struct val_map *map, const char *key);
float getFloatVal(struct val_map *map, const char *key);
double getDoubleVal(struct val_map *map, const char *key);
signed char getByteVal(struct val_map *map, const char *key);
const char *getStringVal(struct val_map *map, const char *key);
bool getBoolVal(struct val_map *map, const char *key);
short getShortVal(struct val_map *map, const char *key);
struct val_list *getListVal(struct val_map *map, const char *key);
struct val_map *getMapVal(struct val_map *map, const char *key);
/*Insert or Update Methods*/
void putVal(struct val_map *map, const char *key, struct map_val *val);
void putObjectVal(struct val_map *map, const char *key, jobject val);
void putIntVal(struct val_map *map, const char *key, int val);
void putLongVal(struct val_map *map, const char *key, long val);
void putFloatVal(struct val_map *map, const char *key, float val);
void putDoubleVal(struct val_map *map, const char *key, double val);
void putByteVal(struct val_map *map, const char *key, signed char val);
void putStringVal(struct val_map *map, const char *key, const char *val);
void putBoolVal(struct val_map *map, const char *key, bool val);
void putShortVal(struct val_map *map, const char *key, short val);
void putListVal(struct val_map *map, const char *key, struct val_list *val);
void putMapVal(struct val_map *map, const char *key, struct val_map *val);
jmethodID createMapMethod();
jmethodID getSizeMethod();
jmethodID hasKeyMethod();
jmethodID getValueMethod();
jmethodID putValueMethod();
private:
JNIEnv *jvm;
TypeUtils *typeUtils;
ListUtils *listUtils;
jmethodID createMapMethodId;
jmethodID getSizeMethodId;
jmethodID hasKeyMethodId;
jmethodID getValueMethodId;
jmethodID putValueMethodId;
/* Initialization Methods */
void loadGlobalRefs(JNIEnv *env, TypeUtils *TypeUtils);
void loadMethodIds();
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef _Included_MessageApiEndpoint
#define _Included_MessageApiEndpoint
#include <jni.h>
#include <stdbool.h>
#include "messageapi_structs.h"
#ifdef __cplusplus
#include <iostream>
#include <string>
#include "JniUtils.h"
#include "MapUtils.h"
#include "ListUtils.h"
#include "EndpointUtils.h"
#include "ProtocolRecordUtils.h"
#include "RecordUtils.h"
#include "RejectionUtils.h"
#include "FieldUtils.h"
#include "ConditionUtils.h"
#include "PacketUtils.h"
/**
* This is the header for the MessageApiEndpoint class - this class is the native side facility
* for doing endpoint processing and communicating back with the java side. This class holds
* three private vars - a pointer to the jvm where the call originated from, a pointer to the
* endpoint class instance (jobject), and a pointer to the protocol record that holds data for
* this endpoint to process (jobject). To the user of the MessageApiEndpoint library in the native side,
* they will see the entire library as a single jlong. This jlong holds a pointer to this class,
* making it easier for implementors to ignore most of the details of implementation.
* @author Ryan Berkheimer
*/
class MessageApiEndpoint
{
public:
/*Default constructor/destructors*/
MessageApiEndpoint(JNIEnv* javaEnv, jobject jEndpoint, jobject jProtocolRecord);
~MessageApiEndpoint();
/*Utils Accessors*/
EndpointUtils *getEndpointUtils();
ProtocolRecordUtils *getProtocolRecordUtils();
RecordUtils *getRecordUtils();
RejectionUtils *getRejectionUtils();
FieldUtils *getFieldUtils();
ConditionUtils *getConditionUtils();
PacketUtils *getPacketUtils();
ListUtils *getListUtils();
MapUtils *getMapUtils();
TypeUtils *getTypeUtils();
private :
/*Global References*/
JNIEnv *jvm;
jobject endpoint;
jobject protocolRecord;
EndpointUtils *endpointUtils;
ProtocolRecordUtils *protocolRecordUtils;
RecordUtils *recordUtils;
RejectionUtils *rejectionUtils;
FieldUtils *fieldUtils;
ConditionUtils *conditionUtils;
PacketUtils *packetUtils;
TypeUtils *typeUtils;
ListUtils *listUtils;
MapUtils *mapUtils;
};
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif