Author: chris.laprun(a)jboss.com
Date: 2009-04-28 12:15:46 -0400 (Tue, 28 Apr 2009)
New Revision: 13279
Modified:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStackFactory.java
branches/JBoss_Portal_Branch_2_7/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorStackFactory.java
Log:
- JBPORTAL-2381: Insert dynamic interceptors in n-1 position in the stack.
Modified:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStackFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStackFactory.java 2009-04-28
09:10:50 UTC (rev 13278)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStackFactory.java 2009-04-28
16:15:46 UTC (rev 13279)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -42,7 +42,7 @@
/** . */
protected List<ObjectName> dynamicInterceptorNames;
-
+
/** . */
protected PortletInterceptorStack stack;
@@ -100,37 +100,44 @@
List<ObjectName> names = new ArrayList<ObjectName>();
//
- if (interceptorNames != null)
+ if (interceptorNames != null && !interceptorNames.isEmpty())
{
names.addAll(interceptorNames);
}
- //
- names.addAll(dynamicInterceptorNames);
+ int size = names.size();
+ if (dynamicInterceptorNames != null && !dynamicInterceptorNames.isEmpty())
+ {
+ // insert dynamic interceptors in N - 1 position as last static interceptor
terminates the stack
+ ObjectName last = names.remove(size - 1);
+ names.addAll(dynamicInterceptorNames);
+ names.add(last);
+ size = names.size();
+ }
//
log.debug("Building interceptor stack " + getName());
- PortletInvokerInterceptor[] interceptors = new
PortletInvokerInterceptor[names.size()];
- if (names.size() == 1)
+ PortletInvokerInterceptor[] interceptors = new PortletInvokerInterceptor[size];
+ if (size == 1)
{
ObjectName name = names.get(0);
log.debug("Adding interceptor " + name + " to the stack");
PortletInvokerInterceptor a =
(PortletInvokerInterceptor)server.getAttribute(name, "ManagedResource");
interceptors[0] = a;
}
- for (int i = 0; i < names.size()-1; i++)
+ for (int i = 0; i < size - 1; i++)
{
ObjectName name = names.get(i);
log.debug("Adding interceptor " + name + " to the stack");
PortletInvokerInterceptor a =
(PortletInvokerInterceptor)server.getAttribute(name, "ManagedResource");
- name = names.get(i+1);
+ name = names.get(i + 1);
log.debug("Adding interceptor " + name + " to the stack");
PortletInvokerInterceptor b =
(PortletInvokerInterceptor)server.getAttribute(name, "ManagedResource");
a.setNext(b);
interceptors[i] = a;
- interceptors[i+1] = b;
+ interceptors[i + 1] = b;
}
-
+
//
stack = new JBossPortletInterceptorStack(interceptors);
Modified:
branches/JBoss_Portal_Branch_2_7/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorStackFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorStackFactory.java 2009-04-28
09:10:50 UTC (rev 13278)
+++
branches/JBoss_Portal_Branch_2_7/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorStackFactory.java 2009-04-28
16:15:46 UTC (rev 13279)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -40,10 +40,10 @@
{
/** . */
- protected List interceptorNames;
+ protected List<ObjectName> interceptorNames;
/** . */
- protected List dynamicInterceptorNames;
+ protected List<ObjectName> dynamicInterceptorNames;
/** . */
protected InterceptorStack stack;
@@ -52,7 +52,7 @@
public JBossInterceptorStackFactory()
{
interceptorNames = null;
- dynamicInterceptorNames = new ArrayList();
+ dynamicInterceptorNames = new ArrayList<ObjectName>();
stack = JBossInterceptorStack.EMPTY_STACK;
}
@@ -106,23 +106,30 @@
/** Rebuild the interceptor stack. */
public void rebuild() throws Exception
{
- List names = new ArrayList();
+ List<ObjectName> names = new ArrayList<ObjectName>();
//
- if (interceptorNames != null)
+ if (interceptorNames != null && !interceptorNames.isEmpty())
{
names.addAll(interceptorNames);
}
- //
- names.addAll(dynamicInterceptorNames);
+ int size = names.size();
+ if (dynamicInterceptorNames != null && !dynamicInterceptorNames.isEmpty())
+ {
+ // insert dynamic interceptors in N - 1 position as last static interceptor
terminates the stack
+ ObjectName last = names.remove(size - 1);
+ names.addAll(dynamicInterceptorNames);
+ names.add(last);
+ size = names.size();
+ }
//
log.debug("Building interceptor stack " + getName());
Interceptor[] interceptors = new Interceptor[names.size()];
for (int i = 0; i < names.size(); i++)
{
- ObjectName name = (ObjectName)names.get(i);
+ ObjectName name = names.get(i);
log.debug("Adding interceptor " + name + " to the stack");
interceptors[i] = (Interceptor)server.getAttribute(name,
"ManagedResource");
}
Show replies by date