Commit Graph

88 Commits

Author SHA1 Message Date
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
cc257f5ef9 Edit Javadoc.
Resolves gh-67.
2020-05-12 19:05:37 -07:00
John Blum
b1ec1dbab2 Delegate all cach instance operations to org.springframework.geode.util.CacheUtils. 2020-05-11 00:02:41 -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
a855787b66 Include Jackson JSON serializers for BigDecimals and BigIntegers as well as generating typeless Collection JSON.
Resolves gh-67.
2020-05-08 01:44:39 -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
8418082a00 Remove unnecessary ObjectMapper configuration used specifically for deserialization.
Clearly, this configuration is 'unnecessary' because the ObjectMapper is used to serialize Objects to JSON in this converter.

Removes Mixin that virtually annotated application domain model object types with @JsonIgnoreProperties for unknown/unmapped properties.

Removes configuration to accept case insensitive Enum (String) values.

Resolves gh-67.
2020-05-08 00:54:41 -07:00
John Blum
a3faf2584a Configure the ObjectMapper used to convert (serialize) Objects to JSON with Jackson.
Activates default typing using a property.

Adds Mixin to virtually annotate application domain model object types with @JsonTypeInfo.

Adds Mixin to virtually annotate application domain model object types with @JsonIgnoreProperties for unknown/unmapped properties.

Configures JsonGenerator to write BigDecimal values as a plain String.

Configures ObjectMapper to accept case insensitive Enum (String) values.

Configures ObjectMapper to sort properties alphabetically in JSON.

Registers SimpleModule with customer JsonSerializers for java.math.BigDecimal and java.math.BigInteger as well as to render typeless Collections.

Resolves gh-67.
2020-05-08 00:54:41 -07:00
John Blum
2627cf7a90 Change ObjectToJsonConverter implementation from JacksonObjectToJsonConverter to JSONFormatterPdxToJsonConverter.
Note that JSONFormatterPdxToJsonConverter extends JacksonObjectToJsonConverter and adds the capability to convert (serialize) PDX to JSON in addition to Objects.

Resolves gh-67.
2020-05-07 22:16:51 -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
bbef166670 Edit Javadoc.
Resolves gh-67.
2020-05-06 00:13:17 -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
ec20642cc1 Add ObjectToJsonConverter interface specifying a contract for converting an Object to JSON.
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
a0ead741ab Add implementation of CacheDataImporter/Exporter to import/export JSON sourced data.
Resolves gh-67.
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
76ef0e7062 Introduce CacheDataImporterExporter interface extending the CacheDataImporter and CacheDataExporter interfaces.
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
b1e9a30e10 Override ApplicationContext prepareRefresh() and onRefresh() methods.
Add option to copy configuration from the pre-refresh BeanFactory to the post-refresh BeanFactory instance.

Apply appropriate Spring @NonNull and @Nullable annotations.

Edit Javadoc.
2020-04-27 14:18:45 -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
John Blum
d90dbf6f7a Use wildcard generic type signature in declaration of the 'VCAP_REQUIRED_PROPERTIES_PREDICATE' Predicate of a parameterized PropertySource type.
Remove unnecessary @SuppressWarnings('all') annotation from iterator() method.
2020-03-18 20:23:04 -07:00
John Blum
8447eaad10 Update Copyright to 2020. 2020-02-19 23:04:23 -08:00
John Blum
1969f89492 Add GeodeLoggingApplicationListener registered with Spring Boot to handle backwards compatibility and existing logging configuration expressed with SDG.
User may configure logging using @ClientCacheApplication(logLevel = INFO), or by annotating their Spring application class with @EnableLogging(logLevel = INFO) or using 1 of SDG's logging configuration properties ['spring.data.gemfire.cache.log-level', 'spring.data.gemfire.logging.level'], therefore, SBDG makes a best attempt to honor those logging configuration settings.

Resolves gh-73.
2020-02-14 15:19:14 -08:00
John Blum
f21900d0c8 Cleanup compiler warnings.
Apply wildcard generic type signature to PropertySource object reference in order to avoid the rawtype usage warning.

Annotate ClusterAwareCondition.match(..) and ClusterAwareCondition.getConfiguredConnectionEndpoints(..) with @SuppressWarnings.
2020-02-04 15:53:00 -08:00
John Blum
b45431fd53 Optimize imports. 2020-01-24 21:17:09 -08:00
John Blum
47b3c01bf4 Improve EnableClusterAware configuration logic to identify Region beans of type CacheTypeAwareRegionFactoryBean.
Resolves gh-66.
2019-11-15 18:53:19 -08:00
John Blum
25960adc4d Add auto-configuration support for TLS using SSL when deploying Spring Boot ClientCache applications to PCF using PCC that requires secure Sockets.
The TLS/SSL auto-configuration enables and configures the use of the SSL default context provided by the JRE, which the ClientCache instance uses to obtain the required CERT necessary when creating SSL Sockets between the client and PCC servers.

Resolves gh-61.
2019-10-17 15:50:26 -07:00
John Blum
4eff04c517 Refactor Cluster-aware Conditions to be CloudFoundry Environment-aware.
Resolves gh-56.
2019-09-24 00:34:36 -07:00
John Blum
0da65d79b9 Fix possible NullPointerException when testing and mocking.
Resolves gh-52.
2019-09-20 13:41:55 -07:00
John Blum
0094fd6ea4 Add Environment/System property to control ClusterAwareCondition matching.
Provide static method ClusterAwareConfiguration.ClusterAwareCondition.isAvailable() to assess whether the cluster was available in application components and act accordingly.

Resolves gh-52.
2019-09-20 13:23:43 -07:00
John Blum
6b4827c9b6 Add TypelessAnnotationConfigSupport class extending SDG's o.s.d.g.config.annotation.support.AbstractAnnotationConfigSupport class, which is not based on any configuration-based annotation, but provides a means to utilize the helper methods. 2019-09-20 01:42:40 -07:00
John Blum
ff3ddaf586 Adds support to properly clean up and 'reset' the ClusterAwareConfiguration.ClusterAwareCondition state on ApplicationContext closed events. 2019-09-12 17:40:08 -07:00
John Blum
8e30b4ddd2 Improve CQ Auto-configuration by assessing the availability of a server or cluster first before enabling and auto-configuring CQ functionality.
This added capabilities relies on the new ClusterAwareConditions.

Resolves gh-53.
2019-09-12 14:28:59 -07:00
John Blum
25cf033095 Format source code; Optimize imports. 2019-09-12 01:09:38 -07:00
John Blum
a616bc52e7 Correct 'beanName' variable spelling in Lambda expression of the clientCacheMemberNameConfigurer and peerCacheMemberNameConfigurer bean definitions.
Optimize imports.
2019-09-12 01:09:38 -07:00