Package com.google.inject.name

Examples of com.google.inject.name.Named


          continue;
        }
        for (final Annotation annotation : annotations[index]) {
          final Class<? extends Annotation> clazz = annotation.annotationType();
          if (clazz.equals(Named.class)) {
            final Named named = (Named) annotation;
            getNamedParameters().put(named.value(), para);
            continue label1;
          } else if (clazz.equals(FirstResult.class)) {
            firstResult = (Integer) para;
            continue label1;
          } else if (clazz.equals(MaxResults.class)) {
View Full Code Here


   * @return
   */
  private Object propertyResult(Object[] parameters) {
    EntityManager em = getContext().getEntityManager();
    Annotation[][] annos = method.getParameterAnnotations();
    Named named = null;
    for (Annotation a : annos[0]) {
      final Class<? extends Annotation> clazz = a.annotationType();
      if (clazz.equals(Named.class)) {
        named = (Named) a;
      }
    }
    if (named == null)
      return em.find(getMethodReturnType(), parameters[0]);
    else {
      String ejbql = "from " + getMethodReturnType().getSimpleName() + " entity where entity." + named.value()
              + "=?";
      Query query = em.createQuery(ejbql);
      query.setParameter(1, parameters[0]);
      return query.getSingleResult();
    }
View Full Code Here

        continue;
      }
      for (final Annotation annotation : annotations[index]) {
        final Class<? extends Annotation> clazz = annotation.annotationType();
        if (clazz.equals(Named.class)) {
          final Named named = (Named) annotation;
          getNamedParameters().put(named.value(), para);
          continue label1;
        } else if (clazz.equals(FirstResult.class)) {
          firstResult = (Integer) para;
          continue label1;
        } else if (clazz.equals(MaxResults.class)) {
View Full Code Here

  public boolean equals(Object o) {
    if (!(o instanceof Named)) {
      return false;
    }

    Named other = (Named) o;
    return value.equals(other.value());
  }
View Full Code Here

            if(i instanceof ProviderMethod)
            {
                Class type = ((ProviderMethod)i).getKey().getTypeLiteral().getRawType();
                boolean bindRequired = (type.equals(Connector.class) || type.equals(Agent.class));

                Named bindTo = ((ProviderMethod)i).getMethod().getAnnotation(Named.class);
                if(bindTo!=null)
                {
                    try
                    {
                        Object o = ((ProviderMethod)i).get();
                        if(o instanceof NameableObject)
                        {
                            ((NameableObject)o).setName(bindTo.value());
                        }
                        muleContext.getRegistry().registerObject(bindTo.value(), o);
                    }
                    catch (RegistrationException e)
                    {
                        throw new MuleRuntimeException(CoreMessages.createStaticMessage("failed to bind " + bindTo.value()));
                    }
                }
                else if(bindRequired)
                {
                    throw new RuntimeException("Provider object type: " + type + ", must have a @Named annotation so that the object can be bound in Mule");
View Full Code Here

    assertEquals(INTEGER_VALUE, instance.configurableParam);
    assertEquals(INTEGER_VALUE, instance.configurableParamMemberInjected);
  }

  public void testOneConfigurableParam_multipleConfigurations() {
    Named named1 = Names.named("1");
    Named named2 = Names.named("2");

    Injector injector = getInjector(
        new LegModuleBuilder()
            .bind(OneConfigurableParam.class)
            .annotatedWith(named1)
View Full Code Here

      pattern = p;
      argNames = new String[method.getParameterTypes().length];
      argTypes = new Class[argNames.length];
      for (int i = 0; i < argNames.length; i++) {
        Named name = null;
        for (Annotation a : method.getParameterAnnotations()[i]) {
          if (a instanceof Named) {
            name = (Named) a;
            break;
          }
        }
        if (name == null) {
          throw new RuntimeException("Argument " + (i + 1) + " of "
              + m.toGenericString() + " in " + m.getDeclaringClass()
              + " has no @Named annotation");
        }
        if (!Predicate.class.isAssignableFrom(method.getParameterTypes()[i])) {
          throw new RuntimeException("Argument " + (i + 1) + " of "
              + m.toGenericString() + " in " + m.getDeclaringClass()
              + " must be of type " + Predicate.class);
        }
        argNames[i] = name.value();
        argTypes[i] = (Class<Predicate<T>>) method.getParameterTypes()[i];
      }
    }
View Full Code Here

  private static final class ExploreExecutorModule extends PrivateModule {

    @Override
    protected void configure() {
      Named exploreSeriveName = Names.named(Constants.Service.EXPLORE_HTTP_USER_SERVICE);
      Multibinder<HttpHandler> handlerBinder =
          Multibinder.newSetBinder(binder(), HttpHandler.class, exploreSeriveName);
      handlerBinder.addBinding().to(QueryExecutorHttpHandler.class);
      handlerBinder.addBinding().to(ExploreExecutorHttpHandler.class);
      handlerBinder.addBinding().to(ExplorePingHandler.class);
View Full Code Here

    }
   
    Injector injector = Guice.createInjector(new ProductionBindings(type, temp));
    NoSqlEntityManagerFactory factory = injector.getInstance(NoSqlEntityManagerFactory.class);

    Named named = Names.named("logger");
    Key<NoSqlRawSession> key = Key.get(NoSqlRawSession.class, named);
    NoSqlRawSession inst = injector.getInstance(key);
    inst.start(properties);
   
    //why not just add setInjector() and setup() in NoSqlEntityManagerFactory
View Full Code Here

        // Bind ThriftClientConfig with random @Named annotation
        // We generate a random Named annotation for binding the ThriftClientConfig because we
        // need one of these for each clientType+annotationType pair.  Without this, the
        // ThriftClientConfig bindings collapse to a single instance which is shared by all
        // clients.
        Named thriftClientConfigKey = Names.named(UUID.randomUUID().toString());
        bindConfig(binder).annotatedWith(thriftClientConfigKey).prefixedWith(typeName).to(ThriftClientConfig.class);

        // Bind ThriftClient to a provider which knows how to find the ThriftClientConfig using
        // the random @Named annotation
        TypeLiteral<ThriftClient<T>> typeLiteral = toThriftClientTypeLiteral(clientInterface);
View Full Code Here

TOP

Related Classes of com.google.inject.name.Named

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.