use of com.genexus.util.GXService in project JavaClasses by genexuslabs.
the class ConfigurationManager method getValueFromGXServices.
private static String getValueFromGXServices(GXServices services, String propName) {
String[] tokens = propName.split(":");
if (tokens.length < 2 || tokens.length > 3)
return null;
String key = tokens[0];
String property = tokens[1];
if (tokens.length == 3) {
key = String.format("%s:%s", tokens[0], tokens[1]);
property = tokens[2];
}
GXService service = services.get(key);
if (service == null)
return null;
return service.getProperties().get(property);
}
use of com.genexus.util.GXService in project JavaClasses by genexuslabs.
the class ExternalStorage method create.
public boolean create(String name, GXProperties properties, GXStorageProvider[] storageProvider, GXBaseCollection<SdtMessages_Message>[] messages) {
storageProvider[0] = null;
if (isNullOrEmpty(name)) {
GXutil.ErrorToMessages("Unsupported", "Provider name cannot be empty", messages[0]);
return false;
}
try {
if (providerService == null || !providerService.getName().equals(name)) {
providerService = new GXService();
providerService.setType(GXServices.STORAGE_SERVICE);
providerService.setName(name);
providerService.setAllowMultiple(false);
providerService.setAllowOverrideWithEnvVarSettings(false);
providerService.setProperties(new GXProperties());
}
preprocess(name, properties);
GXProperty prop = properties.first();
while (!properties.eof()) {
providerService.getProperties().set(prop.name, prop.value);
prop = properties.next();
}
String classFullName = providerService.getClassName();
logger.debug("Loading storage provider: " + classFullName);
final Class<?> providerClass = Class.forName(classFullName);
this.provider = (ExternalProvider) providerClass.getConstructor(GXService.class).newInstance(providerService);
} catch (final Exception ex) {
logger.error("Couldn't connect to external storage provider. ", ex.getMessage(), ex);
storageMessages(ex, messages[0]);
return false;
}
storageProvider[0] = this;
return true;
}
use of com.genexus.util.GXService in project JavaClasses by genexuslabs.
the class RedisClient method initCache.
private void initCache() throws URISyntaxException {
GXService providerService = Application.getGXServices().get(GXServices.CACHE_SERVICE);
String addresses = providerService.getProperties().get("CACHE_PROVIDER_ADDRESS");
String cacheKeyPattern = providerService.getProperties().get("CACHE_PROVIDER_KEYPATTERN");
String password = providerService.getProperties().get("CACHE_PROVIDER_PASSWORD");
initCache(addresses, password, cacheKeyPattern);
}
use of com.genexus.util.GXService in project JavaClasses by genexuslabs.
the class Memcached method InitCache.
MemcachedClient InitCache() throws IOException {
GXService providerService = Application.getGXServices().get(GXServices.CACHE_SERVICE);
String addresses = providerService.getProperties().get("CACHE_PROVIDER_ADDRESS");
String username = providerService.getProperties().get("CACHE_PROVIDER_USER");
String password = providerService.getProperties().get("CACHE_PROVIDER_PASSWORD");
if (addresses == null || addresses.isEmpty())
addresses = "127.0.0.1:11211";
if (username == null || username.isEmpty()) {
return new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses(addresses));
} else {
AuthDescriptor ad = new AuthDescriptor(new String[] { "PLAIN" }, new PlainCallbackHandler(username, password));
return new MemcachedClient(new ConnectionFactoryBuilder().setProtocol(Protocol.BINARY).setAuthDescriptor(ad).build(), AddrUtil.getAddresses(addresses));
}
}
use of com.genexus.util.GXService in project JavaClasses by genexuslabs.
the class Application method getExternalProviderImpl.
private static ExternalProvider getExternalProviderImpl(String service) {
ExternalProvider externalProviderImpl = null;
GXService providerService = getGXServices().get(service);
if (providerService != null) {
Class providerClass;
try {
providerClass = Class.forName(providerService.getClassName());
} catch (ClassNotFoundException e) {
logger.fatal("Unrecognized External Provider class (ClassNotFound) : " + providerService.getName() + " / " + providerService.getClassName(), e);
throw new InternalError("Unrecognized External Provider class (ClassNotFound) : " + providerService.getName() + " / " + providerService.getClassName());
}
try {
externalProviderImpl = (ExternalProvider) providerClass.getConstructor(String.class).newInstance(service);
} catch (Exception e) {
logger.fatal("Unable to Initialize External Provider Class: " + providerService.getClassName(), e);
throw new InternalError("Unable to Initialize External Provider Class: " + providerService.getClassName(), e);
}
}
return externalProviderImpl;
}
Aggregations