Package org.ow2.util.scan.api.metadata.structures

Examples of org.ow2.util.scan.api.metadata.structures.JMethod


        // As the Bean class may not implement the interface, ads also the local and remote business interfaces
        List<String> businessInterfaces = new ArrayList<String>();
        // Add implemented interfaces
        businessInterfaces.addAll(Arrays.asList(visitingclassAnnotationMetadata.getInterfaces()));
        // Add local interfaces
        IJLocal localInterfaces = beanclassAnnotationMetadata.getLocalInterfaces();
        if (localInterfaces != null) {
            for (String itf : localInterfaces.getInterfaces()) {
                if (!businessInterfaces.contains(itf)) {
                    businessInterfaces.add(itf);
                }
            }
        }
View Full Code Here


     * @param sessionBean Session bean to analyze
     */
    public static void resolve(final EasyBeansEjbJarClassMetadata sessionBean) {

        IJLocal jLocal = sessionBean.getLocalInterfaces();
        IJRemote jRemote = sessionBean.getRemoteInterfaces();

        // No business interface or empty annotation (@Remote or @Local)
        if ((jLocal == null && jRemote == null) || (jLocal == null && jRemote != null && jRemote.getInterfaces().isEmpty())
                || (jRemote == null && jLocal != null && jLocal.getInterfaces().isEmpty())) {

            // The following interfaces are excluded when determining whether
            // the bean class has
            // more than one interface: java.io.Serializable;
            // java.io.Externalizable;
            // any of the interfaces defined by the javax.ejb package.
            String[] interfaces = sessionBean.getInterfaces();
            List<String> inheritedInterfaces = sessionBean.getInheritedInterfaces();

            int numberItfFound = 0;
            String itfFound = null;
            for (String itf : interfaces) {
                if (!itf.equals(java.io.Serializable.class.getName().replace(".", "/"))
                        && !itf.equals(java.io.Externalizable.class.getName().replace(".", "/"))
                        && !itf.startsWith("javax/ejb")
                        // Should not be inherited
                        && !inheritedInterfaces.contains(itf)
                        ) {
                    itfFound = itf;
                    numberItfFound++;
                }
            }

            // No business interface found but there is only one inherited interface, use it.
            if (numberItfFound == 0 && inheritedInterfaces != null && inheritedInterfaces.size() == 1) {
                itfFound = inheritedInterfaces.get(0);
                numberItfFound = 1;
            }


            // No business interface found
            if (numberItfFound == 0) {
                // if this is a 2.1 bean, it could be normal
                if (sessionBean.getRemoteHome() != null || sessionBean.getLocalHome() != null) {
                    return;
                }

                logger.warn("No business interface found on bean class {0}.", sessionBean.getClassName());
            } else {

                if (numberItfFound > 1) {
                    throw new IllegalStateException("More than 1 itf on class '" + sessionBean.getClassName() + "'.");
                }

                // If bean class implements a single interface, that interface is
                // assumed to be the business
                // interface of the bean. This business interface will be a local
                // interface unless the
                // interface is designated as a remote business interface by use of
                // the Remote annotation
                // on the bean class or interface or by means of the deployment
                // descriptor.

                // Build a local interface if no @Remote annotation, else add interface in the existing object
                if (jRemote == null) {
                    JLocal addedJLocal = new JLocal();
                    addedJLocal.addInterface(itfFound);
                    sessionBean.setLocalInterfaces(addedJLocal);
                } else {
                    jRemote.addInterface(itfFound);
                    sessionBean.setRemoteInterfaces(jRemote);
                }
            }
        }
    }
View Full Code Here

                    businessInterfaces.add(itf);
                }
            }
        }
        // Remote interfaces
        IJRemote remoteInterfaces = beanclassAnnotationMetadata.getRemoteInterfaces();
        if (remoteInterfaces != null) {
            for (String itf : remoteInterfaces.getInterfaces()) {
                if (!businessInterfaces.contains(itf)) {
                    businessInterfaces.add(itf);
                }
            }
        }
View Full Code Here

                // on the bean class or interface or by means of the deployment
                // descriptor.

                // Build a local interface if no @Remote annotation, else add interface in the existing object
                if (jRemote == null) {
                    JLocal addedJLocal = new JLocal();
                    addedJLocal.addInterface(itfFound);
                    sessionBean.setLocalInterfaces(addedJLocal);
                } else {
                    jRemote.addInterface(itfFound);
                    sessionBean.setRemoteInterfaces(jRemote);
                }
View Full Code Here

            metadataRemove = new EasyBeansEjbJarMethodMetadata(REMOVE_METHOD, bean);
            bean.addStandardMethodMetadata(metadataRemove);
        }

        // flag method as a remove method
        metadataRemove.setRemove(new JRemove());
        metadataRemove.setBusinessMethod(true);


        // Flag ejbXXX() method as business method (so interceptors are invoked)
        for (EasyBeansEjbJarMethodMetadata methodData : bean.getMethodMetadataCollection()) {
View Full Code Here

                throw new DeployerException("Cannot get the URL for the archive '" + war.getArchive() + "'.", e);
            }


            // Analyze the war archive
            IWarDeployableMetadata warDeployableMetadata = null;
            try {
                warDeployableMetadata = new WarDeployableMetadataFactory().createDeployableMetadata(war);
            } catch (DeployableMetadataException e) {
                logger.error("Unable to analyze the metadata of the war '" + warURL + "'.", e);
            }
View Full Code Here


            // Analyze the war archive
            IWarDeployableMetadata warDeployableMetadata = null;
            try {
                warDeployableMetadata = new WarDeployableMetadataFactory().createDeployableMetadata(war);
            } catch (DeployableMetadataException e) {
                logger.error("Unable to analyze the metadata of the war '" + warURL + "'.", e);
            }

            // Now, get the bindings for this web application
View Full Code Here

                        + "' referenced in the home/localhome of the bean '" + bean.getClassName() + "'.");
            }

            // Get all methods
            for (EasyBeansEjbJarMethodMetadata methodData : interfaceUsed.getMethodMetadataCollection()) {
                JMethod itfMethod = methodData.getJMethod();

                // Ignore class init method
                if (itfMethod.getName().equals(BusinessMethodResolver.CLASS_INIT)
                        || itfMethod.getName().equals(BusinessMethodResolver.CONST_INIT)) {
                    continue;
                }

                // take the method from the bean class
                EasyBeansEjbJarMethodMetadata beanMethod = bean.getMethodMetadata(itfMethod);
                if (beanMethod == null) {
                    throw new IllegalStateException("No method was found for method " + itfMethod + " in class "
                            + bean.getClassName());
                }
                beanMethod.setBusinessMethod(true);
            }

        }

        // Add remove method
        EasyBeansEjbJarMethodMetadata metadataRemove = bean.getMethodMetadata(REMOVE_METHOD);
        // not present ? add it
        if (metadataRemove == null) {
            metadataRemove = new EasyBeansEjbJarMethodMetadata(REMOVE_METHOD, bean);
            bean.addStandardMethodMetadata(metadataRemove);
        }

        // flag method as a remove method
        metadataRemove.setRemove(new JRemove());
        metadataRemove.setBusinessMethod(true);


        // Flag ejbXXX() method as business method (so interceptors are invoked)
        for (EasyBeansEjbJarMethodMetadata methodData : bean.getMethodMetadataCollection()) {
          JMethod method = methodData.getJMethod();
          if (method.getName().startsWith("ejbActivate") || method.getName().startsWith("ejbCreate")) {
            if ("()V".equals(method.getDescriptor())) {
              methodData.setBusinessMethod(true);
            }
          }
        }
View Full Code Here

        // Get methods
        for (EasyBeansEjbJarMethodMetadata method : homeMetadata.getMethodMetadataCollection()) {
            // if method name begins with "create", it's matching
            if (method.getMethodName().startsWith("create")) {
                // Get return type
                JMethod jMethod = method.getJMethod();
                Type returnType = Type.getReturnType(jMethod.getDescriptor());
                String returnTypeClassname = returnType.getClassName();
                // Not yet present in the list ? add it
                if (!interfacesList.contains(returnTypeClassname)) {
                    interfacesList.add(returnTypeClassname.replace(".", "/"));
                }
View Full Code Here

     *         this method.
     */
    @Override
    public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
            final String[] exceptions) {
        JMethod jMethod = new JMethod(access, name, desc, signature, exceptions);
        String newName = name;
        int newAccess = access;

        // Intercepted method : need to change the method name for Beans
        if (isInterceptedMethod(jMethod) && this.classAnnotationMetadata.isBean()) {
View Full Code Here

TOP

Related Classes of org.ow2.util.scan.api.metadata.structures.JMethod

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.