use of org.platformlayer.http.HttpStrategy in project platformlayer by platformlayer.
the class GuiceXaasConfig method configure.
@Override
protected void configure() {
bind(EncryptionStore.class).toProvider(EncryptionStoreProvider.class);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
FreemarkerTemplateEngine freemarker = new FreemarkerTemplateEngine(classLoader);
bind(TemplateEngine.class).toInstance(freemarker);
bind(ItemService.class).to(ItemServiceImpl.class);
bind(ISshContext.class).to(MinaSshContext.class);
bind(OpsSystem.class);
bind(OpsContext.class).toProvider(OpsContextProvider.class);
bind(JobRegistry.class).to(PersistentJobRegistry.class).asEagerSingleton();
File jobLogStoreBaseDir = new File("jobs");
jobLogStoreBaseDir.mkdirs();
bind(JobLogStore.class).toInstance(new FilesystemJobLogStore(jobLogStoreBaseDir));
// TODO: Split off scheduler
bind(ResultSetMappersProvider.class).asEagerSingleton();
bind(ResultSetMappers.class).toProvider(ResultSetMappersProvider.class).in(Scopes.SINGLETON);
bind(DataSource.class).toProvider(GuiceDataSourceProvider.bind("platformlayer.jdbc.")).asEagerSingleton();
URLClassLoader urlClassLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader();
JerseyAnnotationDiscovery discovery = new JerseyAnnotationDiscovery();
discovery.scan(urlClassLoader);
bind(AnnotationDiscovery.class).toInstance(discovery);
for (AnnotatedClass annotatedClass : discovery.findAnnotatedClasses(org.platformlayer.xaas.Module.class)) {
Class<?> moduleClass = annotatedClass.getSubjectClass();
log.info("Installing extension module: " + moduleClass);
com.google.inject.Module module;
try {
module = (com.google.inject.Module) moduleClass.newInstance();
} catch (InstantiationException e) {
throw new IllegalStateException("Error creating class: " + moduleClass, e);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Error creating class: " + moduleClass, e);
}
this.install(module);
}
HttpStrategy httpStrategy = new InstrumentedApacheHttpStrategy();
bind(HttpStrategy.class).toInstance(httpStrategy);
bind(AuthenticationTokenValidator.class).toProvider(PlatformLayerAuthAdminClient.Provider.class).in(Scopes.SINGLETON);
// boolean isMultitenant = !Strings.isNullOrEmpty(configuration.lookup("multitenant.keys", null));
if (true) {
// isMultitenant) {
bind(PlatformLayerAuthenticationClient.class).toProvider(PlatformLayerAuthenticationClientProvider.class).asEagerSingleton();
bind(AuthenticationService.class).to(PlatformlayerAuthenticationService.class).asEagerSingleton();
}
bind(BackupContextFactory.class).to(StubBackupContextFactory.class);
bind(ExecutorService.class).toInstance(Executors.newCachedThreadPool());
bind(ServiceProviderDictionary.class).to(AnnotationServiceProviderDictionary.class).in(Scopes.SINGLETON);
bind(JaxbContextHelper.class).asEagerSingleton();
bind(JAXBContext.class).toProvider(JaxbContextHelper.class);
bind(OperationQueue.class).to(SimpleOperationQueue.class).asEagerSingleton();
bind(ObjectInjector.class).to(GuiceObjectInjector.class);
bind(OpsKeyStore.class).to(SimpleOpsKeyStore.class).in(Scopes.SINGLETON);
bind(JobRepository.class).to(JdbcJobRepository.class);
bind(ManagedItemRepository.class).to(JdbcManagedItemRepository.class);
bind(ServiceAuthorizationRepository.class).to(JdbcServiceAuthorizationRepository.class);
bind(ChangeQueue.class).to(InProcessChangeQueue.class);
bind(PlatformLayerClient.class).toProvider(PlatformLayerClientProvider.class);
}
use of org.platformlayer.http.HttpStrategy in project platformlayer by platformlayer.
the class ConfigurationOptions method buildPlatformLayerClient.
private HttpPlatformLayerClient buildPlatformLayerClient(Properties properties, boolean debug) {
HttpStrategy httpStrategy = new JreHttpStrategy();
// HttpStrategy httpStrategy = new ApacheCommonsHttpStrategy();
HttpPlatformLayerClient client = HttpPlatformLayerClient.buildUsingProperties(httpStrategy, properties);
if (debug) {
client.setDebug(System.err);
} else {
// We don't want debug messages to interfere with our output
// TODO: Fix this so debug output doesn't interfere (stderr?)
// TODO: Maybe output the debug info only in case of failure?
ByteArrayOutputStream baos = new ByteArrayOutputStream();
client.setDebug(new PrintStream(baos));
}
return client;
}
use of org.platformlayer.http.HttpStrategy in project platformlayer by platformlayer.
the class PlatformLayerTestContext method buildPlatformLayerClient.
public PlatformLayerClient buildPlatformLayerClient() throws IOException, OpsException {
PlatformLayerClient client;
if (configFile == null) {
throw new IllegalArgumentException("Config file is required");
}
InputStream is = null;
try {
if (!configFile.exists()) {
throw new FileNotFoundException("Configuration file not found: " + configFile);
}
is = new FileInputStream(configFile);
Properties properties = new Properties();
try {
properties.load(is);
} catch (IOException e) {
throw new IOException("Error reading configuration file", e);
}
HttpStrategy httpStrategy = new JreHttpStrategy();
client = HttpPlatformLayerClient.buildUsingProperties(httpStrategy, properties);
} finally {
if (is != System.in) {
IoUtils.safeClose(is);
}
}
return client;
}
Aggregations