private String retrieveWSBaseURL() { return SingularProperties.get().getProperty(WkHtmlToPdfConstants.ENDPOINT_WS_WKHTMLTOPDF); }
/** * Verifies if should use embedded database (usually while running a test or in development mode). */ public static boolean useEmbeddedDatabase() { //In the future, this code should be move to Embedded Database helper class if (SingularProperties.getOpt(USE_EMBEDDED_DATABASE).isPresent()) { return SingularProperties.get().isTrue(USE_EMBEDDED_DATABASE); } else if (SingularProperties.get().isFalse(SINGULAR_DEV_MODE)) { return false; } return true; }
@Bean public DataSource dataSource() { if (SingularProperties.get().isTrue(USE_INMEMORY_DATABASE)) { LOGGER.warn("Usando datasource banco em memória"); final DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setUrl(getUrlConnection()); dataSource.setUsername("sa"); dataSource.setPassword("sa"); dataSource.setDriverClassName("org.h2.Driver"); final Properties connectionProperties = new Properties(); connectionProperties.setProperty("removeAbandoned", "true"); connectionProperties.setProperty("initialSize", "5"); connectionProperties.setProperty("maxActive", "10"); connectionProperties.setProperty("minIdle", "1"); dataSource.setConnectionProperties(connectionProperties); return dataSource; } else { LOGGER.info("Usando datasource configurado via JNDI"); DataSource dataSource = null; JndiTemplate jndi = new JndiTemplate(); String dataSourceName = SingularProperties.get().getProperty(JNDI_DATASOURCE, "java:jboss/datasources/singular"); try { dataSource = (DataSource) jndi.lookup(dataSourceName); } catch (NamingException e) { LOGGER.error(String.format("Datasource %s not found.", dataSourceName), e); } return dataSource; } }
/** * Looks for the property with the giving key. * <p>Never return empty String (in this case they became null) and also trims the resulting String.</p> */ @Nonnull static Optional<String> getOpt(@Nonnull String key) { return get().getPropertyOpt(key); }
public SingularSchedulerBean(DataSource dataSource) { Properties properties = new Properties(); properties.setProperty("org.quartz.scheduler.instanceName", "SingularFlowScheduler"); properties.setProperty("org.quartz.scheduler.instanceId", "AUTO"); if (SingularProperties.get().isTrue(SINGULAR_QUARTZ_JOBSTORE_ENABLED)) { properties.setProperty("org.quartz.jobStore.useProperties", "false"); properties.setProperty("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); properties.setProperty("org.quartz.jobStore.driverDelegateClass", SingularProperties.getOpt(SINGULAR_QUARTZ_DRIVER_DELEGATE).orElse("org.quartz.impl.jdbcjobstore.StdJDBCDelegate")); properties.setProperty("org.quartz.jobStore.tablePrefix", SingularProperties.getOpt(SINGULAR_QUARTZ_TABLE_PREFIX).orElse("QRTZ_")); properties.setProperty("org.quartz.jobStore.isClustered", "true"); setDataSource(dataSource); setOverwriteExistingJobs(true); } else { properties.put("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore"); } setQuartzProperties(properties); }
public static String getEndpointDefault() { String baseURL = SingularProperties.get(HtmlToPdfConstants.ENDPOINT_WS_WKHTMLTOPDF, ENDPOINT_WS_WKHTMLTOPDF_DEFAULT_VALUE); LoggerFactory.getLogger(RestfulHtmlToPdfConverter.class).warn("Singular property {} not set! Defaulting to {} ", HtmlToPdfConstants.ENDPOINT_WS_WKHTMLTOPDF, ENDPOINT_WS_WKHTMLTOPDF_DEFAULT_VALUE); String context = HtmlToPdfConstants.CONVERT_HTML_TO_PDF_PATH; return baseURL + context; }
@DependsOn("scriptsInitializer") @Bean public LocalSessionFactoryBean sessionFactory(final DataSource dataSource) { final LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); sessionFactoryBean.setDataSource(dataSource); sessionFactoryBean.setHibernateProperties(hibernateProperties()); sessionFactoryBean.setPackagesToScan(hibernatePackagesToScan()); if (SingularProperties.get().containsKey(CUSTOM_SCHEMA_NAME)) { LOGGER.info("Utilizando schema customizado: " + SingularProperties.get().getProperty(CUSTOM_SCHEMA_NAME)); sessionFactoryBean.setEntityInterceptor(new EntityInterceptor()); } return sessionFactoryBean; }
/** * Replaces default singular schema name using the configured replacement */ @Nonnull public static String replaceSingularSchemaName(@Nonnull String sql) { Optional<String> customSchema = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); return customSchema.map(s -> SqlUtil.replaceSchemaName(sql, Constants.SCHEMA, s)).orElse(sql); }
public FileUploadConfig(SingularProperties sp) { //@formatter:off this.globalMaxFileAge = toLongHumane(sp.getProperty(FILEUPLOAD_GLOBAL_MAX_FILE_AGE), Long.MAX_VALUE); this.globalMaxFileCount = toLongHumane(sp.getProperty(FILEUPLOAD_GLOBAL_MAX_FILE_COUNT), Long.MAX_VALUE); this.globalMaxFileSize = toLongHumane(sp.getProperty(FILEUPLOAD_GLOBAL_MAX_FILE_SIZE), Long.MAX_VALUE); this.globalMaxRequestSize = toLongHumane(sp.getProperty(FILEUPLOAD_GLOBAL_MAX_REQUEST_SIZE), Long.MAX_VALUE); this.defaultMaxFileSize = toLongHumane(sp.getProperty(FILEUPLOAD_DEFAULT_MAX_FILE_SIZE), Long.MAX_VALUE); this.defaultMaxRequestSize = toLongHumane(sp.getProperty(FILEUPLOAD_DEFAULT_MAX_REQUEST_SIZE), Long.MAX_VALUE); //@formatter:on }
/** * Retorna o valor da propriedade solicitada. Retornar {@param defaultValue} se * a propriedade retornar null; */ @Nonnull default String getProperty(@Nonnull String key, @Nonnull String defaultValue) { Objects.requireNonNull(defaultValue); return getPropertyOpt(Objects.requireNonNull(key)).orElse(defaultValue); }
if (SingularProperties.get().isTrue(SingularProperties.SINGULAR_SEND_EMAIL)) { msg.addRecipient(recipientType, new InternetAddress(addressee.getAddress())); } else { msg.addRecipient(recipientType, new InternetAddress(SingularProperties.get().getProperty(SINGULAR_EMAIL_TEST_RECPT, EMAIL_DEVELOPMENT)));
/** * Method responsible for include some accept origins. * This will be used for allow some domains to send request for the server. * <p> * A property will be used for this configuration. */ private void configureAcceptOrigins() { SingularProperties.get().getPropertyOpt(SingularProperties.SINGULAR_CSRF_ACCEPT_ORIGINS) .ifPresent(origins -> { for (String origin : origins.split(",")) { if (StringUtils.isNotBlank(origin)) { addAcceptedOrigin(origin.trim()); } } }); }
protected DataSource jndiDataSourceConfiguration() { getLogger().info("Usando datasource configurado via JNDI"); DataSource dataSource = null; JndiTemplate jndi = new JndiTemplate(); String dataSourceName = SingularProperties.get(JNDI_DATASOURCE, "java:jboss/datasources/singular"); try { dataSource = (DataSource) jndi.lookup(dataSourceName); } catch (NamingException e) { getLogger().error(String.format("Datasource %s not found.", dataSourceName), e); } return dataSource; }
public SingularEntityInterceptor(List<DatabaseObjectNameReplacement> replacements) { Optional<String> schemaName = SingularProperties.getOpt(CUSTOM_SCHEMA_NAME); schemaName.ifPresent(s -> schemaReplacements.add(new DatabaseObjectNameReplacement(Constants.SCHEMA, s))); schemaReplacements.addAll(replacements); }
private long readLong(@Nonnull SingularProperties sp, @Nonnull String key) { return toLongHumane(sp.getPropertyOpt(key).orElse(null), Long.MAX_VALUE); }
/** * Dynamic override for enabling/disabling the CSRF detection. Might be handy for specific * tenants in a multi-tenant application. When false, the CSRF detection is not performed for * the running request. Default {@code true} * * @return {@code true} when the CSRF checks need to be performed. */ protected boolean isEnabled() { return SingularProperties.get().isTrue(SingularProperties.SINGULAR_CSRF_ENABLED); }
protected String getAllowedCommonName() { return SingularProperties.get().getProperty(SingularProperties.REST_ALLOWED_COMMON_NAME, ""); }