mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#239 - Support Geometric types of Postgres
This commit is contained in:
1 parent
967b4de784
commit
44ad78b5e0
8 files changed
+102
-4
No files matched your search
@@ -12,6 +12,7 @@ import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.DatabasePlatform;
|
||||
import com.avaje.ebean.config.dbplatform.DbPlatformType;
|
||||
import com.avaje.ebean.dbmigration.DbOffline;
|
||||
import com.avaje.ebean.plugin.ExtraTypeFactory;
|
||||
import com.avaje.ebeaninternal.server.core.bootup.BootupClasses;
|
||||
import com.avaje.ebeaninternal.server.type.reflect.CheckImmutable;
|
||||
import com.avaje.ebeaninternal.server.type.reflect.CheckImmutableResponse;
|
||||
@@ -65,9 +66,11 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Currency;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
@@ -208,6 +211,8 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
|
||||
initialiseJodaTypes(jsonDateTime, config);
|
||||
initialiseJacksonTypes(config);
|
||||
|
||||
loadTypesFromProviders(config, objectMapper);
|
||||
|
||||
if (bootupClasses != null) {
|
||||
initialiseCustomScalarTypes(jsonDateTime, bootupClasses);
|
||||
initialiseScalarConverters(bootupClasses);
|
||||
@@ -215,6 +220,24 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load custom scalar types registered via ExtraTypeFactory and ServiceLoader.
|
||||
*/
|
||||
private void loadTypesFromProviders(ServerConfig config, Object objectMapper) {
|
||||
|
||||
ServiceLoader<ExtraTypeFactory> factories = ServiceLoader.load(ExtraTypeFactory.class);
|
||||
Iterator<ExtraTypeFactory> iterator = factories.iterator();
|
||||
if (iterator.hasNext()) {
|
||||
// use the cacheFactory (via classpath service loader)
|
||||
ExtraTypeFactory plugin = iterator.next();
|
||||
List<? extends ScalarType> types = plugin.createTypes(config, objectMapper);
|
||||
for (ScalarType type : types) {
|
||||
logger.debug("adding ScalarType {}", type.getClass());
|
||||
addCustomType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPostgres(DatabasePlatform databasePlatform) {
|
||||
return databasePlatform.getName().toLowerCase().startsWith("postgre");
|
||||
}
|
||||
@@ -707,8 +730,7 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
|
||||
}
|
||||
}
|
||||
|
||||
add(scalarType);
|
||||
customScalarTypes.add(scalarType);
|
||||
addCustomType(scalarType);
|
||||
|
||||
} catch (Exception e) {
|
||||
String msg = "Error loading ScalarType [" + cls.getName() + "]";
|
||||
@@ -717,6 +739,11 @@ public final class DefaultTypeManager implements TypeManager, KnownImmutable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addCustomType(ScalarType<?> scalarType) {
|
||||
add(scalarType);
|
||||
customScalarTypes.add(scalarType);
|
||||
}
|
||||
|
||||
private Object initObjectMapper(ServerConfig serverConfig) {
|
||||
|
||||
Object objectMapper = serverConfig.getObjectMapper();
|
||||
|
||||
Reference in new issue
Block a user