Package org.exoplatform.container.spi

Examples of org.exoplatform.container.spi.Interceptor


            if (chain == null)
            {
               List<Interceptor> staticInts = getStaticInterceptors(holder, parent);
               List<Interceptor> dynamicInts = getDynamicInterceptors(holder, parent);
               List<Interceptor> interceptors = resolve(staticInts, dynamicInts);
               Interceptor result = null;
               List<Class<? extends Interceptor>> chain = new LinkedList<Class<? extends Interceptor>>();
               StringBuilder sb = null;
               boolean isDevelopping = PropertyManager.isDevelopping();
               if (isDevelopping)
               {
                  sb = new StringBuilder();
               }
               for (int i = 0, length = interceptors.size(); i < length; i++)
               {
                  Interceptor it = interceptors.get(i);
                  it.setSuccessor(result);
                  chain.add(it.getClass());
                  if (isDevelopping)
                  {
                     sb.insert(0, "-> " + it.getClass().getName() + " ");
                  }
                  result = it;
               }
               if (isDevelopping)
               {
                  System.out.println("The interceptor chain used is " + sb); //NOSONAR
               }
               this.chain = chain;
               return result;
            }
         }
      }
      Interceptor result = null;
      for (Iterator<Class<? extends Interceptor>> iter = chain.iterator(); iter.hasNext();)
      {
         Class<? extends Interceptor> iClass = iter.next();
         try
         {
            Interceptor it = iClass.cast(iClass.newInstance());
            it.setHolder(holder);
            it.setParent(parent);
            it.setSuccessor(result);
            result = it;
         }
         catch (Exception e)
         {
            System.out.println("ERROR: Cannot instantiate inteceptor of class " + iClass + ": "
View Full Code Here


   {
      List<Interceptor> list = new ArrayList<Interceptor>();
      ServiceLoader<Interceptor> loader = ServiceLoader.load(Interceptor.class);
      for (Iterator<Interceptor> it = loader.iterator(); it.hasNext();)
      {
         Interceptor interceptor = it.next();
         interceptor.setHolder(holder);
         interceptor.setParent(parent);
         list.add(interceptor);
      }
      return list;
   }
View Full Code Here

    * @param resolveIfAbsent indicates if the interceptor must be resolved if the referred interceptor could not
    * be found
    */
   protected void resolveNext(List<Interceptor> alreadyResolved, Iterator<Interceptor> iter, boolean resolveIfAbsent)
   {
      Interceptor it = iter.next();
      Before b = it.getClass().getAnnotation(Before.class);
      if (b != null)
      {
         // An annotation Before has been defined
         String id = b.value();
         if (id == null || (id = id.trim()).isEmpty())
         {
            // No id set
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: No value set for the annotation Before of the interceptor " + it.getClass()); //NOSONAR
            }
            alreadyResolved.add(it);
            iter.remove();
            return;
         }
         // The id has been set
         for (int i = 0, length = alreadyResolved.size(); i < length; i++)
         {
            Interceptor interceptor = alreadyResolved.get(i);
            if (id.equals(interceptor.getId()))
            {
               // The id has been found
               if (i < length - 1)
               {
                  alreadyResolved.add(i + 1, it);
               }
               else
               {
                  alreadyResolved.add(it);
               }
               iter.remove();
               return;
            }
         }
         if (resolveIfAbsent)
         {
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: Could not find the interceptor of " + id + " required by the interceptor "
                  + it.getClass()); //NOSONAR
            }
            alreadyResolved.add(it);
            iter.remove();
         }
         return;
      }
      After a = it.getClass().getAnnotation(After.class);
      if (a != null)
      {
         // An annotation After has been defined
         String id = a.value();
         if (id == null || (id = id.trim()).isEmpty())
         {
            // No id set
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: No value set for the annotation After of the interceptor " + it.getClass()); //NOSONAR
            }
            alreadyResolved.add(it);
            iter.remove();
            return;
         }
         // The id has been set
         for (int i = 0, length = alreadyResolved.size(); i < length; i++)
         {
            Interceptor interceptor = alreadyResolved.get(i);
            if (id.equals(interceptor.getId()))
            {
               // The id has been found
               alreadyResolved.add(i, it);
               iter.remove();
               return;
View Full Code Here

            if (chain == null)
            {
               List<Interceptor> staticInts = getStaticInterceptors(holder, parent);
               List<Interceptor> dynamicInts = getDynamicInterceptors(holder, parent);
               List<Interceptor> interceptors = resolve(staticInts, dynamicInts);
               Interceptor result = null;
               List<Class<? extends Interceptor>> chain = new LinkedList<Class<? extends Interceptor>>();
               StringBuilder sb = null;
               boolean isDevelopping = PropertyManager.isDevelopping();
               if (isDevelopping)
               {
                  sb = new StringBuilder();
               }
               for (int i = 0, length = interceptors.size(); i < length; i++)
               {
                  Interceptor it = interceptors.get(i);
                  it.setSuccessor(result);
                  chain.add(it.getClass());
                  if (isDevelopping)
                  {
                     sb.insert(0, "-> " + it.getClass().getName() + " ");
                  }
                  result = it;
               }
               if (isDevelopping)
               {
                  System.out.println("The interceptor chain used is " + sb); //NOSONAR
               }
               this.chain = chain;
               return result;
            }
         }
      }
      Interceptor result = null;
      for (Iterator<Class<? extends Interceptor>> iter = chain.iterator(); iter.hasNext();)
      {
         Class<? extends Interceptor> iClass = iter.next();
         try
         {
            Interceptor it = iClass.cast(iClass.newInstance());
            it.setHolder(holder);
            it.setParent(parent);
            it.setSuccessor(result);
            result = it;
         }
         catch (Exception e)
         {
            System.out.println("ERROR: Cannot instantiate inteceptor of class " + iClass + ": " //NOSONAR
View Full Code Here

   {
      List<Interceptor> list = new ArrayList<Interceptor>();
      ServiceLoader<Interceptor> loader = ServiceLoader.load(Interceptor.class);
      for (Iterator<Interceptor> it = loader.iterator(); it.hasNext();)
      {
         Interceptor interceptor = it.next();
         interceptor.setHolder(holder);
         interceptor.setParent(parent);
         list.add(interceptor);
      }
      return list;
   }
View Full Code Here

    * @param resolveIfAbsent indicates if the interceptor must be resolved if the referred interceptor could not
    * be found
    */
   protected void resolveNext(List<Interceptor> alreadyResolved, Iterator<Interceptor> iter, boolean resolveIfAbsent)
   {
      Interceptor it = iter.next();
      Before b = it.getClass().getAnnotation(Before.class);
      if (b != null)
      {
         // An annotation Before has been defined
         String id = b.value();
         if (id == null || (id = id.trim()).isEmpty())
         {
            // No id set
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: No value set for the annotation Before of the interceptor " + it.getClass()); //NOSONAR
            }
            alreadyResolved.add(it);
            iter.remove();
            return;
         }
         // The id has been set
         for (int i = 0, length = alreadyResolved.size(); i < length; i++)
         {
            Interceptor interceptor = alreadyResolved.get(i);
            if (id.equals(interceptor.getId()))
            {
               // The id has been found
               if (i < length - 1)
               {
                  alreadyResolved.add(i + 1, it);
               }
               else
               {
                  alreadyResolved.add(it);
               }
               iter.remove();
               return;
            }
         }
         if (resolveIfAbsent)
         {
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: Could not find the interceptor of " + id + " required by the interceptor " //NOSONAR
                  + it.getClass());
            }
            alreadyResolved.add(it);
            iter.remove();
         }
         return;
      }
      After a = it.getClass().getAnnotation(After.class);
      if (a != null)
      {
         // An annotation After has been defined
         String id = a.value();
         if (id == null || (id = id.trim()).isEmpty())
         {
            // No id set
            if (PropertyManager.isDevelopping())
            {
               System.out.println("WARN: No value set for the annotation After of the interceptor " + it.getClass()); //NOSONAR
            }
            alreadyResolved.add(it);
            iter.remove();
            return;
         }
         // The id has been set
         for (int i = 0, length = alreadyResolved.size(); i < length; i++)
         {
            Interceptor interceptor = alreadyResolved.get(i);
            if (id.equals(interceptor.getId()))
            {
               // The id has been found
               alreadyResolved.add(i, it);
               iter.remove();
               return;
View Full Code Here

TOP

Related Classes of org.exoplatform.container.spi.Interceptor

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.