Package org.apache.geronimo.xbeans.javaee

Examples of org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType


        List<Class> classes = new ArrayList<Class>();

        // Get all the servlets from the deployment descriptor
        ServletType[] servlets = webApp.getServletArray();
        for (ServletType servlet : servlets) {
            FullyQualifiedClassType cls = servlet.getServletClass();
            if (cls != null) {                              // Don't try this for JSPs
                Class<?> clas;
                try {
                    clas = classLoader.loadClass(cls.getStringValue());
                } catch (ClassNotFoundException e) {
                    throw new DeploymentException("AbstractWebModuleBuilder: Could not load servlet class: " + cls.getStringValue(), e);
                }
                addClass(classes, clas);
            }
        }

        // Get all the listeners from the deployment descriptor
        ListenerType[] listeners = webApp.getListenerArray();
        for (ListenerType listener : listeners) {
            FullyQualifiedClassType cls = listener.getListenerClass();
            Class<?> clas;
            try {
                clas = classLoader.loadClass(cls.getStringValue());
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("AbstractWebModuleBuilder: Could not load listener class: " + cls.getStringValue(), e);
            }
            addClass(classes, clas);
        }

        // Get all the filters from the deployment descriptor
        FilterType[] filters = webApp.getFilterArray();
        for (FilterType filter : filters) {
            FullyQualifiedClassType cls = filter.getFilterClass();
            Class<?> clas;
            try {
                clas = classLoader.loadClass(cls.getStringValue());
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("AbstractWebModuleBuilder: Could not load filter class: " + cls.getStringValue(), e);
            }
            addClass(classes, clas);
        }

        // see https://issues.apache.org/jira/browse/GERONIMO-3421 .
View Full Code Here


                        JndiNameType resourceRefName = resourceRef.addNewResRefName();
                        resourceRefName.setStringValue(resourceName);

                        if (!resourceType.equals("")) {
                            // resource-ref-type
                            FullyQualifiedClassType qualifiedClass = resourceRef.addNewResType();
                            qualifiedClass.setStringValue(resourceType);
                        }
                        if (method != null || field != null) {
                            // injectionTarget
                            InjectionTargetType injectionTarget = resourceRef.addNewInjectionTarget();
                            configureInjectionTarget(injectionTarget, method, field);
View Full Code Here

            for (Method m : postConstructs) {
                String methodName = m.getName();
                String className = m.getDeclaringClass().getName();
                if (!postConstructMap.containsKey(className)) {
                    LifecycleCallbackType callback = annotatedApp.addPostConstruct();
                    FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
                    classType.setStringValue(className);
                    JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
                    method.setStringValue(methodName);
                    postConstructMap.put(className, callback);
                }
            }
            List<Method> preDestroys = classFinder.findAnnotatedMethods(PreDestroy.class);
            for (Method m : preDestroys) {
                String methodName = m.getName();
                String className = m.getDeclaringClass().getName();
                if (!preDestroyMap.containsKey(className)) {
                    LifecycleCallbackType callback = annotatedApp.addPreDestroy();
                    FullyQualifiedClassType classType = callback.addNewLifecycleCallbackClass();
                    classType.setStringValue(className);
                    JavaIdentifierType method = callback.addNewLifecycleCallbackMethod();
                    method.setStringValue(methodName);
                    preDestroyMap.put(className, callback);
                }
            }
View Full Code Here

    protected static void configureInjectionTarget(InjectionTargetType injectionTarget, Method method, Field field) {

        String injectionJavaType = getInjectionJavaType(method, field);
        String injectionClass = getInjectionClass(method, field);

        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
        qualifiedClass.setStringValue(injectionClass);
        javaType.setStringValue(injectionJavaType);
    }
View Full Code Here

                    }

                    // injectionTarget
                    if (method != null || field != null) {                            // No class-level injection
                        InjectionTargetType injectionTarget = ejbLocalRef.addNewInjectionTarget();
                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
                        if (method != null) {
                            qualifiedClass.setStringValue(method.getDeclaringClass().getName());
                            javaType.setStringValue(method.getName().substring(3));   // method should start with "set"
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                        else if (field != null) {
                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
                            javaType.setStringValue(field.getName());
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                    }

                }
                catch (Exception anyException) {
                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-local-ref>");
                    anyException.printStackTrace();
                }
            }
        }                                                                           // end if local
        else if (remoteFlag) {                                                      // remote

            //--------------------------------------------------------------------------------------
            // 2. <ejb-ref>
            //--------------------------------------------------------------------------------------

            log.debug("addEJB(): <ejb-ref> found");

            String remoteRefName = annotation.name();
            if (remoteRefName.equals("")) {
                if (method != null) {
                    remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3); // method should start with "set"
                } else if (field != null) {
                    remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
                }
            }

            boolean exists = false;
            EjbRefType[] ejbRefEntries = annotatedApp.getEjbRefArray();
            for (EjbRefType ejbRefEntry : ejbRefEntries) {
                if (ejbRefEntry.getEjbRefName().getStringValue().trim().equals(remoteRefName)) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                try {

                    log.debug("addEJB(): Does not exist in DD: " + remoteRefName);

                    // Doesn't exist in deployment descriptor -- add new
                    EjbRefType ejbRef = annotatedApp.addNewEjbRef();

                    //------------------------------------------------------------------------------
                    // <ejb-ref> required elements:
                    //------------------------------------------------------------------------------

                    // ejb-ref-name
                    EjbRefNameType ejbRefName = ejbRef.addNewEjbRefName();
                    ejbRefName.setStringValue(remoteRefName);
                    ejbRef.setEjbRefName(ejbRefName);

                    //------------------------------------------------------------------------------
                    // <ejb-ref> optional elements:
                    //------------------------------------------------------------------------------

                    // remote
                    if (interfce != null) {
                        String remoteAnnotation = interfce.getName();
                        if (!remoteAnnotation.equals("")) {
                            RemoteType remote = ejbRef.addNewRemote();
                            remote.setStringValue(remoteAnnotation);
                            ejbRef.setRemote(remote);
                        }
                    }

                    // ejb-link
                    String beanName = annotation.beanName();
                    if (!beanName.equals("")) {
                        EjbLinkType ejbLink = ejbRef.addNewEjbLink();
                        ejbLink.setStringValue(beanName);
                        ejbRef.setEjbLink(ejbLink);
                    }

                    // mappedName
                    String mappdedNameAnnotation = annotation.mappedName();
                    if (!mappdedNameAnnotation.equals("")) {
                        XsdStringType mappedName = ejbRef.addNewMappedName();
                        mappedName.setStringValue(mappdedNameAnnotation);
                        ejbRef.setMappedName(mappedName);
                    }

                    // description
                    String descriptionAnnotation = annotation.description();
                    if (!descriptionAnnotation.equals("")) {
                        DescriptionType description = ejbRef.addNewDescription();
                        description.setStringValue(descriptionAnnotation);
                    }

                    // injectionTarget
                    if (method != null || field != null) {                            // No class-level injection
                        InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
                        if (method != null) {
                            qualifiedClass.setStringValue(method.getDeclaringClass().getName());
                            javaType.setStringValue(method.getName().substring(3));   // method should start with "set"
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                        else if (field != null) {
                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
                            javaType.setStringValue(field.getName());
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                    }

                }
                catch (Exception anyException) {
                    log.debug("EJBAnnotationHelper: Exception caught while processing <ejb-ref>");
                    anyException.printStackTrace();
                }
            }
        }                                                                           // end if remote
        else {                                                                      // ambiguous

            //--------------------------------------------------------------------------------------
            // 3. <UNKNOWN>
            //--------------------------------------------------------------------------------------
            log.debug("addEJB(): <UNKNOWN> found");

            String remoteRefName = annotation.name();
            if (remoteRefName.equals("")) {
                if (method != null) {
                    remoteRefName = method.getDeclaringClass().getName() + "/" + method.getName().substring(3); // method should start with "set"
                } else if (field != null) {
                    remoteRefName = field.getDeclaringClass().getName() + "/" + field.getName();
                }
            }

            boolean exists = false;
            EjbRefType[] ejbRefEntries = annotatedApp.getEjbRefArray();
            for (EjbRefType ejbRefEntry : ejbRefEntries) {
                if (ejbRefEntry.getEjbRefName().getStringValue().trim().equals(remoteRefName)) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                try {

                    log.debug("addEJB(): Does not exist in DD: " + remoteRefName);

                    // Doesn't exist in deployment descriptor -- add as an <ejb-ref> to the
                    // ambiguous list so that it can be resolved later
                    EjbRefType ejbRef = EjbRefType.Factory.newInstance();
                    annotatedApp.getAmbiguousEjbRefs().add(ejbRef);

                    //------------------------------------------------------------------------------
                    // <ejb-ref> required elements:
                    //------------------------------------------------------------------------------

                    // ejb-ref-name
                    EjbRefNameType ejbRefName = ejbRef.addNewEjbRefName();
                    ejbRefName.setStringValue(remoteRefName);
                    ejbRef.setEjbRefName(ejbRefName);

                    //------------------------------------------------------------------------------
                    // <ejb-ref> optional elements:
                    //------------------------------------------------------------------------------

                    // remote
                    if (interfce != null) {
                        String remoteAnnotation = interfce.getName();
                        if (!remoteAnnotation.equals("")) {
                            RemoteType remote = ejbRef.addNewRemote();
                            remote.setStringValue(remoteAnnotation);
                            ejbRef.setRemote(remote);
                        }
                    }

                    // ejb-link
                    String beanName = annotation.beanName();
                    if (!beanName.equals("")) {
                        EjbLinkType ejbLink = ejbRef.addNewEjbLink();
                        ejbLink.setStringValue(beanName);
                        ejbRef.setEjbLink(ejbLink);
                    }

                    // mappedName
                    String mappdedNameAnnotation = annotation.mappedName();
                    if (!mappdedNameAnnotation.equals("")) {
                        XsdStringType mappedName = ejbRef.addNewMappedName();
                        mappedName.setStringValue(mappdedNameAnnotation);
                        ejbRef.setMappedName(mappedName);
                    }

                    // description
                    String descriptionAnnotation = annotation.description();
                    if (!descriptionAnnotation.equals("")) {
                        DescriptionType description = ejbRef.addNewDescription();
                        description.setStringValue(descriptionAnnotation);
                    }

                    // injectionTarget
                    if (method != null || field != null) {                            // No class-level injection
                        InjectionTargetType injectionTarget = ejbRef.addNewInjectionTarget();
                        FullyQualifiedClassType qualifiedClass = injectionTarget.addNewInjectionTargetClass();
                        JavaIdentifierType javaType = injectionTarget.addNewInjectionTargetName();
                        if (method != null) {
                            qualifiedClass.setStringValue(method.getDeclaringClass().getName());
                            javaType.setStringValue(method.getName().substring(3));   // method should start with "set"
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                        else if (field != null) {
                            qualifiedClass.setStringValue(field.getDeclaringClass().getName());
                            javaType.setStringValue(field.getName());
                            injectionTarget.setInjectionTargetClass(qualifiedClass);
                            injectionTarget.setInjectionTargetName(javaType);
                        }
                    }
View Full Code Here

            serviceRefName.setStringValue(webServiceRefName);
            serviceRef.setServiceRefName(serviceRefName);

            // service-ref-interface
            if (!webServiceRefValue.equals(Object.class)) {
                FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
                qualifiedClass.setStringValue(webServiceRefValue.getName());
                serviceRef.setServiceInterface(qualifiedClass);
            } else {
                FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceInterface();
                qualifiedClass.setStringValue(webServiceRefType.getName());
                serviceRef.setServiceInterface(qualifiedClass);
            }
        }

        //------------------------------------------------------------------------------
        // <service-ref> optional elements:
        //------------------------------------------------------------------------------

        // service-ref-type
        if (!serviceRef.isSetServiceRefType() && !webServiceRefType.equals(Object.class)) {
            FullyQualifiedClassType qualifiedClass = serviceRef.addNewServiceRefType();
            qualifiedClass.setStringValue(webServiceRefType.getName());
            serviceRef.setServiceRefType(qualifiedClass);
        }

        // mapped-name
        if (!serviceRef.isSetMappedName() && annotation.mappedName().trim().length() > 0) {
View Full Code Here

                        JndiNameType serviceRefName = serviceRef.addNewServiceRefName();
                        serviceRefName.setStringValue(resourceName);
                        serviceRef.setServiceRefName(serviceRefName);

                        // service-ref-interface
                        FullyQualifiedClassType serviceRefInterfaceClass = serviceRef.addNewServiceInterface();
                        serviceRefInterfaceClass.setStringValue(resourceType);
                        serviceRef.setServiceInterface(serviceRefInterfaceClass);

                        //------------------------------------------------------------------------------
                        // <service-ref> optional elements:
                        //------------------------------------------------------------------------------

                        // description
                        String descriptionAnnotation = annotation.description();
                        if (!descriptionAnnotation.equals("")) {
                            DescriptionType description = serviceRef.addNewDescription();
                            description.setStringValue(descriptionAnnotation);
                        }

                        // service-ref-type
                        if (!serviceRef.isSetServiceRefType()) {
                            FullyQualifiedClassType serviceRefTypeClass = serviceRef.addNewServiceRefType();
                            serviceRefTypeClass.setStringValue(resourceType);
                            serviceRef.setServiceRefType(serviceRefTypeClass);
                        }

                        // mappedName
                        if (!serviceRef.isSetMappedName() && annotation.mappedName().trim().length() > 0) {
View Full Code Here

            resourceEnvRefName.setStringValue(resourceName);
            resourceEnvRef.setResourceEnvRefName(resourceEnvRefName);

            if (!resourceType.equals("")) {
                // resource-env-ref-type
                FullyQualifiedClassType qualifiedClass = resourceEnvRef.addNewResourceEnvRefType();
                qualifiedClass.setStringValue(resourceType);
                resourceEnvRef.setResourceEnvRefType(qualifiedClass);
            }
            if (method != null || field != null) {
                // injectionTarget
                InjectionTargetType injectionTarget = resourceEnvRef.addNewInjectionTarget();
View Full Code Here

                        JndiNameType resourceRefName = resourceRef.addNewResRefName();
                        resourceRefName.setStringValue(resourceName);

                        if (!resourceType.equals("")) {
                            // resource-ref-type
                            FullyQualifiedClassType qualifiedClass = resourceRef.addNewResType();
                            qualifiedClass.setStringValue(resourceType);
                        }
                        if (method != null || field != null) {
                            // injectionTarget
                            InjectionTargetType injectionTarget = resourceRef.addNewInjectionTarget();
                            configureInjectionTarget(injectionTarget, method, field);
View Full Code Here

            mainClas = mainClas.getSuperclass();
        }

        // Get the callback-handler from the deployment descriptor
        if (appClient.isSetCallbackHandler()) {
            FullyQualifiedClassType cls = appClient.getCallbackHandler();
            Class<?> clas;
            try {
                clas = classLoader.loadClass(cls.getStringValue().trim());
            }
            catch (ClassNotFoundException e) {
                throw new DeploymentException("AppClientModuleBuilder: Could not load callback-handler class: " + cls.getStringValue(), e);
            }
            classes.add(clas);
        }

        return new ClassFinder(classes);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.xbeans.javaee.FullyQualifiedClassType

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.