Search in sources :

Example 1 with StorageBackendCreationException

use of com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException in project honeycomb by altamiracorp.

the class Bootstrap method configure.

@Override
protected void configure() {
    bind(HoneycombConfiguration.class).toInstance(configuration);
    for (AdapterType adapter : AdapterType.values()) {
        if (configuration.isAdapterConfigured(adapter)) {
            try {
                Class<?> moduleClass = Class.forName(adapter.getModuleClass());
                Constructor<?> moduleCtor = moduleClass.getConstructor(Map.class);
                Object module = moduleCtor.newInstance(configuration.getAdapterOptions(adapter));
                install((Module) module);
            } catch (ClassNotFoundException e) {
                logger.error("The " + adapter.getName() + " adapter is" + " configured, but could not be found on the classpath.");
                throw new StorageBackendCreationException(adapter.getName(), e);
            } catch (Exception e) {
                logger.error("Exception while attempting to reflect on the " + adapter.getName() + " adapter.", e);
                throw new StorageBackendCreationException(adapter.getName(), e);
            }
        }
    }
}
Also used : HoneycombConfiguration(com.nearinfinity.honeycomb.config.HoneycombConfiguration) StorageBackendCreationException(com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException) AdapterType(com.nearinfinity.honeycomb.config.AdapterType) StorageBackendCreationException(com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException) IOException(java.io.IOException)

Aggregations

AdapterType (com.nearinfinity.honeycomb.config.AdapterType)1 HoneycombConfiguration (com.nearinfinity.honeycomb.config.HoneycombConfiguration)1 StorageBackendCreationException (com.nearinfinity.honeycomb.exceptions.StorageBackendCreationException)1 IOException (java.io.IOException)1