Author: julien(a)jboss.com
Date: 2007-01-17 15:54:46 -0500 (Wed, 17 Jan 2007)
New Revision: 6021
Added:
trunk/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorRegistration.java
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FolderGetListCommand.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
- added JBossInterceptorRegistration which allows the registration of interceptor
dynamically on an interceptor stack
- add/remove the cms user interceptor binding at runtime using the new interceptor
registration service
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FolderGetListCommand.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FolderGetListCommand.java 2007-01-17
18:37:31 UTC (rev 6020)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/FolderGetListCommand.java 2007-01-17
20:54:46 UTC (rev 6021)
@@ -78,13 +78,14 @@
{
Node node = ni.nextNode();
NodeType nt = node.getPrimaryNodeType();
- if (nt.getName().equals("portalcms:folder"))
+ String ntName = nt.getName();
+ if (ntName.equals("portalcms:folder"))
{
JCRCommand folderList =
(JCRCommand)context.getCommandFactory().createFolderGetCommand(node.getPath());
Folder childFolder = (Folder)context.execute(folderList);
folders.add(childFolder);
}
- else if (nt.getName().equals("portalcms:file"))
+ else if (ntName.equals("portalcms:file"))
{
//JCRCommand fileList = (JCRCommand)
context.getCommandFactory().createFileGetMetaDataCommand(node.getPath(), null);
//File childFile = (File) context.execute(fileList);
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-01-17
18:37:31 UTC (rev 6020)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-01-17
20:54:46 UTC (rev 6021)
@@ -604,4 +604,25 @@
<attribute
name="UseRegionBasedMarshalling">false</attribute>
</mbean-->
+
+ <mbean
+ code="org.jboss.portal.core.cms.aspect.IdentityBindingInterceptor"
+ name="portal:service=Interceptor,type=Server,name=CMSIdentityBinding"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <mbean
+
code="org.jboss.portal.server.impl.invocation.JBossInterceptorRegistration"
+
name="portal:service=InterceptorRegistration,type=Server,name=CMSIdentityBinding"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+
optional-attribute-name="InterceptorName">portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends
+
optional-attribute-name="StackFactory">portal:service=InterceptorStackFactory,type=Server</depends>
+ </mbean>
+
</server>
Added:
trunk/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorRegistration.java
===================================================================
---
trunk/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorRegistration.java
(rev 0)
+++
trunk/server/src/main/org/jboss/portal/server/impl/invocation/JBossInterceptorRegistration.java 2007-01-17
20:54:46 UTC (rev 6021)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * 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.server.impl.invocation;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import javax.management.ObjectName;
+
+/**
+ * Register an interceptor on a stack factory. The main usage is for dynamic registration
of an interceptor
+ * when the interceptor cannot be specified in the stack factory dependencies.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossInterceptorRegistration extends AbstractJBossService
+{
+
+ /** . */
+ private ObjectName interceptorName;
+
+ /** . */
+ private ObjectName stackFactory;
+
+ public ObjectName getInterceptorName()
+ {
+ return interceptorName;
+ }
+
+ public void setInterceptorName(ObjectName interceptorName)
+ {
+ this.interceptorName = interceptorName;
+ }
+
+ public ObjectName getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public void setStackFactory(ObjectName stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ protected void startService() throws Exception
+ {
+ try
+ {
+ server.invoke(
+ stackFactory,
+ "addInterceptor",
+ new Object[]{interceptorName},
+ new String[]{ObjectName.class.getName()});
+ }
+ finally
+ {
+ rebuildStackFactory();
+ }
+ }
+
+ protected void stopService() throws Exception
+ {
+ try
+ {
+ server.invoke(
+ stackFactory,
+ "removeInterceptor",
+ new Object[]{interceptorName},
+ new String[]{ObjectName.class.getName()});
+ }
+ finally
+ {
+ rebuildStackFactory();
+ }
+ }
+
+ private void rebuildStackFactory()
+ {
+ try
+ {
+ server.invoke(
+ stackFactory,
+ "rebuild",
+ new Object[0],
+ new String[0]);
+ }
+ catch (Exception e)
+ {
+ log.warn("Exception during rebuild of stack factory", e);
+ }
+ }
+}
+