Package javax.inject

Examples of javax.inject.Named


    InjectManager beanManager = InjectManager.create();
   
    Set<Bean<?>> beans;

    if (name != null) {
      Named named = Names.create(name);

      beans = beanManager.getBeans(type, named);
    }
    else {
      beans = beanManager.getBeans(type);
View Full Code Here


  private DataSource loadDataSource(String name)
  {
    if (name == null)
      return null;
   
    Named named = Names.create(name);
    InjectManager beanManager = InjectManager.create();
   
    Set<Bean<?>> beans = beanManager.getBeans(DataSource.class, named);
   
    if (beans != null && beans.size() > 0) {
View Full Code Here

            if (name != null) {
                return name;
            }
        }
        // alternative for name attribute
        Named named = element.getAnnotation(Named.class);
        if (named != null) {
            return named.value();
        }
        if (element instanceof Method) {
            return getNameFromMethod((Method) element);
        } else if (element instanceof Field) {
            return getNameFromField((Field) element);
View Full Code Here

         });
   }

   private static Named createNamed(final String name)
   {
      return new Named()
      {
         public Class<? extends Annotation> annotationType()
         {
            return Named.class;
         }
View Full Code Here

    boolean required;
    if (annot != null) {
      name = annot.name();
      required = annot.required();
    } else {
      Named named = field.getAnnotation(Named.class);
      name = named != null ? named.value() : "";
      required = false;
    }

    if (Strings.isEmpty(name))
    {
View Full Code Here

        name = annot.name();
        required = annot.required();
      }
      else
      {
        Named named = field.getAnnotation(Named.class);
        name = named != null ? named.value() : "";
        required = true;
      }

      String beanName = getBeanName(field, name, required);
View Full Code Here

        @Override
        public ViewControllerRef convertToViewMetaData(ViewRef inlineMetaData, Class<?> sourceClass)
        {
            String beanName = null;

            Named named = sourceClass.getAnnotation(Named.class);

            if (named != null)
            {
                beanName = named.value();
            }

            return new ViewControllerRefLiteral(sourceClass, beanName);
        }
View Full Code Here

{
    public void ensureNamingConvention(@Observes ProcessAnnotatedType processAnnotatedType)
    {
        Class<?> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass();

        Named namedAnnotation = beanClass.getAnnotation(Named.class);
        if (namedAnnotation != null &&
                namedAnnotation.value().length() > 0 &&
                Character.isUpperCase(namedAnnotation.value().charAt(0)))
        {
            AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder();
            builder.readFromType(beanClass);

            String beanName = namedAnnotation.value();
            String newBeanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);

            builder.removeFromClass(Named.class)
                    .addToClass(new NamedLiteral(newBeanName));
View Full Code Here

    public void assertMemberAccessIsCorrect()
    {
        Map<String, String> memberValues = new HashMap<String, String>();
        memberValues.put("value", "test");

        Named a1 = AnnotationInstanceProvider.of(Named.class, memberValues);

        assertThat(a1.value(), is("test"));
    }
View Full Code Here

    @Test
    public void assertDifferentAnnotationsNotEqual()
    {
        RequestScoped annotation1 = AnnotationInstanceProvider.of(RequestScoped.class);
        Named annotation2 = AnnotationInstanceProvider.of(Named.class);

        assertFalse(annotation1.equals(annotation2));
        assertFalse(annotation2.equals(annotation1));
    }
View Full Code Here

TOP

Related Classes of javax.inject.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.