You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/05/02 16:09:04 UTC
svn commit: r770958 - in
/incubator/jspwiki/trunk/src/java/org/apache/wiki/event:
PageEventFilter.java WikiEvent.java WikiEventUtils.java WikiPageEvent.java
WikiSecurityEvent.java
Author: ajaquith
Date: Sat May 2 14:09:03 2009
New Revision: 770958
URL: http://svn.apache.org/viewvc?rev=770958&view=rev
Log:
Added varargs to WikiEvent and subclasses, so that arbitrary numbers of arguments can be supplied with events.
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/event/PageEventFilter.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEvent.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEventUtils.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiPageEvent.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiSecurityEvent.java
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/event/PageEventFilter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/event/PageEventFilter.java?rev=770958&r1=770957&r2=770958&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/event/PageEventFilter.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/event/PageEventFilter.java Sat May 2 14:09:03 2009
@@ -50,6 +50,9 @@
*
* @see org.apache.wiki.event.WikiEventManager
* @author Murray Altheim
+ * @deprecated this class was always a dopey idea because there appears to be no limit on how many
+ * page events we might fire, if we stack up multiple PageEventFilters. Attach listeners to ContentManager,
+ * for example, instead.
*/
public class PageEventFilter extends BasicPageFilter
{
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEvent.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEvent.java?rev=770958&r1=770957&r2=770958&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEvent.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEvent.java Sat May 2 14:09:03 2009
@@ -21,6 +21,7 @@
package org.apache.wiki.event;
+import java.io.Serializable;
import java.util.EventObject;
/**
@@ -42,8 +43,12 @@
private int m_type = UNDEFINED;
+ private final Serializable[] m_args;
+
private final long m_when;
+ private static final Serializable[] NO_ARGS = new Serializable[0];
+
// ............
@@ -51,14 +56,39 @@
* Constructs an instance of this event.
* @param src the Object that is the source of the event.
* @param type the event type.
+ * @param args additional arguments passed to the event.
*/
- public WikiEvent( Object src, int type )
+ public WikiEvent( Object src, int type, Serializable... args )
{
+ // FIXME: not sure Serializable are the best thing to use here...
super( src );
m_when = System.currentTimeMillis();
setType( type );
+
+ // Set arguments
+ if ( args == null )
+ {
+ m_args = NO_ARGS;
+ }
+ else
+ {
+ m_args = new Serializable[args.length];
+ for ( int i = 0; i < args.length; i++ )
+ {
+ m_args[i] = args[i];
+ }
+ }
}
+ /**
+ * Returns the additional arguments passed to this event at construction,
+ * or a zero-length array if not supplied.
+ * @return the arguments
+ */
+ public Serializable[] getArgs()
+ {
+ return m_args;
+ }
/**
* Returns the timestamp of when this WikiEvent occurred.
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEventUtils.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEventUtils.java?rev=770958&r1=770957&r2=770958&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEventUtils.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiEventUtils.java Sat May 2 14:09:03 2009
@@ -98,6 +98,10 @@
// Make sure WikiEventManager exists
WikiEventManager.getInstance();
+ // FIXME: Seriously, what is all this crap code below? We've made it impossible to use the
+ // same event type with more than one source. Isn't the listener pattern supposed to
+ // stop stuff like this? Bueller?
+
// first, figure out what kind of event is expected to be generated this does
// tie us into known types, but WikiEvent.isValidType() will return true so
// long as the type was set to any non-ERROR or non-UNKNOWN value
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiPageEvent.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiPageEvent.java?rev=770958&r1=770957&r2=770958&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiPageEvent.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiPageEvent.java Sat May 2 14:09:03 2009
@@ -21,6 +21,7 @@
package org.apache.wiki.event;
+import java.io.Serializable;
/**
* WikiPageEvent indicates a change in the state or processing of a WikiPage.
@@ -171,16 +172,20 @@
public static final int PAGE_DELIVERED = 25;
/** Indicates a wiki page delete event (the beginning of a delete request).
- * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}.
+ * It is fired by ContentManager, and is identical to
+ * {@link org.apache.wiki.event.ContentEvent#NODE_DELETE_REQUEST}.
+ * @deprecated use org.apache.wiki.event.ContentEvent.NODE_DELETE_REQUEST instead
* @since 2.4.65 */
- public static final int PAGE_DELETE_REQUEST = 26;
+ public static final int PAGE_DELETE_REQUEST = ContentEvent.NODE_DELETE_REQUEST;
/** Indicates a wiki page deleted event (after the delete has been completed).
- * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}.
+ * It is fired by ContentManager, and is identical to
+ * {@link org.apache.wiki.event.ContentEvent#NODE_DELETED}.
+ * @deprecated use org.apache.wiki.event.ContentEvent.NODE_DELETED instead
* @since 2.4.65 */
- public static final int PAGE_DELETED = 27;
+ public static final int PAGE_DELETED = ContentEvent.NODE_DELETED;
- private String m_pagename = null;
+ private final String m_pagename;
// ............
@@ -191,14 +196,14 @@
* @param type the type of the event (see the enumerated int values defined
* in {@link org.apache.wiki.event.WikiEvent}).
* @param pagename the WikiPage being acted upon.
+ * @param args additional arguments passed to the event.
*/
- public WikiPageEvent( Object src, int type, String pagename )
+ public WikiPageEvent( Object src, int type, String pagename, Serializable... args )
{
- super( src, type );
+ super( src, type, args );
m_pagename = pagename;
}
-
/**
* Returns the Wiki page name associated with this event.
* This may be null if unavailable.
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiSecurityEvent.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiSecurityEvent.java?rev=770958&r1=770957&r2=770958&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiSecurityEvent.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/event/WikiSecurityEvent.java Sat May 2 14:09:03 2009
@@ -20,6 +20,7 @@
*/
package org.apache.wiki.event;
+import java.io.Serializable;
import java.security.Principal;
import org.apache.commons.lang.ArrayUtils;
@@ -143,10 +144,11 @@
* @param type the type of event
* @param principal the subject of the event, which may be <code>null</code>
* @param target the changed Object, which may be <code>null</code>
+ * @param args additional arguments passed to the event.
*/
- public WikiSecurityEvent( Object src, int type, Principal principal, Object target )
+ public WikiSecurityEvent( Object src, int type, Principal principal, Object target, Serializable...args )
{
- super( src, type );
+ super( src, type, args );
if ( src == null )
{
throw new IllegalArgumentException( "Argument(s) cannot be null." );
@@ -177,8 +179,9 @@
* page, group or authentication/authentication/group manager.
* @param type the type of event
* @param target the changed Object, which may be <code>null</code>.
+ * @param args additional arguments passed to the event.
*/
- public WikiSecurityEvent( Object src, int type, Object target )
+ public WikiSecurityEvent( Object src, int type, Object target, Serializable... args )
{
this( src, type, null, target );
}