Class LocalOptimizationUtil
- java.lang.Object
-
- org.technologybrewery.fermenter.stout.client.service.LocalOptimizationUtil
-
public final class LocalOptimizationUtil extends Object
Utility methods leverages to perform locally optimized delegate calls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classLocalOptimizationUtil.BusinessObjectCollectionJsonOutputStreamConverts an OutputStream into an InputStream via an underlying Pipes implementation to prevent loading the entire object into memory for a ValueServiceResponse-> ValueServiceResponse transformation. classLocalOptimizationUtil.BusinessObjectJsonOutputStreamConverts an OutputStream into an InputStream via an underlying Pipes implementation to prevent loading the entire object into memory for a ValueServiceResponse-> ValueServiceResponse transformation. classLocalOptimizationUtil.TransferObjectJsonOutputStreamConverts an OutputStream into an InputStream via an underlying Pipes implementation to prevent loading the entire object into memory for a TransferObject -> BusinessObject transformation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectconvertResponseToTransferObjectListViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).static ObjectconvertResponseToTransferObjectPageWrapperViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Converts a ValueServiceResponsecontaining BusinessObject(s) to a ValueServiceResponse containing TransferObject(s). static ObjectconvertResponseToTransferObjectViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).static ObjectconvertToBusinessObjectViaJson(Collection<? extends TransferObject> transferObjectList, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Converts a List of TransferObjects to a List of corresponding BusinessObjects.static ObjectconvertToBusinessObjectViaJson(FindByExampleCriteria<? extends TransferObject> criteria, com.fasterxml.jackson.databind.ObjectMapper objectMapper)ConvertsFindByExampleCriteriawith a TransferObject probe to a one containing the equivalent BusinessObject probe.static ObjectconvertToBusinessObjectViaJson(TransferObject transferObject, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Converts a TransferObject to a corresponding BusinessObject.static com.fasterxml.jackson.databind.ObjectMappergetObjectMapper(String objectMapperManagerClassName)Looks up a ObjectMapperManager via reflection to avoid compile-time coupling between client and domain modules.static booleanisLocalServicePresent(String serviceClassName)Checks to see if a local service is present for optimization.static Class<?>lookupBusinessObjectClassByTransferObject(Class<? extends TransferObject> transferObjectClass)Finds the BusinessObject class corresponding to a given TransferObject class.static Class<?>lookupClassByName(String className)Normal Class.forName(), but with implicit exception handling for cleaner overall code in this and related classes.
-
-
-
Method Detail
-
isLocalServicePresent
public static boolean isLocalServicePresent(String serviceClassName)
Checks to see if a local service is present for optimization. Requires that the class is in the classpath AND that service is registered and available via Spring. If only the class is available, but the Spring bean is not, will emit a warning.- Parameters:
serviceClassName- fully qualified class name of the service- Returns:
- whether or not a local optimization is available
-
convertToBusinessObjectViaJson
public static Object convertToBusinessObjectViaJson(Collection<? extends TransferObject> transferObjectList, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Converts a List of TransferObjects to a List of corresponding BusinessObjects.- Parameters:
transferObjectList- list of transfer objectsobjectMapper- ObjectMapper to perform the transformation- Returns:
- list of business objects
-
convertToBusinessObjectViaJson
public static Object convertToBusinessObjectViaJson(FindByExampleCriteria<? extends TransferObject> criteria, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
ConvertsFindByExampleCriteriawith a TransferObject probe to a one containing the equivalent BusinessObject probe.- Parameters:
criteria- criteria containing a TransferObject probeobjectMapper- ObjectMapper to perform the transformation- Returns:
- equivalent criteria containing a BusinessObject probe
-
convertToBusinessObjectViaJson
public static Object convertToBusinessObjectViaJson(TransferObject transferObject, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Converts a TransferObject to a corresponding BusinessObject.- Parameters:
transferObject- list of transfer objectsobjectMapper- ObjectMapper to perform the transformation- Returns:
- business object
-
convertResponseToTransferObjectViaJson
public static Object convertResponseToTransferObjectViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).- Parameters:
input- the inbound ValueServiceResponsetransferObjectTargetClass- the transfer object class we want to have in the resultobjectMapper- ObjectMapper to perform the transformation- Returns:
- a ValueServiceResponse with a TransferObject-based payload
-
convertResponseToTransferObjectListViaJson
public static Object convertResponseToTransferObjectListViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Converts a ValueServiceResponse containing BusinessObject(s) to a ValueServiceResponse containing TransferObject(s).- Parameters:
input- the inbound ValueServiceResponsetransferObjectTargetClass- the transfer object class we want to have in the resultobjectMapper- ObjectMapper to perform the transformation- Returns:
- a ValueServiceResponse with a TransferObject-based payload
-
convertResponseToTransferObjectPageWrapperViaJson
public static Object convertResponseToTransferObjectPageWrapperViaJson(Object input, Class<?> transferObjectTargetClass, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Converts a ValueServiceResponsecontaining BusinessObject(s) to a ValueServiceResponse containing TransferObject(s). - Parameters:
input- the inbound ValueServiceResponsetransferObjectTargetClass- the transfer object class we want to have in the resultobjectMapper- ObjectMapper to perform the transformation- Returns:
- a ValueServiceResponse
with a TransferObject-based payload
-
lookupBusinessObjectClassByTransferObject
public static Class<?> lookupBusinessObjectClassByTransferObject(Class<? extends TransferObject> transferObjectClass)
Finds the BusinessObject class corresponding to a given TransferObject class.- Parameters:
transferObjectClass- the specific Transfer object class (e.g., foo.bar.SimpleDomain)- Returns:
- the specific BusinessObject class (e.g., foo.bar.SimpleDomainBO)
-
lookupClassByName
public static Class<?> lookupClassByName(String className)
Normal Class.forName(), but with implicit exception handling for cleaner overall code in this and related classes.- Parameters:
className- fully qualified class name to lookup- Returns:
- the Class for that lookup value (or an UnrecoverableException, if not found)
-
getObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper(String objectMapperManagerClassName)
Looks up a ObjectMapperManager via reflection to avoid compile-time coupling between client and domain modules.- Parameters:
objectMapperManagerClassName- fully qualified class name of the ObjectMapperManager to lookup- Returns:
- the resulting instance or an UnrecoverableException, if not found
-
-