Author: thomas.heute(a)jboss.com
Date: 2008-06-30 10:08:18 -0400 (Mon, 30 Jun 2008)
New Revision: 11207
Added:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/EmptyPortletInterceptorStackFactory.java
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStack.java
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/PortletInterceptorStack.java
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStackFactory.java
Log:
Command line rocks
Added:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/EmptyPortletInterceptorStackFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/EmptyPortletInterceptorStackFactory.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/EmptyPortletInterceptorStackFactory.java 2008-06-30
14:08:18 UTC (rev 11207)
@@ -0,0 +1,37 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.portlet.impl.invocation;
+
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class EmptyPortletInterceptorStackFactory implements
PortletInterceptorStackFactory
+{
+ public PortletInterceptorStack getInterceptorStack()
+ {
+ return JBossPortletInterceptorStack.EMPTY_STACK;
+ }
+}
+
Added:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStack.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStack.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStack.java 2008-06-30
14:08:18 UTC (rev 11207)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.invocation;
+
+import org.jboss.portal.portlet.PortletInvokerInterceptor;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JBossPortletInterceptorStack implements PortletInterceptorStack
+{
+
+ /** . */
+ public static final PortletInterceptorStack EMPTY_STACK = new
JBossPortletInterceptorStack(new PortletInvokerInterceptor[0]);
+
+ /** . */
+ private final PortletInvokerInterceptor[] interceptors;
+
+ public JBossPortletInterceptorStack(PortletInvokerInterceptor interceptor)
+ {
+ this.interceptors = new PortletInvokerInterceptor[]{interceptor};
+ }
+
+ public JBossPortletInterceptorStack(PortletInvokerInterceptor[] interceptors)
+ {
+ if (interceptors == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.interceptors = interceptors;
+ }
+
+ public int getLength()
+ {
+ return interceptors.length;
+ }
+
+ public PortletInvokerInterceptor getInterceptor(int index) throws
ArrayIndexOutOfBoundsException
+ {
+ return interceptors[index];
+ }
+}
+
Added:
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
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/JBossPortletInterceptorStackFactory.java 2008-06-30
14:08:18 UTC (rev 11207)
@@ -0,0 +1,148 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.invocation;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.portlet.PortletInvokerInterceptor;
+
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JBossPortletInterceptorStackFactory extends AbstractJBossService implements
PortletInterceptorStackFactory
+{
+
+ /** . */
+ protected List<ObjectName> interceptorNames;
+
+ /** . */
+ protected List<ObjectName> dynamicInterceptorNames;
+
+ /** . */
+ protected PortletInterceptorStack stack;
+
+ public JBossPortletInterceptorStackFactory()
+ {
+ interceptorNames = null;
+ dynamicInterceptorNames = new ArrayList<ObjectName>();
+ }
+
+ public List<ObjectName> getInterceptorNames()
+ {
+ return interceptorNames;
+ }
+
+ public void setInterceptorNames(List<ObjectName> interceptorNames)
+ {
+ this.interceptorNames = interceptorNames;
+ }
+
+ public List<ObjectName> getDynamicInterceptorNames()
+ {
+ return Collections.unmodifiableList(dynamicInterceptorNames);
+ }
+
+ /**
+ * Add's the supplied name to the list of interceptor names.
+ *
+ * @param name the intercptor's ObjectName.
+ * @throws Exception
+ */
+ public void addInterceptor(ObjectName name) throws Exception
+ {
+ dynamicInterceptorNames.add(name);
+ }
+
+ /**
+ * Remove's the supplied name from the list of interceptor names.
+ *
+ * @param name the intercptor's ObjectName.
+ * @throws Exception
+ */
+ public void removeInterceptor(ObjectName name) throws Exception
+ {
+ dynamicInterceptorNames.remove(name);
+ }
+
+ public void startService() throws Exception
+ {
+ rebuild();
+ }
+
+ /** Rebuild the interceptor stack. */
+ public void rebuild() throws Exception
+ {
+ List<ObjectName> names = new ArrayList<ObjectName>();
+
+ //
+ if (interceptorNames != null)
+ {
+ names.addAll(interceptorNames);
+ }
+
+ //
+ names.addAll(dynamicInterceptorNames);
+
+ //
+ log.debug("Building interceptor stack " + getName());
+ PortletInvokerInterceptor[] interceptors = new
PortletInvokerInterceptor[names.size()];
+ if (names.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++)
+ {
+ 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);
+ 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;
+ }
+
+ //
+ stack = new JBossPortletInterceptorStack(interceptors);
+
+ }
+
+ public void stopService()
+ {
+ this.stack = JBossPortletInterceptorStack.EMPTY_STACK;
+ }
+
+ public PortletInterceptorStack getInterceptorStack()
+ {
+ return stack;
+ }
+}
Added:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStack.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStack.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStack.java 2008-06-30
14:08:18 UTC (rev 11207)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.invocation;
+
+import org.jboss.portal.portlet.PortletInvokerInterceptor;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface PortletInterceptorStack
+{
+ /**
+ * Returns the stack length.
+ *
+ * @return the length
+ */
+ int getLength();
+
+ /**
+ * Return the interceptor at the specified index.
+ *
+ * @param index the interceptor index in the stack
+ * @return the specified interceptor
+ * @throws ArrayIndexOutOfBoundsException if the index is not valid
+ */
+ PortletInvokerInterceptor getInterceptor(int index) throws
ArrayIndexOutOfBoundsException;
+}
+
Added:
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStackFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStackFactory.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/portlet-server/src/main/org/jboss/portal/portlet/impl/invocation/PortletInterceptorStackFactory.java 2008-06-30
14:08:18 UTC (rev 11207)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.invocation;
+
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface PortletInterceptorStackFactory
+{
+ PortletInterceptorStack getInterceptorStack();
+
+}
+