Package com.google.inject.spi

Examples of com.google.inject.spi.InjectionPoint


public class GuiceShiroFilterTest {

    @Test
    public void ensureInjectable() {
        try {
            InjectionPoint ip = InjectionPoint.forConstructorOf(GuiceShiroFilter.class);
        } catch (Exception e) {
            fail("Could not create constructor injection point.");
        }
    }
View Full Code Here


public class WebGuiceEnvironmentTest {

    @Test
    public void ensureInjectable() {
        try {
            InjectionPoint ip = InjectionPoint.forConstructorOf(WebGuiceEnvironment.class);
        } catch (Exception e) {
            fail("Could not create constructor injection point.");
        }
    }
View Full Code Here

  List<MethodAspect> aspects = Lists.newArrayList();

  public void testSimpleCase()
      throws NoSuchMethodException, InvocationTargetException, ErrorsException {
    SimpleInterceptor interceptor = new SimpleInterceptor();
    InjectionPoint injectionPoint = InjectionPoint.forConstructorOf(Simple.class);

    aspects.add(new MethodAspect(any(), any(), interceptor));
    ProxyFactory<Simple> factory = new ProxyFactory<Simple>(injectionPoint, aspects);

    ConstructionProxy<Simple> constructionProxy = factory.create();
View Full Code Here

  protected Collection<D> newDependencyEdges(K nodeId, M node,
      Collection<Dependency<?>> dependencies) {
    List<D> edges = Lists.newArrayList();

    for (Dependency<?> dependency : dependencies) {
      InjectionPoint injectionPoint = dependency.getInjectionPoint();

      if (injectionPoint != null) {
        node.addMember(injectionPoint.getMember());
      }

      D edge = newDependencyEdge(nodeId, injectionPoint, dependency);
      edges.add(edge);
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private <T> ScopedBindingBuilder bindNewSpyProvider(Key<T> key) {
        TypeLiteral<T> type = key.getTypeLiteral();
        InjectionPoint constructorInjectionPoint = InjectionPoint.forConstructorOf(type);
        Key<T> relayingKey = Key.get(type, JukitoInternal.class);
        bind(relayingKey).toConstructor((Constructor<T>) constructorInjectionPoint.getMember());
        return bind(key).toProvider(new SpyProvider<T>(getProvider(relayingKey), relayingKey));
    }
View Full Code Here

  }

  public static void formatSource(Formatter formatter, Object source) {
    if (source instanceof Dependency) {
      Dependency<?> dependency = (Dependency<?>) source;
      InjectionPoint injectionPoint = dependency.getInjectionPoint();
      if (injectionPoint != null) {
        formatInjectionPoint(formatter, dependency, injectionPoint);
      } else {
        formatSource(formatter, dependency.getKey());
      }
View Full Code Here

  private boolean cleanup(BindingImpl<?> binding, Set<Key> encountered) {
    boolean bindingFailed = false;
    Set<Dependency<?>> deps = getInternalDependencies(binding);
    for(Dependency dep : deps) {
      Key<?> depKey = dep.getKey();
      InjectionPoint ip = dep.getInjectionPoint();
      if(encountered.add(depKey)) { // only check if we haven't looked at this key yet
        BindingImpl depBinding = jitBindings.get(depKey);
        if(depBinding != null) { // if the binding still exists, validate
          boolean failed = cleanup(depBinding, encountered); // if children fail, we fail
          if(depBinding instanceof ConstructorBindingImpl) {
View Full Code Here

    } catch (Throwable e) {}
  }

  private static class LoggerFactory implements InternalFactory<Logger>, Provider<Logger> {
    public Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) {
      InjectionPoint injectionPoint = dependency.getInjectionPoint();
      return injectionPoint == null
          ? Logger.getAnonymousLogger()
          : Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
    }
View Full Code Here

      }
      return loggerFactory;
    }

    public org.slf4j.Logger get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) {
      InjectionPoint injectionPoint = dependency.getInjectionPoint();
      if (injectionPoint != null) {
        return loggerFactory().getLogger(injectionPoint.getMember().getDeclaringClass().getName());
      }
      return loggerFactory().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    }
View Full Code Here

    }

    private Iterator<Dependency<?>> initInjectionPoint()
    {
        try {
            InjectionPoint injectionPoint;
            if (creationTypeLiteral != null) {
                injectionPoint = InjectionPoint.forConstructorOf(creationTypeLiteral);
            }
            else {
                injectionPoint = InjectionPoint.forConstructorOf(creationClass);
            }

            return injectionPoint.getDependencies().iterator();
        }
        catch (ConfigurationException dummy) {
            // ignore
        }
View Full Code Here

TOP

Related Classes of com.google.inject.spi.InjectionPoint

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.