Package com.google.inject

Examples of com.google.inject.ProvisionException


                                try {
                                    methodHandler.afterInjection(injectee,
                                            annotation, method);
                                } catch (InvocationTargetException ie) {
                                    Throwable e = ie.getTargetException();
                                    throw new ProvisionException(
                                            e.getMessage(), e);
                                } catch (IllegalAccessException e) {
                                    throw new ProvisionException(
                                            e.getMessage(), e);
                                }
                            }
                        });
                    }
View Full Code Here


                            }
                            try {
                                method.setAccessible(true);
                                method.invoke(injectee, values);
                            } catch (IllegalAccessException e) {
                                throw new ProvisionException(
                                        "Failed to inject method " + method
                                                + ". Reason: " + e, e);
                            } catch (InvocationTargetException ie) {
                                Throwable e = ie.getTargetException();
                                throw new ProvisionException(
                                        "Failed to inject method " + method
                                                + ". Reason: " + e, e);
                            }
                        }
                    });
                }
            }

            protected <I> void bindAnnotationInjectorToField(
                    final TypeEncounter<I> encounter,
                    final TypeLiteral<?> type, final Field field) {
                // TODO lets exclude fields with @Inject?
                final A annotation = field.getAnnotation(annotationType);
                if (annotation != null) {
                    if (providerProvider == null) {
                        providerProvider = memberProviderProvider
                                .get(encounter);
                    }

                    encounter.register(new InjectionListener<I>() {
                        public void afterInjection(I injectee) {
                            AnnotationMemberProvider provider = providerProvider
                                    .get();
                            Object value = provider.provide(annotation, type,
                                    field);
                            checkInjectedValueType(value, field.getType(),
                                    encounter);

                            try {
                                field.setAccessible(true);
                                field.set(injectee, value);
                            } catch (IllegalAccessException e) {
                                throw new ProvisionException(
                                        "Failed to inject field " + field
                                                + ". Reason: " + e, e);
                            }
                        }
                    });
View Full Code Here

    try {
      long maxDirectMemory = VMUtils.getMaxDirectMemory();

      final long memoryNeeded = (long) config.intermediateComputeSizeBytes() * (config.getNumThreads() + 1);
      if (maxDirectMemory < memoryNeeded) {
        throw new ProvisionException(
            String.format(
                "Not enough direct memory.  Please adjust -XX:MaxDirectMemorySize, druid.processing.buffer.sizeBytes, or druid.processing.numThreads: "
                + "maxDirectMemory[%,d], memoryNeeded[%,d] = druid.processing.buffer.sizeBytes[%,d] * ( druid.processing.numThreads[%,d] + 1 )",
                maxDirectMemory,
                memoryNeeded,
View Full Code Here

  @Provides
  @LazySingleton
  public DruidServerMetadata getMetadata(@Self DruidNode node, @Nullable NodeTypeConfig nodeType, DruidServerConfig config)
  {
    if (nodeType == null) {
      throw new ProvisionException("Must override the binding for NodeTypeConfig if you want a DruidServerMetadata.");
    }

    return new DruidServerMetadata(
        node.getHost(),
        node.getHost(),
View Full Code Here

    final Server server = makeJettyServer(node, config);
    try {
      initializer.initialize(server, injector);
    }
    catch (ConfigurationException e) {
      throw new ProvisionException(Iterables.getFirst(e.getErrorMessages(), null).getMessage());
    }


    lifecycle.addHandler(
        new Lifecycle.Handler()
View Full Code Here

        {
            logInjectorConstructor = loggerInjectorClass.getConstructor( Field.class );
        }
        catch ( SecurityException e )
        {
            throw new ProvisionException( format( "Impossible to access to '%s(%s)' public constructor due to security violation: %s",
                                                  loggerInjectorClass.getName(), Field.class.getName(), e.getMessage() ) );
        }
        catch ( NoSuchMethodException e )
        {
            throw new ProvisionException( format( "Class '%s' doesn't have a public construcor with <%s> parameter type: %s",
                                                  loggerInjectorClass.getName(), Field.class.getName(), e.getMessage() ) );
        }
    }
View Full Code Here

                field.set( target, createLogger( target.getClass() ) );
            }
        }
        catch ( Exception e )
        {
            throw new ProvisionException( format( "Impossible to set logger for field '%s', see nested exception: %s",
                                                  field, e.getMessage() ) );
        }
    }
View Full Code Here

  }

  @Provides
  public Environment providesEnvironment() {
    if (environment == null) {
      throw new ProvisionException(ILLEGAL_DROPWIZARD_MODULE_STATE);
    }
    return environment;
  }
View Full Code Here

  private class CustomConfigurationProvider implements Provider<T> {
    @Override
    public T get() {
      if (configuration == null) {
        throw new ProvisionException(ILLEGAL_DROPWIZARD_MODULE_STATE);
      }
      return configuration;
    }
View Full Code Here

                             {
                                 initialisable.initialise();
                             }
                             catch (Exception e)
                             {
                                 throw new ProvisionException("Failed to invoke initialise(): " + e, e);
                             }
                         }
                     }
                 });
View Full Code Here

TOP

Related Classes of com.google.inject.ProvisionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.