Package javax.ejb

Examples of javax.ejb.EJB


        List<Method> methodsWithEJB = classFinder.findAnnotatedMethods(EJB.class);
        List<Field> fieldsWithEJB = classFinder.findAnnotatedFields(EJB.class);

        // Class-level annotation
        for (Class cls : classesWithEJB) {
            EJB ejb = (EJB) cls.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, cls, null, null);
            }
        }

        // Method-level annotation
        for (Method method : methodsWithEJB) {
            EJB ejb = (EJB) method.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, null, method, null);
            }
        }

        // Field-level annotation
        for (Field field : fieldsWithEJB) {
            EJB ejb = (EJB) field.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, null, null, field);
            }
        }
View Full Code Here


                    // Initialize fields annotations for resource injection if
                    // JNDI is enabled
                    Field[] fields = Introspection.getDeclaredFields(clazz);
                    for (Field field : fields) {
                        Resource resourceAnnotation;
                        EJB ejbAnnotation;
                        WebServiceRef webServiceRefAnnotation;
                        PersistenceContext persistenceContextAnnotation;
                        PersistenceUnit persistenceUnitAnnotation;
                        if (injections != null && injections.containsKey(field.getName())) {
                            annotations.add(new AnnotationCacheEntry(
                                    field.getName(), null,
                                    injections.get(field.getName()),
                                    AnnotationCacheEntryType.FIELD));
                        } else if ((resourceAnnotation =
                                field.getAnnotation(Resource.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(field.getName(), null,
                                    resourceAnnotation.name(), AnnotationCacheEntryType.FIELD));
                        } else if ((ejbAnnotation =
                                field.getAnnotation(EJB.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(field.getName(), null,
                                    ejbAnnotation.name(), AnnotationCacheEntryType.FIELD));
                        } else if ((webServiceRefAnnotation =
                                field.getAnnotation(WebServiceRef.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(field.getName(), null,
                                    webServiceRefAnnotation.name(),
                                    AnnotationCacheEntryType.FIELD));
                        } else if ((persistenceContextAnnotation =
                                field.getAnnotation(PersistenceContext.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(field.getName(), null,
                                    persistenceContextAnnotation.name(),
                                    AnnotationCacheEntryType.FIELD));
                        } else if ((persistenceUnitAnnotation =
                                field.getAnnotation(PersistenceUnit.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(field.getName(), null,
                                    persistenceUnitAnnotation.name(),
                                    AnnotationCacheEntryType.FIELD));
                        }
                    }
                }

                // Initialize methods annotations
                Method[] methods = Introspection.getDeclaredMethods(clazz);
                Method postConstruct = null;
                String postConstructFromXml = postConstructMethods.get(clazz.getName());
                Method preDestroy = null;
                String preDestroyFromXml = preDestroyMethods.get(clazz.getName());
                for (Method method : methods) {
                    if (context != null) {
                        // Resource injection only if JNDI is enabled
                        if (injections != null &&
                                Introspection.isValidSetter(method)) {
                            String fieldName = Introspection.getPropertyName(method);
                            if (injections.containsKey(fieldName)) {
                                annotations.add(new AnnotationCacheEntry(
                                        method.getName(),
                                        method.getParameterTypes(),
                                        injections.get(fieldName),
                                        AnnotationCacheEntryType.SETTER));
                                continue;
                            }
                        }
                        Resource resourceAnnotation;
                        EJB ejbAnnotation;
                        WebServiceRef webServiceRefAnnotation;
                        PersistenceContext persistenceContextAnnotation;
                        PersistenceUnit persistenceUnitAnnotation;
                        if ((resourceAnnotation =
                                method.getAnnotation(Resource.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(
                                    method.getName(),
                                    method.getParameterTypes(),
                                    resourceAnnotation.name(),
                                    AnnotationCacheEntryType.SETTER));
                        } else if ((ejbAnnotation =
                                method.getAnnotation(EJB.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(
                                    method.getName(),
                                    method.getParameterTypes(),
                                    ejbAnnotation.name(),
                                    AnnotationCacheEntryType.SETTER));
                        } else if ((webServiceRefAnnotation =
                                method.getAnnotation(WebServiceRef.class)) != null) {
                            annotations.add(new AnnotationCacheEntry(
                                    method.getName(),
View Full Code Here

    public void processFieldAnnotation(Object instance,
                                       Field field,
                                       Annotation annotation)
            throws InjectionException {
        EJB resource = (EJB) annotation;
        injectField(instance, field, annotation, resource.name(), null);
    }
View Full Code Here

    public void processMethodAnnotation(Object instance,
                                        Method method,
                                        Annotation annotation)
            throws InjectionException {
        EJB resource = (EJB) annotation;
        injectMethod(instance, method, annotation, resource.name(), null);
    }
View Full Code Here

        List<Method> methodsWithEJB = classFinder.findAnnotatedMethods(EJB.class);
        List<Field> fieldsWithEJB = classFinder.findAnnotatedFields(EJB.class);

        // Class-level annotation
        for (Class cls : classesWithEJB) {
            EJB ejb = (EJB) cls.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, cls, null, null);
            }
        }

        // Method-level annotation
        for (Method method : methodsWithEJB) {
            EJB ejb = method.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, null, method, null);
            }
        }

        // Field-level annotation
        for (Field field : fieldsWithEJB) {
            EJB ejb = field.getAnnotation(EJB.class);
            if (ejb != null) {
                addEJB(annotatedApp, ejb, null, null, field);
            }
        }
View Full Code Here

                        urlSet = urlSet.exclude(parent);
                    }
                }
                ClassFinder finder = new ClassFinder(classLoader, urlSet.getUrls());
                for (Field field : finder.findAnnotatedFields(EJB.class)) {
                    EJB ejb = field.getAnnotation(EJB.class);
                    AnnotationDeployer.Member member = new AnnotationDeployer.FieldMember(field);
                    buildEjbRef(consumer, ejb, member);
                }

                for (Method method : finder.findAnnotatedMethods(EJB.class)) {
                    EJB ejb = method.getAnnotation(EJB.class);
                    AnnotationDeployer.Member member = new AnnotationDeployer.MethodMember(method);
                    buildEjbRef(consumer, ejb, member);
                }

            } catch (IOException e) {
View Full Code Here

         for (EJB ejb : ejbs)
         {
            handleClassAnnotation(ejb, clazz, container);
         }
      }
      EJB ejbref = container.getAnnotation(EJB.class, clazz);
      if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
   }
View Full Code Here

         ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
   }

   public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
   {
      EJB ref = container.getAnnotation(EJB.class, method);
      if (ref != null)
      {
         if (!method.getName().startsWith("set"))
            throw new RuntimeException("@EJB can only be used with a set method: " + method);
         String encName = getEncName(ref, method);
         if (!container.getEncInjectors().containsKey(encName))
         {
            ejbRefEncInjector(ref.mappedName(), encName, method.getName().substring(0), method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
           
            if (container.getAnnotation(IgnoreDependency.class, method) == null)
            {
               if (isIgnoreDependency(container, ref))
                  log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
               else
                  ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
            }
         }

         super.handleMethodAnnotations(method, container, injectors);
      }
View Full Code Here

      }
   }

   public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
   {
      EJB ref = container.getAnnotation(EJB.class, field);
      if (ref != null)
      {
         String encName = getEncName(ref, field);
         if (!container.getEncInjectors().containsKey(encName))
         {
            if (container.getAnnotation(IgnoreDependency.class, field) == null)
            {
               if (isIgnoreDependency(container, ref))
                  log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
               else
                  ejbRefDependency(ref.mappedName(), ref.beanName(), container, field.getType(), "@EJB", encName);
            }
            ejbRefEncInjector(ref.mappedName(), encName, field.getName(), field.getType(), ref.beanName(), "@EJB", container);
         }
         super.handleFieldAnnotations(field, container, injectors);
      }
   }
View Full Code Here

         for (EJB ejb : ejbs)
         {
            handleClassAnnotation(ejb, clazz, container);
         }
      }
      EJB ejbref = container.getAnnotation(EJB.class, clazz);
      if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
   }
View Full Code Here

TOP

Related Classes of javax.ejb.EJB

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.