Examples of AspectDefinition


Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

     * @param definition the AspectWerkz definition
     */
    private static void handleAspectDefinitions(final Element root,
                                                final AspectWerkzDefinition definition) {
        for (Iterator it = definition.getAspectDefinitions().iterator(); it.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition)it.next();

            Element aspectElement = root.addElement("aspect");
            aspectElement.addAttribute("name", aspectDef.getName());

            handlePointcutDefinitions(aspectElement, aspectDef);
            handleControllerDefinitions(aspectElement, aspectDef);
            handleIntroductionWeavingRules(aspectElement, aspectDef);
            handleAdviceWeavingRules(aspectElement, aspectDef);
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

    private static void parseIntroductionAttributes(
            final AspectWerkzDefinition definition,
            final String className,
            final QDoxParser qdoxParser) {

        AspectDefinition aspectDefinition = definition.getAspectDefinition(
                AspectWerkzDefinition.SYSTEM_ASPECT);

        JavaClass javaClass = qdoxParser.getJavaClass();
        DocletTag[] introductionTags = javaClass.getTagsByName(AttributeTag.INTRODUCTION);

        IntroductionWeavingRule weavingRule = new IntroductionWeavingRule();
        weavingRule.setClassPattern(className);

        for (int i = 0; i < introductionTags.length; i++) {
            if (introductionTags[i] == null) {
                continue;
            }
            String[] attributes = introductionTags[i].getParameters();
            for (int j = 0; j < attributes.length; j++) {
                final String introductionRef = definition.
                        getIntroductionNameByAttribute(attributes[j]);
                if (introductionRef == null) {
                    continue;
                }
                weavingRule.addIntroductionRef(introductionRef);
            }
            aspectDefinition.addIntroductionWeavingRule(weavingRule);
        }
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.xmldef.definition.AspectDefinition

    public void testAspectTag() {
        try {
            AspectWerkzDefinition aspectwerkz = (AspectWerkzDefinition)XmlParser.parseNoCache(m_input.toURL()).get(0);
            Iterator it1 = aspectwerkz.getAspectDefinitions().iterator();
            it1.next();// SystemAspect @todo check this with Jonas (side effect of precedence fix)
            AspectDefinition aspect = (AspectDefinition)it1.next();
            assertEquals("Logger", aspect.getName());
            assertEquals("Service", aspect.getExtends());
            assertEquals("services.*", ((BindIntroductionRule)aspect.getBindIntroductionRules().get(0)).getExpression().getExpression());
            assertEquals("loggable", (String)((BindIntroductionRule)aspect.getBindIntroductionRules().get(0)).getIntroductionRefs().get(0));
            assertEquals("services.*", ((BindIntroductionRule)aspect.getBindIntroductionRules().get(1)).getExpression().getExpression());
            assertEquals("loggable", (String)((BindIntroductionRule)aspect.getBindIntroductionRules().get(1)).getIntroductionRefs().get(0));
            assertEquals("start && stop", ((BindAdviceRule)aspect.getBindAdviceRules().get(0)).getExpression().getExpression());
            assertEquals("logging", (String)((BindAdviceRule)aspect.getBindAdviceRules().get(0)).getAdviceRefs().get(0));
            assertEquals("start || stop", ((BindAdviceRule)aspect.getBindAdviceRules().get(1)).getExpression().getExpression());
            assertEquals("logging", (String)((BindAdviceRule)aspect.getBindAdviceRules().get(1)).getAdviceRefs().get(0));
        }
        catch (Exception e) {
            System.out.println(e);
            fail();
        }
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

    */
   public void testAspectFactory() throws Exception
   {
      AdviceBinding binding = new AdviceBinding(
            "execution(void *PreparedPOJO->someMethod(..))", null);
      AspectDefinition aspectDefinition = AspectManager.instance()
            .getAspectDefinition(AnnotatedAspectFactory.class.getName());
      assertNotNull(aspectDefinition);
      binding.addInterceptorFactory(new AdviceFactory(aspectDefinition,
            "advice"));
      AspectManager.instance().addBinding(binding);
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

    */
   public void testAspectFactory() throws Exception
   {
      AdviceBinding binding = new AdviceBinding(
            "execution(void *PreparedPOJO->someMethod(..))", null);
      AspectDefinition aspectDefinition = AspectManager.instance()
            .getAspectDefinition(AnnotatedAspectFactory.class.getName());
      assertNotNull(aspectDefinition);
      binding.addInterceptorFactory(new AdviceFactory(aspectDefinition,
            "advice"));
      AspectManager.instance().addBinding(binding);
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

   public Object getPerVMAspect(String def)
   {
      Object aspect = perVMAspects.get(def);
      if (aspect == null)
      {
         AspectDefinition adef = aspectDefinitions.get(def);
         if (adef != null && adef.getScope() == Scope.PER_VM)
         {
            synchronized (adef)
            {
               // double check but, now, in a sync block
               aspect = perVMAspects.get(def);
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

      internalRemoveAspectDefintion(name);
   }

   protected AspectDefinition internalRemoveAspectDefintion(String name)
   {
      AspectDefinition def = aspectDefinitions.remove(name);
      if (def != null)
      {
         def.undeploy();
         if (def.getScope() == Scope.PER_VM) perVMAspects.remove(def.getName());
      }
      return def;
   }
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

      String beanClassName = beanClass.getName();
      String ejbName = beanClass.getSimpleName();
      Domain domain = new Domain(new AspectManager(), "Test", false);

      GenericAspectFactory aspectFactory = new GenericAspectFactory(CurrentInvocationInterceptor.class.getName(), null);
      AspectDefinition def = new AspectDefinition("CurrentInvocationInterceptor", Scope.PER_VM, aspectFactory);
      domain.addAspectDefinition(def);
      AdviceFactory factory = new AdviceFactory(def, "invoke");
      GenericAspectFactory aspectFactory2 = new GenericAspectFactory(CurrentInvocationContextInterceptor.class.getName(), null);
      AspectDefinition def2 = new AspectDefinition("CurrentInvocationContextInterceptor", Scope.PER_VM, aspectFactory2);
      domain.addAspectDefinition(def2);
      AdviceFactory factory2 = new AdviceFactory(def2, "invoke");
      AdviceStack stack = new AdviceStack("InjectionCallbackStack", new ArrayList<InterceptorFactory>(Arrays.asList(factory, factory2)));
      domain.addAdviceStack(stack);
     
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

   public Object getPerVMAspect(String def)
   {
      Object aspect = perVMAspects.get(def);
      if (aspect == null)
      {
         AspectDefinition adef = aspectDefinitions.get(def);
         if (adef != null && adef.getScope() == Scope.PER_VM)
         {
            synchronized (adef)
            {
               // double check but, now, in a sync block
               aspect = perVMAspects.get(def);
View Full Code Here

Examples of org.jboss.aop.advice.AspectDefinition

      internalRemoveAspectDefintion(name);
   }

   protected AspectDefinition internalRemoveAspectDefintion(String name)
   {
      AspectDefinition def = aspectDefinitions.remove(name);
      if (def != null)
      {
         def.undeploy();
         if (def.getScope() == Scope.PER_VM) perVMAspects.remove(def.getName());
      }
      return def;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.