Package com.google.inject.name

Examples of com.google.inject.name.Named


        String typeName = getServiceName(clientInterface);
        String name = annotationType.getSimpleName();

        // Bind ThriftClientConfig with random @Named annotation
        // see comment on random Named annotation above
        Named thriftClientConfigKey = Names.named(UUID.randomUUID().toString());
        String prefix = String.format("%s.%s", typeName, name);
        bindConfig(binder).annotatedWith(thriftClientConfigKey).prefixedWith(prefix).to(ThriftClientConfig.class);

        // Bind ThriftClient to a provider which knows how to find the ThriftClientConfig using
        // the random @Named annotation
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

            if (jndiBind != null) {
                jndiName = jndiBind.value();
            }
            if (jndiName == null) {
                if (annotation instanceof Named) {
                    Named named = (Named) annotation;
                    String name = named.value();
                    jndiName = type.toString() + "/" + name;
                } else if (type instanceof Class<?>) {
                    Class<?> aClass = (Class<?>) type;
                    if (annotation == null) {
                        jndiName = aClass.getName();
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

  }


  @SuppressWarnings("unchecked")
  private Key resolveClass(GuiceBinding annotation, Class returnType) {
    Named named = Names.named(annotation.name());
    if (List.class.isAssignableFrom(returnType)) {
      if (annotation.parameterizedType() == GuiceBinding.NullClass.class) {
        throw new IllegalArgumentException("Missing parameterized type for " + annotation);
      }
      return Key.get(Types.listOf(annotation.parameterizedType()), named);
View Full Code Here

        bind(DatasetFramework.class).annotatedWith(Names.named("datasetMDS")).to(InMemoryDatasetFramework.class);
        bind(MDSDatasetsRegistry.class).in(Singleton.class);
        bind(DatasetService.class);
        expose(DatasetService.class);

        Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
        Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
        handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
        handlerBinder.addBinding().to(PingHandler.class);

        Multibinder.newSetBinder(binder(), DatasetMetricsReporter.class);
View Full Code Here

          .addBinding().to(LevelDBDatasetMetricsReporter.class);

        bind(DatasetService.class);
        expose(DatasetService.class);

        Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
        Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
        handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
        handlerBinder.addBinding().to(PingHandler.class);

        bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
View Full Code Here

          .addBinding().to(HBaseDatasetMetricsReporter.class);

        bind(DatasetService.class);
        expose(DatasetService.class);

        Named datasetUserName = Names.named(Constants.Service.DATASET_EXECUTOR);
        Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(binder(), HttpHandler.class, datasetUserName);
        handlerBinder.addBinding().to(DatasetAdminOpHTTPHandler.class);
        handlerBinder.addBinding().to(PingHandler.class);

        bind(DatasetOpExecutorService.class).in(Scopes.SINGLETON);
View Full Code Here

        Annotation bindingAnnotation = null;
        boolean preInjectableFound = false;
        for (Annotation annotation : annotations) {
          if (Named.class.isInstance(annotation)) {
            Named named = (Named) annotation;
            args.add(new NamedParameter(named.value(), method.getGenericParameterTypes()[i]));
            preInjectableFound = true;
            break;
          }
          if (javax.inject.Named.class.isInstance(annotation)) {
            javax.inject.Named named = (javax.inject.Named) annotation;
                  args.add(new NamedParameter(named.value(), method.getGenericParameterTypes()[i]));
            preInjectableFound = true;
            break;
          }
          else if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) {
            bindingAnnotation = annotation;
View Full Code Here

        Annotation bindingAnnotation = null;
        boolean namedFound = false;
        for (Annotation annotation : annotations) {
          if (Named.class.isInstance(annotation)) {
            Named named = (Named) annotation;

      args.add(new NamedParameter(named.value(), method.getGenericParameterTypes()[i]));
            namedFound = true;

            break;
          } else if (annotation.annotationType().isAnnotationPresent(BindingAnnotation.class)) {
            bindingAnnotation = annotation;
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.