Author: julien(a)jboss.com
Date: 2007-04-25 10:26:47 -0400 (Wed, 25 Apr 2007)
New Revision: 7043
Added:
trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java
Removed:
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
trunk/core/src/main/org/jboss/portal/core/event/user/
Modified:
trunk/api/src/main/org/jboss/portal/api/PortalSession.java
trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java
trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java
trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
Log:
- slight improvement to portal API
Modified: trunk/api/src/main/org/jboss/portal/api/PortalSession.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/PortalSession.java 2007-04-25 13:37:42 UTC
(rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/PortalSession.java 2007-04-25 14:26:47 UTC
(rev 7043)
@@ -38,10 +38,29 @@
*/
String getId();
- Object getAttribute(String name);
+ /**
+ * Returns a session attribute.
+ *
+ * @param name the attribute name
+ * @return the attribute value or null if it is not found
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ Object getAttribute(String name) throws IllegalArgumentException;
- void setAttribute(String name, Object attribute);
+ /**
+ * Update an attribute value. If the attribute value is null, then it is considered as
a removal.
+ *
+ * @param name the attribute name
+ * @param attribute the attribute value
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ void setAttribute(String name, Object attribute) throws IllegalArgumentException;
- void removeAttribute(String name);
-
+ /**
+ * Removes an attribute value.
+ *
+ * @param name the attribute name
+ * @throws IllegalArgumentException if the attribute name is null
+ */
+ void removeAttribute(String name) throws IllegalArgumentException;
}
Modified: trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java 2007-04-25 13:37:42 UTC
(rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEvent.java 2007-04-25 14:26:47 UTC
(rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* Base event class for portal events.
*
@@ -32,22 +30,4 @@
*/
public abstract class PortalEvent
{
-
- /** The portal runtime context. */
- protected PortalRuntimeContext runtimeContext;
-
- protected PortalEvent(PortalRuntimeContext runtimeContext)
- {
- this.runtimeContext = runtimeContext;
- }
-
- /**
- * Returns the runtime context or null if it is not available during the event
broadcasting.
- *
- * @return the portal runtime context
- */
- public PortalRuntimeContext getRuntimeContext()
- {
- return runtimeContext;
- }
}
Added: trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java
(rev 0)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEventContext.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 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.api.event;
+
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortalEventContext
+{
+ /**
+ * Returns the portal runtime context or null if no event context can be associated
with the event.
+ *
+ * @return the portal runtime context
+ */
+ PortalRuntimeContext getPortalRuntimeContext();
+}
Modified: trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java 2007-04-25
13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/event/PortalEventListener.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -28,5 +28,5 @@
*/
public interface PortalEventListener
{
- void onEvent(PortalEvent event);
+ void onEvent(PortalEventContext eventContext, PortalEvent event);
}
Modified: trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java
===================================================================
---
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25
13:37:42 UTC (rev 7042)
+++
trunk/api/src/main/org/jboss/portal/api/node/event/PortalNodeEventContext.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -23,6 +23,7 @@
package org.jboss.portal.api.node.event;
import org.jboss.portal.api.node.PortalNode;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
@@ -31,7 +32,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface PortalNodeEventContext
+public interface PortalNodeEventContext extends PortalEventContext
{
/**
* Dispatch the event to the next listeners.
@@ -46,11 +47,4 @@
* @return the current node.
*/
PortalNode getNode();
-
- /**
- * Returns the portal runtime context.
- *
- * @return the portal runtime context
- */
- PortalRuntimeContext getPortalRuntimeContext();
}
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java
===================================================================
---
trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java 2007-04-25
13:37:42 UTC (rev 7042)
+++
trunk/api/src/main/org/jboss/portal/api/user/event/UserAuthenticationEvent.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.user.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -38,15 +36,11 @@
private final int type;
- public UserAuthenticationEvent(PortalRuntimeContext runtimeContext, String userId, int
type)
+ public UserAuthenticationEvent(String userId, int type)
{
- super(runtimeContext, userId);
+ super(userId);
//
- if (runtimeContext == null)
- {
- throw new IllegalArgumentException("Need a runtime context for this kind of
event");
- }
if (userId == null)
{
throw new IllegalArgumentException("No user id provided");
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java 2007-04-25 13:37:42
UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/user/event/UserEvent.java 2007-04-25 14:26:47
UTC (rev 7043)
@@ -23,7 +23,6 @@
package org.jboss.portal.api.user.event;
import org.jboss.portal.api.event.PortalEvent;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -35,9 +34,8 @@
/** The user id or null if the user is anonymous. */
protected final String userId;
- public UserEvent(PortalRuntimeContext runtimeContext, String userId)
+ public UserEvent(String userId)
{
- super(runtimeContext);
this.userId = userId;
}
Modified: trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java 2007-04-25
13:37:42 UTC (rev 7042)
+++ trunk/api/src/main/org/jboss/portal/api/user/event/UserSessionEvent.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.api.user.event;
-import org.jboss.portal.spi.runtime.PortalRuntimeContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -37,15 +35,11 @@
private final int type;
- public UserSessionEvent(PortalRuntimeContext runtimeContext, String userId, int type)
+ public UserSessionEvent(String userId, int type)
{
- super(runtimeContext, userId);
+ super(userId);
//
- if (runtimeContext == null)
- {
- throw new IllegalArgumentException("Need a runtime context for this kind of
event");
- }
if (type < SESSION_CREATED || type > SESSION_DESTROYED)
{
throw new IllegalArgumentException("Wrong event type");
Deleted:
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java 2007-04-25
13:37:42 UTC (rev 7042)
+++
trunk/core/src/main/org/jboss/portal/core/event/SessionEventListenerRegistry.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2007, 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.core.event;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.portal.common.util.ParameterValidation;
-
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-import java.util.Iterator;
-import java.util.Map;
-
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.6
- */
-public class SessionEventListenerRegistry implements HttpSessionListener
-{
- private static final Map listeners = new ConcurrentHashMap();
-
- public static void registerListener(String id, HttpSessionListener listener)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(listener,
"listener");
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "registerListener");
-
- listeners.put(id, listener);
- }
-
- public static void unregisterListener(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "unregisterListener");
-
- listeners.remove(id);
- }
-
- public static HttpSessionListener getListener(String id)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "listener
identifier", "getListener");
-
- return (HttpSessionListener)listeners.get(id);
- }
-
- public void sessionCreated(HttpSessionEvent httpSessionEvent)
- {
- for (Iterator allListeners = listeners.values().iterator();
allListeners.hasNext();)
- {
- HttpSessionListener listener = (HttpSessionListener)allListeners.next();
- listener.sessionCreated(httpSessionEvent);
- }
- }
-
- public void sessionDestroyed(HttpSessionEvent httpSessionEvent)
- {
- for (Iterator allListeners = listeners.values().iterator();
allListeners.hasNext();)
- {
- HttpSessionListener listener = (HttpSessionListener)allListeners.next();
- listener.sessionDestroyed(httpSessionEvent);
- }
- }
-}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java (from
rev 7042, trunk/core/src/main/org/jboss/portal/core/event/user/UserEventBridge.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventBridge.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * 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.core.impl.api.user;
+
+import org.jboss.portal.core.event.PortalEventListenerRegistry;
+import org.jboss.portal.core.impl.api.CorePortalRuntimeContext;
+import org.jboss.portal.api.user.event.UserSessionEvent;
+import org.jboss.portal.api.user.event.UserAuthenticationEvent;
+import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.mx.util.MBeanProxy;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.mx.util.MBeanProxyCreationException;
+
+import javax.servlet.http.HttpSessionListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionBindingEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserEventBridge implements HttpSessionListener, ServletContextListener,
HttpSessionAttributeListener
+{
+
+ /** . */
+ private PortalEventListenerRegistry listenerRegistry;
+
+ // ServletContextListener implementation
****************************************************************************
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ try
+ {
+ listenerRegistry =
(PortalEventListenerRegistry)MBeanProxy.get(PortalEventListenerRegistry.class,
ObjectNameFactory.create("portal:service=ListenerRegistry"),
MBeanServerLocator.locateJBoss());
+ }
+ catch (MBeanProxyCreationException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ listenerRegistry = null;
+ }
+
+ // HttpSessionListener implementation
*******************************************************************************
+
+ public void sessionCreated(HttpSessionEvent event)
+ {
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
+ UserEventContext uec = new UserEventContext(rt);
+ UserSessionEvent use = new UserSessionEvent(null,
UserSessionEvent.SESSION_CREATED);
+ fireEvent(uec, use);
+ }
+
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession());
+ UserEventContext uec = new UserEventContext(rt);
+ UserSessionEvent use = new UserSessionEvent(null,
UserSessionEvent.SESSION_DESTROYED);
+ fireEvent(uec, use);
+ }
+
+ // HttpSessionAttributeListener implementation
**********************************************************************
+
+
+ public void attributeAdded(HttpSessionBindingEvent event)
+ {
+ if ("PRINCIPAL_TOKEN".equals(event.getName()))
+ {
+ String userId = (String)event.getValue();
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
+ UserEventContext uec = new UserEventContext(rt);
+ UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_IN);
+ fireEvent(uec, uae);
+ }
+ }
+
+ public void attributeRemoved(HttpSessionBindingEvent event)
+ {
+ if ("PRINCIPAL_TOKEN".equals(event.getName()))
+ {
+ String userId = (String)event.getValue();
+ CorePortalRuntimeContext rt = new CorePortalRuntimeContext(event.getSession(),
userId);
+ UserEventContext uec = new UserEventContext(rt);
+ UserAuthenticationEvent uae = new UserAuthenticationEvent(userId,
UserAuthenticationEvent.SIGN_OUT);
+ fireEvent(uec, uae);
+ }
+ }
+
+ public void attributeReplaced(HttpSessionBindingEvent event)
+ {
+ }
+
+ private void fireEvent(PortalEventContext eventContext, PortalEvent event)
+ {
+ for (Iterator i = listenerRegistry.getListeners().iterator();i.hasNext();)
+ {
+ Object o = i.next();
+ if (o instanceof PortalEventListener)
+ {
+ PortalEventListener listener = (PortalEventListener)o;
+ try
+ {
+ listener.onEvent(null, event);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventContext.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.core.impl.api.user;
+
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.portal.spi.runtime.PortalRuntimeContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserEventContext implements PortalEventContext
+{
+
+ /** . */
+ private PortalRuntimeContext portalRuntimeContext;
+
+ public UserEventContext(PortalRuntimeContext portalRuntimeContext)
+ {
+ this.portalRuntimeContext = portalRuntimeContext;
+ }
+
+ public PortalRuntimeContext getPortalRuntimeContext()
+ {
+ return portalRuntimeContext;
+ }
+}
Copied: trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java
(from rev 7039,
trunk/core/src/main/org/jboss/portal/core/event/user/UserEventInterceptor.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/api/user/UserEventInterceptor.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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.core.impl.api.user;
+
+import org.jboss.portal.server.ServerInterceptor;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserEventInterceptor extends ServerInterceptor
+{
+ protected void invoke(ServerInvocation invocation) throws Exception,
InvocationException
+ {
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ HttpSession session = req.getSession(false);
+ if (session != null)
+ {
+ Principal userPrincipal = req.getUserPrincipal();
+ if (userPrincipal != null)
+ {
+ if (session.getAttribute("PRINCIPAL_TOKEN") == null)
+ {
+ session.setAttribute("PRINCIPAL_TOKEN",
userPrincipal.getName());
+ }
+ }
+ else
+ {
+ if (session.getAttribute("PRINCIPAL_TOKEN") != null)
+ {
+ session.removeAttribute("PRINCIPAL_TOKEN");
+ }
+ }
+ }
+
+ //
+ invocation.invokeNext();
+ }
+}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-25
13:37:42 UTC (rev 7042)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-25
14:26:47 UTC (rev 7043)
@@ -108,7 +108,7 @@
<xmbean/>
</mbean>
<mbean
- code="org.jboss.portal.core.event.user.UserEventInterceptor"
+ code="org.jboss.portal.core.impl.api.user.UserEventInterceptor"
name="portal:service=Interceptor,type=Server,name=UserEvent"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-25 13:37:42 UTC
(rev 7042)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2007-04-25 14:26:47 UTC
(rev 7043)
@@ -33,7 +33,7 @@
<!-- Bridge portal user events -->
<listener>
-
<listener-class>org.jboss.portal.core.event.user.UserEventBridge</listener-class>
+
<listener-class>org.jboss.portal.core.impl.api.user.UserEventBridge</listener-class>
</listener>
<!-- The portal servlet is the main entrance point -->
Modified:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java 2007-04-25
13:37:42 UTC (rev 7042)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/PortalEventListenerLogger.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -24,6 +24,7 @@
import org.jboss.portal.api.event.PortalEventListener;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.api.user.event.UserAuthenticationEvent;
@@ -33,7 +34,7 @@
*/
public class PortalEventListenerLogger implements PortalEventListener
{
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
if (event instanceof UserSessionEvent)
{
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-25
13:37:42 UTC (rev 7042)
+++
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/support/MockWSRPConsumer.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -24,6 +24,7 @@
package org.jboss.portal.test.wsrp.framework.support;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -160,7 +161,7 @@
{
}
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-04-25
13:37:42 UTC (rev 7042)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -26,6 +26,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.api.event.PortalEvent;
import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.user.event.UserSessionEvent;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.InvokerUnavailableException;
@@ -400,13 +401,13 @@
// PortalEventListener implementation
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
if (event instanceof UserSessionEvent)
{
UserSessionEvent use = (UserSessionEvent)event;
int type = use.getType();
- String id = use.getRuntimeContext().getSession().getId();
+ String id = eventContext.getPortalRuntimeContext().getSession().getId();
switch (type)
{
case UserSessionEvent.SESSION_CREATED:
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-25
13:37:42 UTC (rev 7042)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java 2007-04-25
14:26:47 UTC (rev 7043)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.common.i18n.LocaleInfo;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.util.ParameterValidation;
@@ -627,11 +628,12 @@
/**
* Just delegate to SessionHandler
*
+ * @param eventContext
* @param event
* @since 2.6
*/
- public void onEvent(PortalEvent event)
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
{
- sessionHandler.onEvent(event);
+ sessionHandler.onEvent(null, event);
}
}