Commit Graph

100 Commits

Author SHA1 Message Date
John Blum
edd0cab1af Add AbstractResourceWriter base class containing operations common to all ResourceWriters.
Resolves gh-92.
2020-07-07 11:23:26 -07:00
John Blum
d2591f7f8c Define ResourceWriter interface for writing data to a resource identified by a Resource handle.
Resolves gh-92.
2020-07-07 11:21:47 -07:00
John Blum
8ed0f24d8b Add ByteArrayResourceReader implementation that reads the data from a Resource (e.g. ClassPathResource) into a byte array.
Resolves gh-92.
2020-07-07 11:20:15 -07:00
John Blum
2b05bc5919 Add AbstractResourceReader base class defining operations common to all ResourceReaders.
Resolves gh-92.
2020-07-07 11:18:33 -07:00
John Blum
2437b0247e Define ResourceReader interface for reading data from a resource identified by a Resource handle.
Ressolves gh-92.
2020-07-07 11:16:36 -07:00
John Blum
01696b15af Refactor and polish JSON and base cache data import/export support. 2020-06-25 17:02:56 -07:00
John Blum
5318782bfb Fix bug to handle cache data import into client LOCAL Regions when no PDX type registry exists.
Resolves gh-91.
2020-06-10 23:16:11 -07:00
John Blum
98ee687a78 Include JacksonJsonToObjectConverter, Spring Converter implementation to convert/map JSON to a POJO using Jackson's ObjectMapper. 2020-06-10 22:24:50 -07:00
John Blum
dd439fe300 Include ObjectPdxInstanceAdapter class to adapt a regular Object (POJO) as an instance of PdxInstance. 2020-06-10 20:03:02 -07:00
John Blum
91a10a8ca1 Move PdxInstance identifier/identity resolution logic from JsonCacheDataImporterExporter to PdxInstanceWrapper. 2020-06-10 12:39:21 -07:00
John Blum
a0b4f60c77 Define Spring Converter interface extension to convert from JSON into an Object array (array of POJOs). 2020-06-10 12:21:35 -07:00
John Blum
2b2e03a764 Define Spring Converter interface extension to convert from JSON into an Object (POJO). 2020-06-10 12:21:35 -07:00
John Blum
db0a00e452 Rename toPdxArray(:byte[]) to toPdx(:byte[]). 2020-06-10 12:21:35 -07:00
John Blum
e05c627e13 Refactor toJson(:Region) to serialize the values from the Region using the AbstractObjectArrayToJsonConverter class and CacheUtils.collectValues(:Region) method. 2020-06-10 12:21:35 -07:00
John Blum
53dda1265b Remove unused and unnecessary code. 2020-06-09 20:47:04 -07:00
John Blum
895378be70 Add Spring Lifecycle-aware CacheDataImporterExporter implementation.
Resolves gh-90.
2020-06-09 14:10:04 -07:00
John Blum
cb291c844e Enable JSON data formatting on export.
Resolves gh-89.
2020-06-09 14:09:57 -07:00
John Blum
b07ca31e51 Add file system appropriate file path separator to Resource location on export. 2020-06-08 15:16:28 -07:00
John Blum
dcfb7eb186 Add configuration property to enable/disable data imports. 2020-05-14 22:32:31 -07:00
John Blum
a63d792898 Add getAtIdentifier(:PdxInstance) method and strategy for resolving ids from PdxInstances.
Add postProcess(:PdxInstance) method to allow subclasses to override the method in order to post process the PdxInstance(s) generated from JSON.

Edit Javadoc.

Rename getIdField(:PdxInstance) to getId(:PdxInstance).

Resolves gh-67.
2020-05-13 00:13:26 -07:00
John Blum
fa9b2e1ae6 Fix infinite recursion bug leading to a StackOverflowError.
Renamed the convertObjectToJson(:Object) method in the JSONFormatterPdxToJsonConverter class to convertPojoToJson(:Object).

Resolves gh-67.
2020-05-12 22:01:22 -07:00
John Blum
8fe13e01fb Add descriptive convertJsonToPdx(..) conversion method.
Add protected jsonFormatterFromJson(..) method to encapsulate the invocation of the JSONFormatter.fromJSON(..) method.

Add wrap(:PdxInstance) method to wrap the PdxInstance generated from JSON in a new instance of PdxInstanceWrapper.

Resolves gh-67.
2020-05-12 19:41:06 -07:00
John Blum
eba12bad17 Configure Jackson ObjectMapper to find and register additional modules declared on the application's classpath.
Resolves gh-67.
2020-05-12 19:23:20 -07:00
John Blum
22b01985b7 Add Integration Tests for JsonCacheDataImporterExporter asserting the functionality in a client/server topology with a ClientCache.
Resolves gh-67.
2020-05-11 00:04:43 -07:00
John Blum
f40685fb4e Refactor JSONFormatterPdxToJsonConverter to handle missing type metadata in both PdxInstances and in JSON, which is required to reconstitute the Object.
Resolves gh-67.
2020-05-10 13:23:47 -07:00
John Blum
30a84eefdd Add additional Integration Tests for JsonCacheDataImporterExporter class.
Added add test cases covering:

* exportImportWithRegionContainingMixOfObjectsAndPdxInstances
* geodeJsonFormatterCannotHandleTypedJsonObjects
* geodeJsonFormatterCannotRememberPdxInstanceClass

Edit Javadoc.

Resolves gh-67.
2020-05-10 00:26:59 -07:00
John Blum
596ea093ba Add null-safe asType(:Object, :Class) method to cast the given source Object into an instance of the given Class type. 2020-05-09 21:07:05 -07:00
John Blum
9dbd290322 Add Integration Tests for JsonCacheDataImporterExporter.
Resolves gh-67.
2020-05-08 01:45:05 -07:00
John Blum
33458ab4be Refactor POS PurchaseOrder application domain model class to include an identifyAs(:Long) builder method to set the ID of a PurchaseOrder instance.
Annotate the PurchaseOrder class with Jackson's JsonTypeInfo annotation.

Include statically defined Array and Map instance members for test purposes.
2020-05-08 01:42:56 -07:00
John Blum
4d7becad79 Simplify ObjectMapper configuration.
Remove activation of default typing configuration.

Change target Class type for ObjectTypeMetadataMixin (Mixin) to the (converted) source object's Class type.

Remove unnecessary SimpleModule registration including the addition of the custom BigDecimalSerializer, BigIntegerSerializer and TypelessCollectionSerializer objects.

Resolves gh-67.
2020-05-08 01:29:26 -07:00
John Blum
5b5e2e5db8 Add abstract base class implementing the ObjectArrayToJsonConverter interface to encapsulate operation common to all implementations.
The abstract base class provides convert methods to convert arrays, Iterables and Map.values(). Additionally it contains support to configure the ObjectToJsonConverter used to convert individual Objects into JSON.

Resolves gh-67.
2020-05-07 21:26:18 -07:00
John Blum
72443e95af Add ObjectArrayToJsonConverter interface specifying a contract to convert an array of Objects to JSON.
Resolves gh-67.
2020-05-07 21:24:09 -07:00
John Blum
9232180643 Add JsonToPdxConverter interface implementation converting JSON to PDX backed by Apache Geode's o.a.g.pdx.JSONFormatter class and Jackson's ObjectMapper.
Resolves gh-67.
2020-05-06 13:27:49 -07:00
John Blum
7f9b36ec18 Adds ObjectToJsonConverter interface implementation using Jackson to convert an Object to JSON.
Resolves gh-67.
2020-05-06 12:20:52 -07:00
John Blum
e76100af47 Add ObjetToJsonConverter interface implementation to convert an Object or PDX to JSON using Apache Geode's o.a.g.pdx.JSONFormatter class.
This converter extends (is backed by) the JacksonObjectToJsonConverter implementation to fallback on Jackson's ObjectMapper if the Object to convert is not a o.a.g.pdx.PdxInstance.

Resolves gh-67.
2020-05-06 11:45:47 -07:00
John Blum
cb3141f0b7 Add JsonToPdxConverter interface implementation to convert JSON to PDX using Apache Geode's o.a.g.pdx.JSONFormatter class.
Resolves gh-67.
2020-05-06 11:42:06 -07:00
John Blum
9f97a8313d Add conditional logic to handle beans of type ResolvableRegionFactoryBean.
Resolves gh-67.
2020-05-06 11:07:52 -07:00
John Blum
68e7b54c90 Refactor importInto(:Region) to parse and convert JSON containing multiple objects into an array of PdxInstances each stored in the Region.
Edit Javadoc.

Resolves gh-67.
2020-05-06 00:43:03 -07:00
John Blum
e67c383de8 Add JsonToPdxArrayConverter interface and Spring Converter extension specifying a contract to convert JSON into PDX, as an array of PdxInstance objects.
Resolves gh-69.
2020-05-06 00:37:31 -07:00
John Blum
8cf6a8b410 Add configurable Product.category as an enumerated type. 2020-05-05 13:40:03 -07:00
John Blum
3f05015b2f Refactor example POS application model classes to be conducive to Jackson's ObjectMapper configuration imposed by GemFire/Geode PDX framework and JSONFormatter class. 2020-05-05 13:15:24 -07:00
John Blum
c3b697e759 Complete base implementation of the JSON CacheDataImporterExporter.
Resolves gh-67.
2020-05-05 11:14:04 -07:00
John Blum
8cb59be29c Add JsonToPdxConverter interface specifying a contract to convert JSON to PDX.
The JSON may be expressed as a byte[] or a String.

Resolves gh-67.
2020-05-05 11:14:04 -07:00
John Blum
98c976fe6c Add example application model classes for a PurchaseOrder in a Point-of-Sale (POS) system. 2020-05-05 11:14:04 -07:00
John Blum
074fd7f1ed Add java.util.function.Predicate on Region to filter Regions on data import/export.
Add protected getLogger() method returning a SLF4J Logger to log messages and events during data import/export operations.

Format source code.

Resolves gh-67.
2020-05-05 11:14:04 -07:00
John Blum
1b44a80830 Add abstract base class implementation of the CacheDataImporterExporter interface to correctly manage data exports and imports based on application and Environment (context) configuration.
Resolves gh-67.
2020-05-05 11:14:04 -07:00
John Blum
1a19c228be Introduce new CacheDataImporter and CacheDataExporter interfaces to import and export data into and out from a GemFire/Geode cache on startup.
These new interfaces and APIs are intended to be used in SBDG's auto-configuration when the Spring Boot app using Apache Geode starts up in order to load or save data.

Resolves gh-67.
2020-05-05 11:14:04 -07:00
John Blum
46722ea9c4 Add ApplicationContextMembershipListener implementation and extension of MembershipListenerAdapter to adapt the Spring ApplicationContext to handle peer member departed and joined membership events. 2020-04-27 15:16:42 -07:00
John Blum
2deb202c21 Add new AbstractContextLoader implementation and extension to the Spring TestContext Framework to configure and bootstrap the RefreshableAnnotationConfigApplicationContext used in Spring based tests. 2020-04-27 14:18:45 -07:00
John Blum
e8ddc1f744 Introduce new Spring ApplicationContext implementation and extension that is Refreshable and can be configured with Annotations. 2020-04-27 14:18:45 -07:00