Package org.jboss.aop.introduction

Examples of org.jboss.aop.introduction.InterfaceIntroduction


            }
         }

         for (int i = 0; i < interfaceIntroductions.size(); ++i)
         {
            InterfaceIntroduction ii = interfaceIntroductions.get(i);
            String[] intf = ii.getInterfaces();
            addMethodsFromInterfaces(intf);

            ArrayList<InterfaceIntroduction.Mixin> mixins = ii.getMixins();
            if (mixins.size() > 0)
            {
               for (InterfaceIntroduction.Mixin mixin : mixins)
               {
                  String[] mintf = mixin.getInterfaces();
View Full Code Here


      Iterator<InterfaceIntroduction> it = pointcuts.iterator();
      if (it.hasNext()) setupBasics(clazz);
      while (it.hasNext())
      {

         InterfaceIntroduction pointcut = it.next();
         ArrayList<InterfaceIntroduction.Mixin> mixins = pointcut.getMixins();
         for (InterfaceIntroduction.Mixin mixin: mixins)
         {
            addMixin(clazz, pointcut, mixin, baseMethods);
         }
      }

      // pointcut interfaces.  If a method is already implemented for it then use that method
      // otherwise delegate to an interceptor
      it = pointcuts.iterator();
      while (it.hasNext())
      {
         InterfaceIntroduction pointcut = it.next();
         String[] interfaces = pointcut.getInterfaces();
         if (interfaces == null) continue;
         for (int i = 0; i < interfaces.length; i++)
         {
            addIntroductionPointcutInterface(clazz, advisor, interfaces[i], baseMethods);
         }
View Full Code Here

    */
   public void removeInterfaceIntroduction(String name)
   {
      synchronized (interfaceIntroductions)
      {
         InterfaceIntroduction pointcut = interfaceIntroductions.remove(name);
         if (pointcut == null) return;
         pointcut.clearAdvisors();
      }
   }
View Full Code Here

            if (!intf.equals("")) interfaces.add(intf);
         }
         ifaces = interfaces.toArray(new String[interfaces.size()]);
      }

      InterfaceIntroduction pcut = null;
      if (classExpr != null)
      {
         pcut = new InterfaceIntroduction(name, classExpr, ifaces);
      }
      else
      {
         ASTStart start = new TypeExpressionParser(new StringReader(ast)).Start();
         pcut = new InterfaceIntroduction(name, start, ifaces);
      }
      Iterator<Element> it = XmlHelper.getChildrenByTagName(pointcut, "mixin");
      while (it.hasNext())
      {
         Element mixin = it.next();
         if (mixin != null)
         {
            String construction = XmlHelper.getOptionalChildContent(mixin, "construction");
            String classname = XmlHelper.getUniqueChildContent(mixin, "class");
            String isTransientString = mixin.getAttribute("transient");
            boolean isTransient = true;
            if (isTransientString == null || isTransientString.trim().equals(""))
            {
               isTransient = true;
            }
            else
            {
               isTransient = new Boolean(isTransientString).booleanValue();
            }

            intfs = XmlHelper.getUniqueChildContent(mixin, "interfaces");
            StringTokenizer tokenizer = new StringTokenizer(intfs, ",");
            ArrayList<String> interfaces = new ArrayList<String>();
            while (tokenizer.hasMoreTokens())
            {
               String intf = tokenizer.nextToken().trim();
               if (!intf.equals("")) interfaces.add(intf);
            }
            ifaces = interfaces.toArray(new String[interfaces.size()]);
            pcut.getMixins().add(new InterfaceIntroduction.Mixin(classname, ifaces, construction, isTransient));
         }
      }
      manager.addInterfaceIntroduction(pcut);
   }
View Full Code Here

         mv = binfo.getMemberValue("isTransient");
         boolean isTransient = (mv != null) ? ((BooleanMemberValue) mv).getValue() : true;//Note! this should be the same as the default in @Mixin

         String name = cf.getName() + "." + minfo.getName(); //Name of the method defined on
        
         InterfaceIntroduction intro = null;
         String construction = name;
         switch(Descriptor.numOfParameters(minfo.getDescriptor()))
         {
            case 0:
               construction += "()";
               intro = createIntroduction(name, target, typeExpression, null, null, null);//cf.getName(), minfo.getName());
               break;
            case 1:
               construction += "(this)";
               intro = createIntroduction(name, target, typeExpression, null, cf.getName(), minfo.getName());              
 
               String parameter = Descriptor.getParamDescriptor(minfo.getDescriptor());
              
               if (parameter.charAt(1) != 'L')
               {
                  String errorMessage = "Mixin creator method '" + name +
                  "' parameter is primitive type ";
                  char desc = parameter.charAt(1);
                  if (desc == ((CtPrimitiveType) CtClass.booleanType).getDescriptor())
                  {
                     errorMessage += "boolean";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.byteType).getDescriptor())
                  {
                     errorMessage += "byte";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.charType).getDescriptor())
                  {
                     errorMessage += "char";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.doubleType).getDescriptor())
                  {
                     errorMessage += "double";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.floatType).getDescriptor())
                  {
                     errorMessage += "float";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.intType).getDescriptor())
                  {
                     errorMessage += "int";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.longType).getDescriptor())
                  {
                     errorMessage += "long";
                  }
                  else if (desc == ((CtPrimitiveType) CtClass.shortType).getDescriptor())
                  {
                     errorMessage += "short";
                  }
                  else
                  {
                     break;
                  }
                  errorMessage += ".\n   It should have the introduction target type as parameter, or have no parameter at all.";
                  throw new RuntimeException(errorMessage);

               }
               break;
            default:
               throw new RuntimeException("Mixin creator method '" + name +
                     "' should not have more than one parameter.");
         }
        
         if (!Modifier.isStatic(minfo.getAccessFlags()) ||
               !Modifier.isPublic(minfo.getAccessFlags()))
         {
            throw new RuntimeException("Mixin creator method '" + name +
                  "' must be public and static.");
         }
        
         //Parse the descriptor to get the returntype of the method.
         String classname = getReturnType(minfo);
        
         intro.getMixins().add(new InterfaceIntroduction.Mixin(classname, interfaces, construction, isTransient));

         manager.addInterfaceIntroduction(intro);
      }
   }
View Full Code Here

         String[] interfaces = new String[values.length];
         for (int i = 0; i < values.length; i++) interfaces[i] = ((ClassMemberValue) values[i]).getValue();

         String name = cf.getName() + "." + finfo.getName(); //Name of the field defined on

         InterfaceIntroduction interfaceIntro = createIntroduction(name, target, typeExpression, interfaces, null, null);
         manager.addInterfaceIntroduction(interfaceIntro);
      }
   }
View Full Code Here

      {
         throw new RuntimeException("You cannot define both a target and typeExpression attribute in the same @Mixin");
      }


      InterfaceIntroduction intro = null;

      if (target != null)
      {
         intro = new InterfaceIntroduction(name, target, interfaces, constructorClass, constructorMethod);
      }
      else
      {
         ASTStart start = new TypeExpressionParser(new StringReader(typeExpression)).Start();
         intro = new InterfaceIntroduction(name, start, interfaces, constructorClass, constructorMethod);
      }

      return intro;
   }
View Full Code Here

    */
   public void removeInterfaceIntroduction(String name)
   {
      synchronized (interfaceIntroductions)
      {
         InterfaceIntroduction pointcut = interfaceIntroductions.remove(name);
         if (pointcut == null) return;
         pointcut.clearAdvisors();
      }
   }
View Full Code Here

      Iterator<InterfaceIntroduction> it = pointcuts.iterator();
      if (it.hasNext()) setupBasics(clazz);
      while (it.hasNext())
      {

         InterfaceIntroduction pointcut = it.next();
         ArrayList<InterfaceIntroduction.Mixin> mixins = pointcut.getMixins();
         for (InterfaceIntroduction.Mixin mixin: mixins)
         {
            addMixin(clazz, pointcut, mixin, baseMethods);
         }
      }

      // pointcut interfaces.  If a method is already implemented for it then use that method
      // otherwise delegate to an interceptor
      it = pointcuts.iterator();
      while (it.hasNext())
      {
         InterfaceIntroduction pointcut = it.next();
         String[] interfaces = pointcut.getInterfaces();
         if (interfaces == null) continue;
         for (int i = 0; i < interfaces.length; i++)
         {
            addIntroductionPointcutInterface(clazz, advisor, interfaces[i], baseMethods);
         }
View Full Code Here

         if (mixins != null)
         {
            HashMap<String, Integer> mixinIntfs = new HashMap<String, Integer>();
            for (int i = 0; i < mixins.size(); i++)
            {
               InterfaceIntroduction introduction = mixins.get(i);
               getIntroductionInterfaces(introduction, intfs, mixinIntfs, mixes, i);
            }
            if (mixes.size() > 0)
            {
               defaultCtor.insertAfter("mixins = new Object[" + mixes.size() + "];");
View Full Code Here

TOP

Related Classes of org.jboss.aop.introduction.InterfaceIntroduction

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.