Package org.jboss.aop.advice

Examples of org.jboss.aop.advice.AdviceBinding


   /**
    * Tests the annotation of an aspect factory as @Aspect.
    */
   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);

      PreparedPOJO pojo = new PreparedPOJO();
      pojo.someMethod();
      assertTrue(AnnotatedAspectFactory.isAspectCreated());
      assertTrue(AnnotatedAspectFactory.getAspectCreated().isAdvised());
      AspectManager.instance().removeBinding(binding.getName());
   }
View Full Code Here


   /**
    * Tests the annotation of an aspect factory as @Aspect.
    */
   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);

      PreparedPOJO pojo = new PreparedPOJO();
      pojo.someMethod();
      assertTrue(AnnotatedAspectFactory.isAspectCreated());
      assertTrue(AnnotatedAspectFactory.getAspectCreated().isAdvised());
      AspectManager.instance().removeBinding(binding.getName());
   }
View Full Code Here

   public synchronized void removeBinding(String name)
   {
      lock.lockWrite();
      try
      {
         AdviceBinding binding = internalRemoveBinding(name);
         if (binding != null)
         {
            binding.clearAdvisors();
            dynamicStrategy.interceptorChainsUpdated();
         }
      }
      finally
      {
View Full Code Here

    * Add an interceptor pointcut with a given name
    */
   public void addBinding(AdviceBinding binding)
   {
      Set<Advisor> affectedAdvisors = null;
      AdviceBinding removedBinding = null;
      // this locked variable is used in order to avoid breaking the try finally block in two pieces
      boolean locked = false;
      try
      {
         // EXTREMELY IMPORTANT: get this' lock before the bindingCollection's, or
         // we will end up with a deadlock
         synchronized(this)
         {
            lock.lockWrite();
            locked = true;
            removedBinding = internalRemoveBinding(binding.getName());
            affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());        
            bindingCollection.add(binding, this);
         }
         synchronized (advisors)
         {
            Set<Advisor> handledAdvisors = new HashSet<Advisor>();
View Full Code Here

    * Removes an AdviceBinding without notifying dynamic aop strategy.
    * @param name the binding to be removed.
    */
   private synchronized AdviceBinding internalRemoveBinding(String name)
   {
      AdviceBinding binding = bindingCollection.removeBinding(name);
      if (binding == null)
      {
         return null;
      }
      Pointcut pointcut = binding.getPointcut();
      this.removePointcut(pointcut.getName());
      return binding;
   }
View Full Code Here

   public void removeBinding(String name)
   {
      lock.lockWrite();
      try
      {
         AdviceBinding binding = internalRemoveBinding(name);
         if (binding != null)
         {
            binding.clearAdvisors();
            dynamicStrategy.interceptorChainsUpdated();
         }
      }
      finally
      {
View Full Code Here

    * Add an interceptor pointcut with a given name
    */
   public void addBinding(AdviceBinding binding)
   {
      Set<Advisor> affectedAdvisors = null;
      AdviceBinding removedBinding = null;
      lock.lockWrite();
      try
      {
         removedBinding = internalRemoveBinding(binding.getName());
         affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());        
         bindingCollection.add(binding, this);
         synchronized (advisors)
         {
            Set<Advisor> handledAdvisors = new HashSet<Advisor>();
            updateAdvisorsForAddedBinding(binding, handledAdvisors);
View Full Code Here

    *
    * @param name the binding to be removed.
    */
   private AdviceBinding internalRemoveBinding(String name)
   {
      AdviceBinding binding = bindingCollection.removeBinding(name);
      if (binding == null)
      {
         return null;
      }
      Pointcut pointcut = binding.getPointcut();
      this.removePointcut(pointcut.getName());
      return binding;
   }
View Full Code Here

   {
      ArrayList unbounded = new ArrayList();
      Iterator it = AspectManager.instance().getBindings().values().iterator();
      while (it.hasNext())
      {
         AdviceBinding binding = (AdviceBinding) it.next();
         if (!binding.hasAdvisors())
         {
            unbounded.add(createTreeNode(
                    binding.getName(),
                    "Unbounded Binding",
                    "images/service.gif", // Icon URL
                    "AOPBinding.jsp?binding=" + java.net.URLEncoder.encode(binding.getName()),
                    null, // menu
                    null, // sub nodes
                    null   // Sub-Resources
            ));
         }
View Full Code Here

   /**
    * Tests the annotation of an aspect factory as @Aspect.
    */
   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);

      PreparedPOJO pojo = new PreparedPOJO();
      pojo.someMethod();
      assertTrue(AnnotatedAspectFactory.isAspectCreated());
      assertTrue(AnnotatedAspectFactory.getAspectCreated().isAdvised());
      AspectManager.instance().removeBinding(binding.getName());
   }
View Full Code Here

TOP

Related Classes of org.jboss.aop.advice.AdviceBinding

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.