Author: thomas.heute(a)jboss.com
Date: 2007-04-30 10:13:19 -0400 (Mon, 30 Apr 2007)
New Revision: 7151
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/UserCounterListener.java
Modified:
trunk/core-samples/src/resources/portal-samples-sar/META-INF/jboss-service.xml
Log:
Example for the doc (disabled)
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/UserCounterListener.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/UserCounterListener.java
(rev 0)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/event/UserCounterListener.java 2007-04-30
14:13:19 UTC (rev 7151)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * 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.portlet.test.event;
+
+import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
+import org.jboss.portal.api.event.PortalEventListener;
+import org.jboss.portal.api.user.event.UserAuthenticationEvent;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserCounterListener implements PortalEventListener
+{
+
+ private int counter = 0;
+ private int counterEver = 0;
+
+ public void onEvent(PortalEventContext eventContext, PortalEvent event)
+ {
+ if (event instanceof UserAuthenticationEvent)
+ {
+ UserAuthenticationEvent userEvent = (UserAuthenticationEvent)event;
+ if (userEvent.getType() == UserAuthenticationEvent.SIGN_IN)
+ {
+ counter++;
+ counterEver++;
+ }
+ else if (userEvent.getType() == UserAuthenticationEvent.SIGN_OUT)
+ {
+ counter--;
+ }
+ System.out.println("Counter : " + counter);
+ System.out.println("Counter ever: " + counterEver);
+ }
+ }
+}
Modified: trunk/core-samples/src/resources/portal-samples-sar/META-INF/jboss-service.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-sar/META-INF/jboss-service.xml 2007-04-30
13:42:29 UTC (rev 7150)
+++
trunk/core-samples/src/resources/portal-samples-sar/META-INF/jboss-service.xml 2007-04-30
14:13:19 UTC (rev 7151)
@@ -61,5 +61,17 @@
<attribute name="RegistryId">user_listener</attribute>
<attribute
name="ListenerClassName">org.jboss.portal.core.portlet.test.event.PortalEventListenerLogger</attribute>
</mbean>
+ <!-- mbean
+ code="org.jboss.portal.core.event.PortalEventListenerServiceImpl"
+ name="portal:service=ListenerService,type=counter_listener"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="Registry"
+
proxy-type="attribute">portal:service=ListenerRegistry</depends>
+ <attribute name="RegistryId">counter_listener</attribute>
+ <attribute
name="ListenerClassName">org.jboss.portal.core.portlet.test.event.UserCounterListener</attribute>
+ </mbean-->
</server>