Package javax.ejb

Examples of javax.ejb.EJB


            Resource annotation =  method.getAnnotation(Resource.class);
            lookupMethodResource(context, instance, method, annotation.name());
        }
        if (method.isAnnotationPresent(EJB.class))
        {
            EJB annotation =  method.getAnnotation(EJB.class);
            lookupMethodResource(context, instance, method, annotation.name());
        }
        // TODO where i find WebServiceRef?
        /*if (method.isAnnotationPresent(WebServiceRef.class)) {
            WebServiceRef annotation =
                (WebServiceRef) method.getAnnotation(WebServiceRef.class);
            lookupMethodResource(context, instance, methods, annotation.name());
        }*/
        if (method.isAnnotationPresent(PersistenceContext.class))
        {
            PersistenceContext annotation = method.getAnnotation(PersistenceContext.class);
            lookupMethodResource(context, instance, method, annotation.name());
        }
        if (method.isAnnotationPresent(PersistenceUnit.class))
        {
            PersistenceUnit annotation = method.getAnnotation(PersistenceUnit.class);
            lookupMethodResource(context, instance, method, annotation.name());
        }
    }
View Full Code Here


            throws NamingException, IllegalAccessException
    {
        super.checkFieldAnnotation(field, instance);
        if (field.isAnnotationPresent(EJB.class))
        {
            EJB annotation = field.getAnnotation(EJB.class);
            lookupFieldResource(context, instance, field, annotation.name());
        }
        /*if (field.isAnnotationPresent(WebServiceRef.class)) {
            WebServiceRef annotation =
                (WebServiceRef) field.getAnnotation(WebServiceRef.class);
            lookupFieldResource(context, instance, field, annotation.name());
        }*/
        if (field.isAnnotationPresent(PersistenceContext.class))
        {
            PersistenceContext annotation = field.getAnnotation(PersistenceContext.class);
            lookupFieldResource(context, instance, field, annotation.name());
        }
        if (field.isAnnotationPresent(PersistenceUnit.class))
        {
            PersistenceUnit annotation = field.getAnnotation(PersistenceUnit.class);
            lookupFieldResource(context, instance, field, annotation.name());
        }
    }
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 = (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

                } else if (field.isAnnotationPresent(Resource.class)) {
                    Resource annotation = field.getAnnotation(Resource.class);
                    lookupFieldResource(context, instance, field,
                            annotation.name(), clazz);
                } else if (field.isAnnotationPresent(EJB.class)) {
                    EJB annotation = field.getAnnotation(EJB.class);
                    lookupFieldResource(context, instance, field,
                            annotation.name(), clazz);
                } else if (field.isAnnotationPresent(WebServiceRef.class)) {
                    WebServiceRef annotation =
                            field.getAnnotation(WebServiceRef.class);
                    lookupFieldResource(context, instance, field,
                            annotation.name(), clazz);
                } else if (field.isAnnotationPresent(PersistenceContext.class)) {
                    PersistenceContext annotation =
                            field.getAnnotation(PersistenceContext.class);
                    lookupFieldResource(context, instance, field,
                            annotation.name(), clazz);
                } else if (field.isAnnotationPresent(PersistenceUnit.class)) {
                    PersistenceUnit annotation =
                            field.getAnnotation(PersistenceUnit.class);
                    lookupFieldResource(context, instance, field,
                            annotation.name(), clazz);
                }
            }
   
            // Initialize methods annotations
            Method[] methods = null;
            if (Globals.IS_SECURITY_ENABLED) {
                final Class<?> clazz2 = clazz;
                methods = AccessController.doPrivileged(
                        new PrivilegedAction<Method[]>(){
                    @Override
                    public Method[] run(){
                        return clazz2.getDeclaredMethods();
                    }
                });
            } else {
                methods = clazz.getDeclaredMethods();
            }
            for (Method method : methods) {
                String methodName = method.getName();
                if (injections != null && methodName.startsWith("set") && methodName.length() > 3) {
                    String fieldName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
                    if (injections.containsKey(fieldName)) {
                        lookupMethodResource(context, instance, method,
                                injections.get(fieldName), clazz);
                        break;
                    }
                }
                if (method.isAnnotationPresent(Resource.class)) {
                    Resource annotation = method.getAnnotation(Resource.class);
                    lookupMethodResource(context, instance, method,
                            annotation.name(), clazz);
                } else if (method.isAnnotationPresent(EJB.class)) {
                    EJB annotation = method.getAnnotation(EJB.class);
                    lookupMethodResource(context, instance, method,
                            annotation.name(), clazz);
                } else if (method.isAnnotationPresent(WebServiceRef.class)) {
                    WebServiceRef annotation =
                            method.getAnnotation(WebServiceRef.class);
                    lookupMethodResource(context, instance, method,
                            annotation.name(), clazz);
                } else if (method.isAnnotationPresent(PersistenceContext.class)) {
                    PersistenceContext annotation =
                            method.getAnnotation(PersistenceContext.class);
                    lookupMethodResource(context, instance, method,
                            annotation.name(), clazz);
                } else if (method.isAnnotationPresent(PersistenceUnit.class)) {
                    PersistenceUnit annotation =
                            method.getAnnotation(PersistenceUnit.class);
                    lookupMethodResource(context, instance, method,
                            annotation.name(), clazz);
                }
            }
            clazz = clazz.getSuperclass();
        }
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 = (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

                        Resource annotation = field.getAnnotation(Resource.class);
                        annotations.add(new AnnotationCacheEntry(field,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (field.isAnnotationPresent(EJB.class)) {
                        EJB annotation = field.getAnnotation(EJB.class);
                        annotations.add(new AnnotationCacheEntry(field,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (field.isAnnotationPresent(WebServiceRef.class)) {
                        WebServiceRef annotation =
                                field.getAnnotation(WebServiceRef.class);
                        annotations.add(new AnnotationCacheEntry(field,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (field.isAnnotationPresent(PersistenceContext.class)) {
                        PersistenceContext annotation =
                                field.getAnnotation(PersistenceContext.class);
                        annotations.add(new AnnotationCacheEntry(field,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (field.isAnnotationPresent(PersistenceUnit.class)) {
                        PersistenceUnit annotation =
                                field.getAnnotation(PersistenceUnit.class);
                        annotations.add(new AnnotationCacheEntry(field,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    }
                }
       
                // Initialize methods annotations
                Method[] methods = null;
                if (Globals.IS_SECURITY_ENABLED) {
                    final Class<?> clazz2 = clazz;
                    methods = AccessController.doPrivileged(
                            new PrivilegedAction<Method[]>(){
                        @Override
                        public Method[] run(){
                            return clazz2.getDeclaredMethods();
                        }
                    });
                } else {
                    methods = clazz.getDeclaredMethods();
                }
                Method postConstruct = null;
                Method preDestroy = null;
                for (Method method : methods) {
                    String methodName = method.getName();
                    if (injections != null && methodName.startsWith("set") && methodName.length() > 3) {
                        String fieldName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
                        if (injections.containsKey(fieldName)) {
                            annotations.add(new AnnotationCacheEntry(method,
                                    injections.get(method.getName()),
                                    AnnotationCacheEntryType.FIELD));
                            break;
                        }
                    }
                    if (method.isAnnotationPresent(Resource.class)) {
                        Resource annotation = method.getAnnotation(Resource.class);
                        annotations.add(new AnnotationCacheEntry(method,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (method.isAnnotationPresent(EJB.class)) {
                        EJB annotation = method.getAnnotation(EJB.class);
                        annotations.add(new AnnotationCacheEntry(method,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (method.isAnnotationPresent(WebServiceRef.class)) {
                        WebServiceRef annotation =
                                method.getAnnotation(WebServiceRef.class);
                        annotations.add(new AnnotationCacheEntry(method,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (method.isAnnotationPresent(PersistenceContext.class)) {
                        PersistenceContext annotation =
                                method.getAnnotation(PersistenceContext.class);
                        annotations.add(new AnnotationCacheEntry(method,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    } else if (method.isAnnotationPresent(PersistenceUnit.class)) {
                        PersistenceUnit annotation =
                                method.getAnnotation(PersistenceUnit.class);
                        annotations.add(new AnnotationCacheEntry(method,
                                annotation.name(),
                                AnnotationCacheEntryType.FIELD));
                    }

                    if (method.isAnnotationPresent(PostConstruct.class)) {
                        if ((postConstruct != null) ||
View Full Code Here

    }

    private void validateEjbProducer( Class annotatedClass,
                                      AnnotatedField annotatedField,
                                      List<InjectionCapable> injectionResources ) {
        EJB ejbAnnotation = annotatedField.getAnnotation(EJB.class);
        if ( ejbAnnotation != null ) {
            String lookupName = getLookupName(annotatedClass,
                                              annotatedField,
                                              injectionResources);
View Full Code Here

        String lookupName = null;
        if ( annotatedField.isAnnotationPresent( Resource.class ) ) {
            Resource resource = annotatedField.getAnnotation( Resource.class );
            lookupName = getJndiName( resource.lookup(), resource.mappedName(), resource.name() );
        } else if ( annotatedField.isAnnotationPresent( EJB.class ) ) {
            EJB ejb = annotatedField.getAnnotation( EJB.class );
            lookupName = getJndiName(ejb.lookup(), ejb.mappedName(), ejb.name());
        } else if ( annotatedField.isAnnotationPresent( WebServiceRef.class ) ) {
            WebServiceRef webServiceRef = annotatedField.getAnnotation( WebServiceRef.class );
            lookupName = getJndiName(webServiceRef.lookup(), webServiceRef.mappedName(), webServiceRef.name());
        } else if ( annotatedField.isAnnotationPresent( PersistenceUnit.class ) ) {
            PersistenceUnit persistenceUnit = annotatedField.getAnnotation( PersistenceUnit.class );
View Full Code Here

    }

    private void validateEjbProducer( Class annotatedClass,
                                      AnnotatedField annotatedField,
                                      List<InjectionCapable> injectionResources ) {
        EJB ejbAnnotation = annotatedField.getAnnotation(EJB.class);
        if ( ejbAnnotation != null ) {
            String lookupName = getLookupName(annotatedClass,
                                              annotatedField,
                                              injectionResources);
View Full Code Here

        String lookupName = null;
        if ( annotatedField.isAnnotationPresent( Resource.class ) ) {
            Resource resource = annotatedField.getAnnotation( Resource.class );
            lookupName = getJndiName( resource.lookup(), resource.mappedName(), resource.name() );
        } else if ( annotatedField.isAnnotationPresent( EJB.class ) ) {
            EJB ejb = annotatedField.getAnnotation( EJB.class );
            lookupName = getJndiName(ejb.lookup(), ejb.mappedName(), ejb.name());
        } else if ( annotatedField.isAnnotationPresent( WebServiceRef.class ) ) {
            WebServiceRef webServiceRef = annotatedField.getAnnotation( WebServiceRef.class );
            lookupName = getJndiName(webServiceRef.lookup(), webServiceRef.mappedName(), webServiceRef.name());
        } else if ( annotatedField.isAnnotationPresent( PersistenceUnit.class ) ) {
            PersistenceUnit persistenceUnit = annotatedField.getAnnotation( PersistenceUnit.class );
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.