/** * Return true if the given class is present. */ public boolean isPresent(String className) { try { forName(className); return true; } catch (Throwable ex) { // Class or one of its dependencies is not present... return false; } }
/** * Return the service loader using the classLoader defined in ClassLoadConfig. */ public <T> ServiceLoader<T> serviceLoad(Class<T> spiService) { return ServiceLoader.load(spiService, classLoadConfig.getClassLoader()); }
ReadAnnotationConfig(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, ServerConfig serverConfig) { this.generatedPropFactory = generatedPropFactory; this.asOfViewSuffix = asOfViewSuffix; this.versionsBetweenSuffix = versionsBetweenSuffix; this.disableL2Cache = serverConfig.isDisableL2Cache(); this.eagerFetchLobs = serverConfig.isEagerFetchLobs(); this.javaxValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJavaxValidationAnnotationsPresent(); this.jacksonAnnotations = generatedPropFactory.getClassLoadConfig().isJacksonAnnotationsPresent(); }
InternalConfigXmlRead(ServerConfig serverConfig) { this.serverConfig = serverConfig; this.classLoader = serverConfig.getClassLoadConfig().getClassLoader(); if (serverConfig.getClassLoadConfig().isJavaxJAXBPresent()) { init(); } }
public InsertTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedInsertTimestamp()); map.put(java.util.Date.class, new GeneratedInsertDate()); map.put(Long.class, longTime); map.put(long.class, longTime); if (classLoadConfig.isJavaTimePresent()) { map.put(Instant.class, new GeneratedInsertJavaTime.InstantDT()); map.put(LocalDateTime.class, new GeneratedInsertJavaTime.LocalDT()); map.put(OffsetDateTime.class, new GeneratedInsertJavaTime.OffsetDT()); map.put(ZonedDateTime.class, new GeneratedInsertJavaTime.ZonedDT()); } if (classLoadConfig.isJodaTimePresent()) { map.put(org.joda.time.LocalDateTime.class, new GeneratedInsertJodaTime.LocalDT()); map.put(org.joda.time.DateTime.class, new GeneratedInsertJodaTime.DateTimeDT()); } }
/** * Create the DefaultTypeManager. */ public DefaultTypeManager(ServerConfig config, BootupClasses bootupClasses) { this.java7Present = config.getClassLoadConfig().isJava7Present(); this.jsonDateTime = config.getJsonDateTime(); this.typeMap = new ConcurrentHashMap<>(); this.nativeMap = new ConcurrentHashMap<>(); this.logicalMap = new ConcurrentHashMap<>(); this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent(); this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null; this.extraTypeFactory = new DefaultTypeFactory(config); this.postgres = isPostgres(config.getDatabasePlatform()); this.arrayTypeListFactory = arrayTypeListFactory(config.getDatabasePlatform()); this.arrayTypeSetFactory = arrayTypeSetFactory(config.getDatabasePlatform()); this.offlineMigrationGeneration = DbOffline.isGenerateMigration(); initialiseStandard(jsonDateTime, config); initialiseJavaTimeTypes(jsonDateTime, config); initialiseJodaTypes(jsonDateTime, config); initialiseJacksonTypes(config); loadTypesFromProviders(config, objectMapper); if (bootupClasses != null) { initialiseCustomScalarTypes(bootupClasses); initialiseScalarConverters(bootupClasses); initialiseAttributeConverters(bootupClasses); } }
private CurrentModel(SpiEbeanServer server, DbConstraintNaming constraintNaming, boolean platformTypes) { this.server = server; this.constraintNaming = constraintNaming; this.maxLength = maxLength(server, constraintNaming); this.platformTypes = platformTypes; this.jaxbPresent = server.getServerConfig().getClassLoadConfig().isJavaxJAXBPresent(); }
/** * Construct for the owning many property. */ BeanPropertyAssocManyJsonHelp(BeanPropertyAssocMany<?> many) { this.many = many; boolean objectMapperPresent = many.getBeanDescriptor().getServerConfig().getClassLoadConfig().isJacksonObjectMapperPresent(); this.jsonTransient = !objectMapperPresent ? null : new BeanPropertyAssocManyJsonTransient(); }
BeanLifecycleAdapterFactory(ServerConfig serverConfig) { this.postConstructPresent = serverConfig.getClassLoadConfig().isJavaxPostConstructPresent(); }
/** * Detect if Joda classes are in the classpath and if so register the Joda data types. */ @SuppressWarnings("deprecation") private void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { // detect if Joda classes are in the classpath if (config.getClassLoadConfig().isJodaTimePresent()) { // Joda classes are in the classpath so register the types logger.debug("Registering Joda data types"); addType(LocalDateTime.class, new ScalarTypeJodaLocalDateTime(mode)); addType(DateTime.class, new ScalarTypeJodaDateTime(mode)); addType(LocalDate.class, new ScalarTypeJodaLocalDate()); addType(org.joda.time.DateMidnight.class, new ScalarTypeJodaDateMidnight()); addType(org.joda.time.Period.class, new ScalarTypeJodaPeriod()); String jodaLocalTimeMode = config.getJodaLocalTimeMode(); if ("normal".equalsIgnoreCase(jodaLocalTimeMode)) { // use the expected/normal local time zone addType(LocalTime.class, new ScalarTypeJodaLocalTime()); logger.debug("registered ScalarTypeJodaLocalTime"); } else if ("utc".equalsIgnoreCase(jodaLocalTimeMode)) { // use the old UTC based addType(LocalTime.class, new ScalarTypeJodaLocalTimeUTC()); logger.debug("registered ScalarTypeJodaLocalTimeUTC"); } } }
private void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { if (java7Present) { typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); } if (config.getClassLoadConfig().isJavaTimePresent()) { logger.debug("Registering java.time data types"); addType(java.time.Period.class, new ScalarTypePeriod()); addType(java.time.LocalDate.class, new ScalarTypeLocalDate()); addType(java.time.LocalDateTime.class, new ScalarTypeLocalDateTime(mode)); addType(OffsetDateTime.class, new ScalarTypeOffsetDateTime(mode)); addType(ZonedDateTime.class, new ScalarTypeZonedDateTime(mode)); addType(Instant.class, new ScalarTypeInstant(mode)); addType(DayOfWeek.class, new ScalarTypeDayOfWeek()); addType(Month.class, new ScalarTypeMonth()); addType(Year.class, new ScalarTypeYear()); addType(YearMonth.class, new ScalarTypeYearMonthDate()); addType(MonthDay.class, new ScalarTypeMonthDay()); addType(OffsetTime.class, new ScalarTypeOffsetTime()); addType(ZoneId.class, new ScalarTypeZoneId()); addType(ZoneOffset.class, new ScalarTypeZoneOffset()); boolean localTimeNanos = config.isLocalTimeWithNanos(); addType(java.time.LocalTime.class, (localTimeNanos) ? new ScalarTypeLocalTimeWithNanos() : new ScalarTypeLocalTime()); boolean durationNanos = config.isDurationWithNanos(); addType(Duration.class, (durationNanos) ? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); } }
public UpdateTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedUpdateTimestamp()); map.put(java.util.Date.class, new GeneratedUpdateDate()); map.put(Long.class, longTime); map.put(long.class, longTime); if (classLoadConfig.isJavaTimePresent()) { map.put(Instant.class, new GeneratedUpdateJavaTime.InstantDT()); map.put(LocalDateTime.class, new GeneratedUpdateJavaTime.LocalDT()); map.put(OffsetDateTime.class, new GeneratedUpdateJavaTime.OffsetDT()); map.put(ZonedDateTime.class, new GeneratedUpdateJavaTime.ZonedDT()); } if (classLoadConfig.isJodaTimePresent()) { map.put(org.joda.time.LocalDateTime.class, new GeneratedUpdateJodaTime.LocalDT()); map.put(org.joda.time.DateTime.class, new GeneratedUpdateJodaTime.DateTimeDT()); } }
InternalConfigXmlRead(ServerConfig serverConfig) { this.serverConfig = serverConfig; this.classLoader = serverConfig.getClassLoadConfig().getClassLoader(); if (serverConfig.getClassLoadConfig().isJavaxJAXBPresent()) { init(); } }
/** * Create the DefaultTypeManager. */ public DefaultTypeManager(ServerConfig config, BootupClasses bootupClasses) { this.java7Present = config.getClassLoadConfig().isJava7Present(); this.jsonDateTime = config.getJsonDateTime(); this.typeMap = new ConcurrentHashMap<>(); this.nativeMap = new ConcurrentHashMap<>(); this.logicalMap = new ConcurrentHashMap<>(); this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent(); this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null; this.extraTypeFactory = new DefaultTypeFactory(config); this.postgres = isPostgres(config.getDatabasePlatform()); this.arrayTypeListFactory = arrayTypeListFactory(config.getDatabasePlatform()); this.arrayTypeSetFactory = arrayTypeSetFactory(config.getDatabasePlatform()); this.offlineMigrationGeneration = DbOffline.isGenerateMigration(); initialiseStandard(jsonDateTime, config); initialiseJavaTimeTypes(jsonDateTime, config); initialiseJodaTypes(jsonDateTime, config); initialiseJacksonTypes(config); loadTypesFromProviders(config, objectMapper); if (bootupClasses != null) { initialiseCustomScalarTypes(bootupClasses); initialiseScalarConverters(bootupClasses); initialiseAttributeConverters(bootupClasses); } }
public DdlGenerator(SpiEbeanServer server, ServerConfig serverConfig) { this.server = server; this.jaxbPresent = serverConfig.getClassLoadConfig().isJavaxJAXBPresent(); this.generateDdl = serverConfig.isDdlGenerate(); this.extraDdl = serverConfig.isDdlExtra(); this.createOnly = serverConfig.isDdlCreateOnly(); this.dbSchema = serverConfig.getDbSchema(); if (!serverConfig.getTenantMode().isDdlEnabled() && serverConfig.isDdlRun()) { log.warn("DDL can't be run on startup with TenantMode " + serverConfig.getTenantMode()); this.runDdl = false; this.ddlCommitOnCreateIndex = false; } else { this.runDdl = serverConfig.isDdlRun(); this.ddlCommitOnCreateIndex = server.getDatabasePlatform().isDdlCommitOnCreateIndex(); } this.scriptTransform = createScriptTransform(serverConfig.getMigrationConfig()); }
/** * Construct for the owning many property. */ BeanPropertyAssocManyJsonHelp(BeanPropertyAssocMany<?> many) { this.many = many; boolean objectMapperPresent = many.getBeanDescriptor().getServerConfig().getClassLoadConfig().isJacksonObjectMapperPresent(); this.jsonTransient = !objectMapperPresent ? null : new BeanPropertyAssocManyJsonTransient(); }
BeanLifecycleAdapterFactory(ServerConfig serverConfig) { this.postConstructPresent = serverConfig.getClassLoadConfig().isJavaxPostConstructPresent(); }
/** * Detect if Joda classes are in the classpath and if so register the Joda data types. */ @SuppressWarnings("deprecation") private void initialiseJodaTypes(JsonConfig.DateTime mode, ServerConfig config) { // detect if Joda classes are in the classpath if (config.getClassLoadConfig().isJodaTimePresent()) { // Joda classes are in the classpath so register the types logger.debug("Registering Joda data types"); addType(LocalDateTime.class, new ScalarTypeJodaLocalDateTime(mode)); addType(DateTime.class, new ScalarTypeJodaDateTime(mode)); addType(LocalDate.class, new ScalarTypeJodaLocalDate()); addType(org.joda.time.DateMidnight.class, new ScalarTypeJodaDateMidnight()); addType(org.joda.time.Period.class, new ScalarTypeJodaPeriod()); String jodaLocalTimeMode = config.getJodaLocalTimeMode(); if ("normal".equalsIgnoreCase(jodaLocalTimeMode)) { // use the expected/normal local time zone addType(LocalTime.class, new ScalarTypeJodaLocalTime()); logger.debug("registered ScalarTypeJodaLocalTime"); } else if ("utc".equalsIgnoreCase(jodaLocalTimeMode)) { // use the old UTC based addType(LocalTime.class, new ScalarTypeJodaLocalTimeUTC()); logger.debug("registered ScalarTypeJodaLocalTimeUTC"); } } }
private void initialiseJavaTimeTypes(JsonConfig.DateTime mode, ServerConfig config) { if (java7Present) { typeMap.put(java.nio.file.Path.class, new ScalarTypePath()); } if (config.getClassLoadConfig().isJavaTimePresent()) { logger.debug("Registering java.time data types"); addType(java.time.Period.class, new ScalarTypePeriod()); addType(java.time.LocalDate.class, new ScalarTypeLocalDate()); addType(java.time.LocalDateTime.class, new ScalarTypeLocalDateTime(mode)); addType(OffsetDateTime.class, new ScalarTypeOffsetDateTime(mode)); addType(ZonedDateTime.class, new ScalarTypeZonedDateTime(mode)); addType(Instant.class, new ScalarTypeInstant(mode)); addType(DayOfWeek.class, new ScalarTypeDayOfWeek()); addType(Month.class, new ScalarTypeMonth()); addType(Year.class, new ScalarTypeYear()); addType(YearMonth.class, new ScalarTypeYearMonthDate()); addType(MonthDay.class, new ScalarTypeMonthDay()); addType(OffsetTime.class, new ScalarTypeOffsetTime()); addType(ZoneId.class, new ScalarTypeZoneId()); addType(ZoneOffset.class, new ScalarTypeZoneOffset()); boolean localTimeNanos = config.isLocalTimeWithNanos(); addType(java.time.LocalTime.class, (localTimeNanos) ? new ScalarTypeLocalTimeWithNanos() : new ScalarTypeLocalTime()); boolean durationNanos = config.isDurationWithNanos(); addType(Duration.class, (durationNanos) ? new ScalarTypeDurationWithNanos() : new ScalarTypeDuration()); } }
public UpdateTimestampFactory(ClassLoadConfig classLoadConfig) { map.put(Timestamp.class, new GeneratedUpdateTimestamp()); map.put(java.util.Date.class, new GeneratedUpdateDate()); map.put(Long.class, longTime); map.put(long.class, longTime); if (classLoadConfig.isJavaTimePresent()) { map.put(Instant.class, new GeneratedUpdateJavaTime.InstantDT()); map.put(LocalDateTime.class, new GeneratedUpdateJavaTime.LocalDT()); map.put(OffsetDateTime.class, new GeneratedUpdateJavaTime.OffsetDT()); map.put(ZonedDateTime.class, new GeneratedUpdateJavaTime.ZonedDT()); } if (classLoadConfig.isJodaTimePresent()) { map.put(org.joda.time.LocalDateTime.class, new GeneratedUpdateJodaTime.LocalDT()); map.put(org.joda.time.DateTime.class, new GeneratedUpdateJodaTime.DateTimeDT()); } }