protected JettyHttpROPConnector createJettyHttpRopConnector() { String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY); if (url == null) { throw new ConfigurationException( "No property defined for '%s', can't initialize connection", ClientConstants.ROP_SERVICE_URL_PROPERTY); } String username = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY); long readTimeout = runtimeProperties.getLong( ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY, -1L); HttpClient httpClient = initJettyHttpClient(); addBasicAuthentication(httpClient, url, username); JettyHttpROPConnector result = new JettyHttpROPConnector(httpClient, url, username); if (readTimeout > 0) { result.setReadTimeout(readTimeout); } return result; }
private URI getConfig() { String config = properties.get(JCacheConstants.JCACHE_PROVIDER_CONFIG); if(config == null) { return null; } else { try { return new URI(config); } catch (URISyntaxException ex) { throw new RuntimeException("Wrong value for JCache provider config property", ex); } } } }
@Override public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception { String suffix = "." + nodeDescriptor.getDataChannelDescriptor().getName() + "." + nodeDescriptor.getName(); String driverClass = getProperty(Constants.JDBC_DRIVER_PROPERTY, suffix); String url = getProperty(Constants.JDBC_URL_PROPERTY, suffix); String username = getProperty(Constants.JDBC_USERNAME_PROPERTY, suffix); String password = getProperty(Constants.JDBC_PASSWORD_PROPERTY, suffix); int minConnections = getIntProperty(Constants.JDBC_MIN_CONNECTIONS_PROPERTY, suffix, 1); int maxConnections = getIntProperty(Constants.JDBC_MAX_CONNECTIONS_PROPERTY, suffix, 1); long maxQueueWaitTime = properties.getLong(Constants.JDBC_MAX_QUEUE_WAIT_TIME, UnmanagedPoolingDataSource.MAX_QUEUE_WAIT_DEFAULT); String validationQuery = properties.get(Constants.JDBC_VALIDATION_QUERY_PROPERTY); Driver driver = objectFactory.newInstance(Driver.class, driverClass); return DataSourceBuilder.url(url).driver(driver).userName(username).password(password) .pool(minConnections, maxConnections).maxQueueWaitTime(maxQueueWaitTime) .validationQuery(validationQuery).build(); }
protected void addBasicAuthentication(HttpClient httpClient, String url, String username) { String password = runtimeProperties.get(ClientConstants.ROP_SERVICE_PASSWORD_PROPERTY); String realm = runtimeProperties.get(ClientConstants.ROP_SERVICE_REALM_PROPERTY); if (username != null && password != null) { if (realm == null && logger.isWarnEnabled()) { logger.warn("In order to use JettyClient with BASIC Authentication " + "you should provide Constants.ROP_SERVICE_REALM_PROPERTY."); return; } if (logger.isInfoEnabled()) { logger.info( "Adding authentication" + "\nUser: " + username + "\nRealm: " + realm); } AuthenticationStore auth = httpClient.getAuthenticationStore(); auth.addAuthentication(new BasicAuthentication(URI.create(url), realm, username, password)); } }
/** * @since 4.0 */ protected DataChannelDescriptor loadDescriptor() { DataChannelDescriptor descriptor = locations.isEmpty() ? new DataChannelDescriptor() : loadDescriptorFromConfigs(); String nameOverride = runtimeProperties.get(Constants.SERVER_DOMAIN_NAME_PROPERTY); if (nameOverride != null) { descriptor.setName(nameOverride); } return descriptor; }
@SuppressWarnings("unchecked") public Map<Object, Persistent> createObjectMap() { String strategy = runtimeProperties .get(Constants.SERVER_OBJECT_RETAIN_STRATEGY_PROPERTY); if (strategy == null || WEAK_RETAIN_STRATEGY.equals(strategy)) { return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK); } else if (SOFT_RETAIN_STRATEGY.equals(strategy)) { return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT); } else if (HARD_RETAIN_STRATEGY.equals(strategy)) { return new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.HARD); } else { throw new CayenneRuntimeException("Unsupported retain strategy %s", strategy); } } }
}; for (String propertyConstant : verifiableProperties) { String property = properties.get(getDataNodePropertyName(nodeDescriptor, propertyConstant)); if (property != null) { logResult.append(getDataNodePropertyName(nodeDescriptor, propertyConstant)).append(", "); found = true; property = properties.get(propertyConstant); if (property != null) { logResult.append(propertyConstant).append(", ");
protected boolean shouldConfigureDataSourceFromProperties( DataNodeDescriptor nodeDescriptor) { String channelName = nodeDescriptor.getDataChannelDescriptor() != null ? nodeDescriptor.getDataChannelDescriptor().getName() : null; String driver = properties.get(Constants.JDBC_DRIVER_PROPERTY); if (driver == null && channelName != null) { driver = properties.get(getDataNodePropertyName(nodeDescriptor, Constants.JDBC_DRIVER_PROPERTY)); } if (driver == null) { findUnusedProperties(nodeDescriptor); return false; } String url = properties.get(Constants.JDBC_URL_PROPERTY); if (url == null && channelName != null) { url = properties.get(getDataNodePropertyName(nodeDescriptor, Constants.JDBC_URL_PROPERTY)); } if (url == null) { findUnusedProperties(nodeDescriptor); return false; } logger .info(String .format( "Found DataSourceFactory system property overrides for URL and Driver " + "of '%s.%s' node. Will ignore project DataSource configuration.", channelName, nodeDescriptor.getName())); return true; }
@Override public ClientConnection get() throws DIRuntimeException { String sharedSession = runtimeProperties .get(ClientConstants.ROP_SERVICE_SHARED_SESSION_PROPERTY); JettyHttpROPConnector ropConnector = createJettyHttpRopConnector(); ProxyRemoteService remoteService = new ProxyRemoteService(serializationService, ropConnector); HttpClientConnection clientConnection = new HttpClientConnection(remoteService, sharedSession); ropConnector.setClientConnection(clientConnection); return clientConnection; }