Package org.jboss.aop.introduction

Examples of org.jboss.aop.introduction.InterfaceIntroduction$Mixin


   public void testContainerProxy() throws Exception
   {
      InstanceDomain domain = new InstanceDomain(AspectManager.instance(), "blah", false);

     
      InterfaceIntroduction intro = new InterfaceIntroduction("intro", "*", null);
      String[] intfs = {MixinInterface.class.getName()};
      InterfaceIntroduction.Mixin mixin = new InterfaceIntroduction.Mixin(Mixin.class.getName(), intfs, null, false);
      intro.getMixins().add(mixin);
      domain.addInterfaceIntroduction(intro);

     
      AspectDefinition def = new AspectDefinition("aspect", Scope.PER_VM, new GenericAspectFactory(EchoInterceptor.class.getName(), null));
      domain.addAspectDefinition(def);
View Full Code Here


         params.setContainerCache(null);
         POJO instanceAnnotationWithBindings = (POJO)factory.createAdvisedProxy(params);
         assertFalse(instanceAnnotationWithBindings instanceof AspectManaged);
         assertTrue(TestInterceptor.invoked);

         InterfaceIntroduction intro = new InterfaceIntroduction("intro", "@" + SomeAnnotation.class.getName(), new String[] {SomeInterface.class.getName()});
         manager.addInterfaceIntroduction(intro);
         params.setMetaData(someAnnMD);
         params.setContainerCache(null);
         POJO introduced = (POJO)factory.createAdvisedProxy(params);
         assertTrue(introduced instanceof AspectManaged);
View Full Code Here

   }
  
   public void testProxyWithOnlyIntroductions() throws Exception
   {
      AspectManager manager = AspectManager.instance();
      InterfaceIntroduction intro = new InterfaceIntroduction("intro", POJOWithIntroduction.class.getName(), new String[] {Serializable.class.getName()});
      try
      {
         manager.addInterfaceIntroduction(intro);
        
         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
         params.setTarget(new POJOWithIntroduction());
        
         GeneratedAOPProxyFactory factory = new GeneratedAOPProxyFactory();
         POJOWithIntroduction pojo = (POJOWithIntroduction)factory.createAdvisedProxy(params);
         assertTrue(pojo instanceof AspectManaged);
        
         assertInstanceOf(pojo, Serializable.class);
      }
      finally
      {
         manager.removeInterfaceIntroduction(intro.getName());
      }
   }
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

         indenter(pw, indent);
         pw.println("<introductions>");
         indent++;
         for (int i = 0; i < introductions.size(); i++)
         {
            InterfaceIntroduction pointcut = introductions.get(i);
            indenter(pw, indent);
            pw.println("<introduction classExpr=\"" + pointcut.getClassExpr() + "\">");
            indent++;
            String[] intfs = pointcut.getInterfaces();
            ArrayList<InterfaceIntroduction.Mixin> mixins = pointcut.getMixins();

            if (intfs != null && intfs.length > 0)
            {
               //Show interfaces
               for (int j = 0; j < intfs.length; j++)
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

      loader.getAspectManager().removeCFlowStack(name);
   }
  
   public void deployInterfaceIntroduction(AspectAnnotationLoader loader, AspectAnnotationLoaderStrategy.InterfaceIntroductionInfo introduction) throws Exception
   {
      InterfaceIntroduction intro = null;
      if (introduction.getTarget() != null)
      {
         intro = new InterfaceIntroduction(introduction.getName(), introduction.getTarget(), introduction.getInterfaces(), introduction.getConstructorClass(), introduction.getConstructorMethod());
      }
      else
      {
         ASTStart start = new TypeExpressionParser(new StringReader(introduction.getExpr())).Start();
         intro = new InterfaceIntroduction(introduction.getName(), start, introduction.getInterfaces(), introduction.getConstructorClass(), introduction.getConstructorMethod());
      }

      if (introduction.getMixins() != null)
      {
         for (AspectAnnotationLoaderStrategy.InterfaceIntroductionMixinInfo mixin : introduction.getMixins())
         {
            intro.getMixins().add(new InterfaceIntroduction.Mixin(mixin.getClassname(), mixin.getInterfaces(), mixin.getConstruction(), mixin.isTrans()));
         }
      }
     
      loader.getAspectManager().addInterfaceIntroduction(intro);
   }
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

            }
         }

         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

            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

TOP

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

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.