* @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;