Package org.jboss.metadata.ejb.spec

Examples of org.jboss.metadata.ejb.spec.MethodMetaData


      TestCase.assertNotNull(permission);

      // Ensure we've got the right method associated w/ the permission
      MethodsMetaData methods = permission.getMethods();
      TestCase.assertEquals(1, methods.size());
      MethodMetaData method = methods.get(0);
      TestCase.assertNotNull(method);
      String methodName = method.getMethodName();
      String expectedMethodName = "someMethod";
      TestCase.assertEquals(expectedMethodName, methodName);

      // Ensure we've got the right role associated w/ the permission
      Set<String> roles = permission.getRoles();
View Full Code Here


      // cls.getDeclaredMethods is un-ordered, so we must use bestMatch
      ExcludeListMetaData excludes = assembly.getExcludeList();
      assertNotNull(excludes);
      MethodsMetaData excludedMethods = excludes.getMethods();
      assertEquals(2, excludedMethods.size());
      MethodMetaData m0 = excludedMethods.bestMatch("denyAll", (Class[]) null, null, null);
      assertEquals("MyStatelessBean", m0.getEjbName());
      assertEquals("denyAll", m0.getMethodName());
      MethodParametersMetaData noargs = new MethodParametersMetaData();
      assertEquals(noargs, m0.getMethodParams());
      MethodMetaData m1 = excludedMethods.bestMatch("excluded", (Class[]) null, null, null);;
      assertEquals("MyStatelessBean", m1.getEjbName());
      assertEquals("excluded", m1.getMethodName());
      assertEquals(noargs, m1.getMethodParams());

      // @PermitAll, @RolesAllowed({"AccessRole1", "AccessRole2"})
      MethodPermissionsMetaData allPerms = assembly.getMethodPermissions();
      assertEquals(8, allPerms.size());
      MethodPermissionsMetaData perms = assembly.getMethodPermissionsByEjbName("MyStatelessBean");
View Full Code Here

      Method method = null;
      if(type instanceof Method)
         method = (Method) type;

      String ejbName = EjbNameThreadLocal.ejbName.get();
      MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method);
     
      /*
       * JBMETA-152
       *
       * Check that we haven't already defined permissions for this method
       */
      MethodPermissionsMetaData existingPerms = metaData.getMethodPermissionsByEjbName(ejbName);
      if (existingPerms != null && !existingPerms.isEmpty())
      {
         for (MethodPermissionMetaData existingPerm : existingPerms)
         {
            for (MethodMetaData existingMethod : existingPerm.getMethods())
            {
               /*
                * JBMETA-207 Only allow overrides if this method signature has
                * not been overridden, and do so in a way that avoids all NPEs
                */
               // If we've got no predefined existing method, move along
               if (existingMethod == null)
               {
                  return;
               }
               // If the preexisting method matches what we have described here,
               // then check the rest of the signature
               if (existingMethod.getMethodName().equals(mmd.getMethodName()))
               {
                  // If this method's already been added (equal signatures), then don't add it again                 
                  final MethodParametersMetaData existingParams = existingMethod.getMethodParams();
                  if (existingParams == null && mmd.getMethodParams() == null)
                  {
                     return;
                  }
                  if (existingParams.equals(mmd.getMethodParams()))
                  {
                     return;

                  }
               }
            }
         }
      }
     
      MethodPermissionMetaData perm = new MethodPermissionMetaData();
      MethodsMetaData methods = perm.getMethods();
      if(methods == null)
      {
         methods = new MethodsMetaData();
         perm.setMethods(methods);
      }
      HashSet<String> roles = new HashSet<String>();
      for(String role : allowed.value())
         roles.add(role);
      perm.setRoles(roles);
      Descriptions descriptions = ProcessorUtils.getDescription("@RolesAllowed for: "+type);
      mmd.setDescriptions(descriptions);
      methods.add(mmd);
      metaData.add(perm);
   }
View Full Code Here

      Method method = null;
      if(type instanceof Method)
         method = (Method) type;

      String ejbName = EjbNameThreadLocal.ejbName.get();
      MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method);
      MethodPermissionMetaData perm = new MethodPermissionMetaData();
      MethodsMetaData methods = perm.getMethods();
      if(methods == null)
      {
         methods = new MethodsMetaData();
         perm.setMethods(methods);
      }
      perm.setUnchecked(new EmptyMetaData());
      Descriptions descriptions = ProcessorUtils.getDescription("@PermitAll for: "+type);
      mmd.setDescriptions(descriptions);
      methods.add(mmd);
      metaData.add(perm);
   }
View Full Code Here

      Class<?>[] interfaces = ejbClass.getInterfaces();
      for (Class<?> beanInterface : interfaces)
      {
         if (beanInterface.equals(javax.ejb.SessionBean.class))
         {
            MethodMetaData method = new MethodMetaData();
            method.setEjbName(container.getEjbName());

            Annotation annotation;
            Class<? extends Annotation> annotationClass;
            // EJB3 4.6.2: The class may implement the ejbCreate method(s).
            // EJB3 4.6.4: The method must be declared as public.
            if(hasPublicMethod(ejbClass, "ejbCreate"))
            {
               if(isStateful)
               {
                  annotation = new InitImpl();
               }
               else
               {
                  annotation = new PostConstructImpl();
               }
               annotationClass = annotation.annotationType();
               method.setMethodName("ejbCreate");
               addAnnotations(annotationClass, annotation, container, method);
            }

            annotation = new PostActivateImpl();
            annotationClass = javax.ejb.PostActivate.class;
            method.setMethodName("ejbActivate");
            addAnnotations(annotationClass, annotation, container, method);

            annotation = new PrePassivateImpl();
            annotationClass = javax.ejb.PrePassivate.class;
            method.setMethodName("ejbPassivate");
            addAnnotations(annotationClass, annotation, container, method);

            annotation = new PreDestroyImpl();
            annotationClass = javax.annotation.PreDestroy.class;
            method.setMethodName("ejbRemove");
            addAnnotations(annotationClass, annotation, container, method);
           
            annotation = new ResourceImpl();
            annotationClass = Resource.class;
            method.setMethodName("setSessionContext");
            // TODO: set param?
            addAnnotations(annotationClass, annotation, container, method);
         }
      }
   }
View Full Code Here

         {
            addClassAnnotation(container, annotationClass, annotation);
         }
         else
         {
            MethodMetaData method = new MethodMetaData();
            method.setMethodName(xmlAnnotation.getInjectionTarget().getInjectionTargetName());
            addAnnotations(annotationClass, annotation, container, method);
         }
      }
   }
View Full Code Here

      {
         for(ResourceInjectionTargetMetaData ignore : enterpriseBean.getIgnoreDependency().getInjectionTargets())
         {
            IgnoreDependencyImpl annotation = new IgnoreDependencyImpl();

            MethodMetaData method = new MethodMetaData();
            method.setMethodName(ignore.getInjectionTargetName());

            addAnnotations(IgnoreDependency.class, annotation, container, method);
         }
      }
   }
View Full Code Here

    */
   private void addEjb21Annotations(EJBContainer container, boolean isStateful) throws Exception
   {
      if(javax.ejb.SessionBean.class.isAssignableFrom(ejbClass))
      {
         MethodMetaData method = new MethodMetaData();
         method.setEjbName(container.getEjbName());

         Annotation annotation;
         Class<? extends Annotation> annotationClass;
         // EJB3 4.6.2: The class may implement the ejbCreate method(s).
         // EJB3 4.6.4: The method must be declared as public.
         if(hasPublicMethod(ejbClass, "ejbCreate"))
         {
            if(isStateful)
            {
               annotation = new InitImpl();
            }
            else
            {
               annotation = new PostConstructImpl();
            }
            annotationClass = annotation.annotationType();
            method.setMethodName("ejbCreate");
            addAnnotations(annotationClass, annotation, container, method);
         }

         annotation = new PostActivateImpl();
         annotationClass = javax.ejb.PostActivate.class;
         method.setMethodName("ejbActivate");
         addAnnotations(annotationClass, annotation, container, method);

         annotation = new PrePassivateImpl();
         annotationClass = javax.ejb.PrePassivate.class;
         method.setMethodName("ejbPassivate");
         addAnnotations(annotationClass, annotation, container, method);

         annotation = new PreDestroyImpl();
         annotationClass = javax.annotation.PreDestroy.class;
         method.setMethodName("ejbRemove");
         addAnnotations(annotationClass, annotation, container, method);
           
         annotation = new ResourceImpl();
         annotationClass = Resource.class;
         method.setMethodName("setSessionContext");
         // TODO: set param?
         addAnnotations(annotationClass, annotation, container, method);
      }
   }
View Full Code Here

         {
            addClassAnnotation(container, annotationClass, annotation);
         }
         else
         {
            MethodMetaData method = new MethodMetaData();
            method.setMethodName(xmlAnnotation.getInjectionTarget().getInjectionTargetName());
            addAnnotations(annotationClass, annotation, container, method);
         }
      }
   }
View Full Code Here

      {
         for(ResourceInjectionTargetMetaData ignore : enterpriseBean.getIgnoreDependency().getInjectionTargets())
         {
            IgnoreDependencyImpl annotation = new IgnoreDependencyImpl();

            MethodMetaData method = new MethodMetaData();
            method.setMethodName(ignore.getInjectionTargetName());

            addAnnotations(IgnoreDependency.class, annotation, container, method);
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.metadata.ejb.spec.MethodMetaData

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.