Package org.jboss.metadata.ejb.spec

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


      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);
      }
      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


         metaData.setMethods(methods);
      }
      String ejbName = EjbNameThreadLocal.ejbName.get();
      if(ejbName == null)
         ejbName = "*";
      MethodMetaData mmd = ProcessorUtils.createMethod(ejbName, method);
      Descriptions descriptions = ProcessorUtils.getDescription("@DenyAll for: "+method);
      mmd.setDescriptions(descriptions);
      log.trace("add " + mmd);
      methods.add(mmd);
   }
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

      return c;
   }

   public static MethodMetaData createMethod(String ejbName, Method method)
   {
      MethodMetaData methodMetaData = new MethodMetaData();
      methodMetaData.setEjbName(ejbName);
      if(method == null)
         methodMetaData.setMethodName("*");
      else
      {
         methodMetaData.setMethodName(method.getName());
         MethodParametersMetaData methodParameters = ProcessorUtils.getMethodParameters(method);
         if(methodParameters != null)
            methodMetaData.setMethodParams(methodParameters);
      }
      return methodMetaData;
   }
View Full Code Here

      MethodPermissionsMetaData permissions = new MethodPermissionsMetaData();
      assembly.setMethodPermissions(permissions);

      // original only
      MethodsMetaData methods = new MethodsMetaData();
      MethodMetaData method = new MethodMetaData();
      method.setEjbName("Original");
      method.setMethodName("execute");
      methods.add(method);

      MethodPermissionMetaData permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      permission.setRoles(java.util.Collections.singleton("original"));
      permissions.add(permission);
     
      // mixed original part
      methods = new MethodsMetaData();
      method = new MethodMetaData();
      method.setEjbName("Overriden");
      method.setMethodName("execute");
      method.setMethodIntf(MethodInterfaceType.Local);
      methods.add(method);

      permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      permission.setRoles(java.util.Collections.singleton("original"));
      permissions.add(permission);

      methods = new MethodsMetaData();
      method = new MethodMetaData();
      method.setEjbName("Overriden");
      method.setMethodName("execute");
      method.setMethodIntf(MethodInterfaceType.Remote);
      methods.add(method);

      permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      Set<String> roles = new HashSet<String>();
      roles.add("original1");
      roles.add("original2");
      permission.setRoles(roles);
      permissions.add(permission);

      // override
      JBoss50MetaData override = new JBoss50MetaData();
      assembly = new JBossAssemblyDescriptorMetaData();
      override.setAssemblyDescriptor(assembly);
      permissions = new MethodPermissionsMetaData();
      assembly.setMethodPermissions(permissions);
     
      // override only
      methods = new MethodsMetaData();
      method = new MethodMetaData();
      method.setEjbName("Override");
      method.setMethodName("execute");
      methods.add(method);

      permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      permission.setRoles(java.util.Collections.singleton("override"));
      permissions.add(permission);

      // mixed override part
      methods = new MethodsMetaData();
      method = new MethodMetaData();
      method.setEjbName("Overriden");
      method.setMethodName("execute");
      method.setMethodIntf(MethodInterfaceType.LocalHome);
      methods.add(method);

      permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      permission.setRoles(java.util.Collections.singleton("override"));
      permissions.add(permission);

      methods = new MethodsMetaData();
      method = new MethodMetaData();
      method.setEjbName("Overriden");
      method.setMethodName("execute");
      method.setMethodIntf(MethodInterfaceType.Remote);
      methods.add(method);

      permission = new MethodPermissionMetaData();
      permission.setMethods(methods);
      roles = new HashSet<String>();
      roles.add("override1");
      roles.add("override2");
      permission.setRoles(roles);
      permissions.add(permission);

      // merge
      JBoss50MetaData merged = new JBoss50MetaData();
      merged.merge(override, original);     
      assembly = merged.getAssemblyDescriptor();
      assertNotNull(assembly);
      permissions = assembly.getMethodPermissions();
      assertNotNull(permissions);
      assertEquals(6, permissions.size());

      for(MethodPermissionMetaData perm : permissions)
      {
         methods = perm.getMethods();
         assertNotNull(methods);
         assertEquals(1, methods.size());
         method = methods.get(0);
         assertNotNull(method);
         assertEquals("execute", method.getMethodName());
         roles = perm.getRoles();
         assertNotNull(roles);
        
         String ejbName = method.getEjbName();
         if("Original".equals(ejbName))
         {
            assertEquals(1, roles.size());
            assertTrue(roles.contains("original"));
         }
         else if("Override".equals(ejbName))
         {
            assertEquals(1, roles.size());
            assertTrue(roles.contains("override"));
         }
         else if("Overriden".equals(ejbName))
         {
            MethodInterfaceType methodIntf = method.getMethodIntf();
            if(MethodInterfaceType.Local == methodIntf)
            {
               assertEquals(1, roles.size());
               assertTrue(roles.contains("original"));              
            }
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

      ContainerTransactionsMetaData containerTransactions = getContainerTransactions();
      if (containerTransactions == null || containerTransactions.isEmpty())
         return result;

      ContainerTransactionMetaData bestMatchTransaction = null;
      MethodMetaData bestMatch = null;
      for (ContainerTransactionMetaData transaction : containerTransactions)
      {
         MethodMetaData match = transaction.bestMatch(methodName, params, iface, bestMatch);
         if (match != bestMatch)
         {
            bestMatchTransaction = transaction;
            bestMatch = match;
         }
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

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.