Package com.google.inject.internal

Examples of com.google.inject.internal.Scoping


    public static Class<? extends Annotation> getScopeAnnotation(
            Binding<?> binding) {
        Class<? extends Annotation> scopeAnnotation = null;
        if (binding instanceof BindingImpl) {
            BindingImpl bindingImpl = (BindingImpl) binding;
            Scoping scoping = bindingImpl.getScoping();
            if (scoping != null) {
                scopeAnnotation = scoping.getScopeAnnotation();

                // TODO not sure why we need this hack???
                if (scopeAnnotation == null) {
                    Scope scope = scoping.getScopeInstance();
                    if (scope instanceof HasScopeAnnotation) {
                        HasScopeAnnotation hasScopeAnnotation = (HasScopeAnnotation) scope;
                        scopeAnnotation = hasScopeAnnotation
                                .getScopeAnnotation();
                    }
View Full Code Here


    }
   
    @Test
    public void itBindsAHibernateInitializerAsAnEagerSingleton() throws Exception {
      final Map<Key<?>, Object> bindings = getBindings(module);
      final Scoping scoping = (Scoping) bindings.get(Key.get(HibernateInitializer.class));
     
      assertThat(scoping, is(Scoping.EAGER_SINGLETON));
    }
View Full Code Here

      return true;
    }

    validateKey(command.getSource(), command.getKey());

    final Scoping scoping = Scopes.makeInjectable(
        ((BindingImpl<?>) command).getScoping(), injector, errors);

    command.acceptTargetVisitor(new BindingTargetVisitor<T, Void>() {

      public Void visitInstance(InstanceBinding<? extends T> binding) {
View Full Code Here

  public Object getInstance(GuiceBean bean, Object context) throws InvocationTargetException {
    return context;
  }

  public void releaseContext(GuiceBean bean, Object context) {
    Scoping scoping = ((BindingImpl)bean.binding).getScoping();
    if (scoping.isNoScope()) {
      invokePreDestroy(context);
    }
  }
View Full Code Here

    }
  }

  public void close() {
    for (Binding<?> binding : injector.getAllBindings().values()) {
      Scoping scoping = ((BindingImpl)binding).getScoping();
      if (scoping == Scoping.SINGLETON_INSTANCE) {
        invokePreDestroy(binding.getProvider().get());
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.google.inject.internal.Scoping

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.