Author: julien(a)jboss.com
Date: 2007-02-06 09:22:19 -0500 (Tue, 06 Feb 2007)
New Revision: 6175
Added:
trunk/identity/src/main/org/jboss/portal/identity/event/
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEvent.java
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventBroadcaster.java
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventEmitter.java
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventListener.java
trunk/identity/src/main/org/jboss/portal/identity/event/UserCreatedEvent.java
trunk/identity/src/main/org/jboss/portal/identity/event/UserDestroyedEvent.java
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java
Log:
added trivial eventing stuff for identity, not yet wired anywhere
Added: trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEvent.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEvent.java
(rev 0)
+++ trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEvent.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.identity.event;
+
+/**
+ * Generic identity event.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityEvent
+{
+}
Added:
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventBroadcaster.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventBroadcaster.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventBroadcaster.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -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.identity.event;
+
+/**
+ * Interface that allow event firing.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityEventBroadcaster
+{
+ /**
+ * Fire an event.
+ *
+ * @param event the event to fire
+ */
+ void fireEvent(IdentityEvent event);
+}
Added: trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventEmitter.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventEmitter.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventEmitter.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.identity.event;
+
+/**
+ * Interface that allows registration management of identity event listeners.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityEventEmitter
+{
+ /**
+ * Add a listener.
+ *
+ * @param listener the listener
+ */
+ void addListener(IdentityEventListener listener);
+
+ /**
+ * Remove a listener.
+ *
+ * @param listener the listener
+ */
+ void removeListener(IdentityEventListener listener);
+}
Added: trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventListener.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventListener.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/event/IdentityEventListener.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -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.identity.event;
+
+/**
+ * An event listener.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityEventListener
+{
+ /**
+ * Fire event on the listener.
+ *
+ * @param event the identity event
+ */
+ void onEvent(IdentityEvent event);
+}
Added: trunk/identity/src/main/org/jboss/portal/identity/event/UserCreatedEvent.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/UserCreatedEvent.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/event/UserCreatedEvent.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.identity.event;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserCreatedEvent extends IdentityEvent
+{
+
+ /** . */
+ private final Object userId;
+
+ /** . */
+ private final String userName;
+
+ public UserCreatedEvent(Object userId, String userName)
+ {
+ if (userId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (userName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.userId = userId;
+ this.userName = userName;
+ }
+
+ public Object getUserId()
+ {
+ return userId;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public String toString()
+ {
+ return "UserCreatedEvent[userId=" + userId + ",userName=" +
userName + "]";
+ }
+}
Added: trunk/identity/src/main/org/jboss/portal/identity/event/UserDestroyedEvent.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/event/UserDestroyedEvent.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/event/UserDestroyedEvent.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.identity.event;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UserDestroyedEvent extends IdentityEvent
+{
+
+ /** . */
+ private final Object userId;
+
+ /** . */
+ private final String userName;
+
+ public UserDestroyedEvent(Object userId, String userName)
+ {
+ if (userId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (userName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.userId = userId;
+ this.userName = userName;
+ }
+
+ public Object getUserId()
+ {
+ return userId;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public String toString()
+ {
+ return "UserDestroyedEvent[userId=" + userId + ",userName=" +
userName + "]";
+ }
+}
Added:
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java 2007-02-06
14:22:19 UTC (rev 6175)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.identity.service;
+
+import org.jboss.portal.identity.event.IdentityEventBroadcaster;
+import org.jboss.portal.identity.event.IdentityEventListener;
+import org.jboss.portal.identity.event.IdentityEvent;
+import org.jboss.portal.identity.event.IdentityEventEmitter;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityEventService extends AbstractJBossService implements
IdentityEventBroadcaster, IdentityEventEmitter
+{
+
+ /** . */
+ private final CopyOnWriteRegistry listeners;
+
+ public IdentityEventService()
+ {
+ listeners = new CopyOnWriteRegistry();
+ }
+
+ public void addListener(IdentityEventListener listener)
+ {
+ listeners.register(listener, listener);
+ }
+
+ public void removeListener(IdentityEventListener listener)
+ {
+ listeners.unregister(listener);
+ }
+
+ public void fireEvent(IdentityEvent event)
+ {
+ for (Iterator i = listeners.getRegistrations().iterator();i.hasNext();)
+ {
+ IdentityEventListener listener = (IdentityEventListener)i.next();
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception e)
+ {
+ log.error("Listener " + listener + " threw an exception during
event firing " + event, e);
+ }
+ }
+ }
+}