no.mnemonic.services.common.api.ResultSetExtender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of service-api Show documentation
Show all versions of service-api Show documentation
Common basic API and interfaces for services
package no.mnemonic.services.common.api;
import java.util.HashMap;
import java.util.Map;
/**
* A ResultSetExtender allows a service to extend the base format of a ResultSet
,
* in particular to add data to the top level object which is not supported
* by the ServiceProxy transport mechanism.
*
* It uses the ServiceProxyMetaDataContext
to carry any extra data as metadata,
* and recreating the ResultSet
subclass on the client side.
*
* The extender implementation is responsible for extracting metadata (which is not carried by the ResultSet base class)
* into metadata, and re-create the ResultSet subclass using the same metadata on the client side.
*
* Note: The meaning of keys and value of the value format of the metadata map is convention based,
* and not something that the framework cares about. The server/client implementation should align with
* which keys are used for what, and what is the expected data format.
* For this implementation, the server and client implementations are in the same class, so that should be doable.
*
*/
public interface ResultSetExtender {
/**
* Implement how to extend a generic ResultSet to a subtype, optionally using service proxy metaData
* @param resultSet the vanilla ResultSet received from the service proxy
* @param metaData any metadata sent with the ResultSet from the service proxy
* @return the extended ResultSet object
*/
T extend(ResultSet resultSet, Map metaData);
/**
* Extract service proxy metadata from an extended ResultSet object (on the server side)
*
* @param extendedResultSet the extended ResultSet object
* @return the metadata to pass to the service client
*/
default Map extract(T extendedResultSet) {
return new HashMap<>();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy