On Tue, Dec 14, 2010 at 3:01 PM, tmortagne
<platform-notifications(a)xwiki.org> wrote:
Author: tmortagne
Date: 2010-12-14 15:01:28 +0100 (Tue, 14 Dec 2010)
New Revision: 33376
Added:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/legacy/internal/
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
Removed:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
Modified:
platform/core/trunk/xwiki-bridge/pom.xml
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
Log:
XWIKI-5786: Deprecate Document(Save|Update|Delete)Event and add new
Document(Created|Updated|Deleted)Event in xwiki-bridge instead
* LegacyEventDispatcher loses document name
* LegacyEventDispatcher should be in an internal package
* AbstractDocumentEvent has nothing to do in xwiki-model
Modified: platform/core/trunk/xwiki-bridge/pom.xml
===================================================================
--- platform/core/trunk/xwiki-bridge/pom.xml 2010-12-14 09:19:33 UTC (rev 33375)
+++ platform/core/trunk/xwiki-bridge/pom.xml 2010-12-14 14:01:28 UTC (rev 33376)
@@ -56,13 +56,6 @@
<!-- Apply the Checkstyle configurations defined in the top level pom.xml file
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.xwiki.platform.tools</groupId>
- <artifactId>xwiki-verification-resources</artifactId>
- <version>${platform.tool.verification.version}</version>
- </dependency>
- </dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Copied:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
(from rev 33375,
platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java)
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
(rev 0)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/AbstractDocumentEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -0,0 +1,74 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.xwiki.bridge.event;
+
+import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
+import org.xwiki.model.reference.DocumentReference;
+import org.xwiki.observation.event.AbstractFilterableEvent;
+import org.xwiki.observation.event.filter.EventFilter;
+
+/**
+ * Base class for all document related {@link org.xwiki.observation.event.Event}.
+ *
+ * @version $Id$
+ * @since 2.7RC1
+ */
+public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
+{
+ /**
+ * The version identifier for this Serializable class. Increment only if the
<i>serialized</i> form of the class
+ * changes.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Used to serialize document name.
+ */
+ private static final DefaultStringEntityReferenceSerializer SERIALIZER =
+ new DefaultStringEntityReferenceSerializer();
+
+ /**
+ * This event will match any other document event of the same type.
+ */
+ public AbstractDocumentEvent()
+ {
+ super();
+ }
+
+ /**
+ * This event will match only events of the same type affecting the same document.
+ *
+ * @param documentReference the reference of the document relater to this event
+ */
+ public AbstractDocumentEvent(DocumentReference documentReference)
+ {
+ super(SERIALIZER.serialize(documentReference));
+ }
+
+ /**
+ * Constructor using a custom {@link EventFilter}.
+ *
+ * @param eventFilter the filter to use for matching events
+ */
+ public AbstractDocumentEvent(EventFilter eventFilter)
+ {
+ super(eventFilter);
+ }
+}
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatedEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered after a document is created.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentCreatedEvent extends AbstractDocumentEvent
{
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentCreatingEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered before a document is created.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentCreatingEvent extends AbstractDocumentEvent
{
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletedEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered after a document is deleted.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentDeletedEvent extends AbstractDocumentEvent
{
@@ -43,7 +43,7 @@
*/
public DocumentDeletedEvent()
{
- super();
+
}
/**
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentDeletingEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered before a document is deleted.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentDeletingEvent extends AbstractDocumentEvent
{
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatedEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered after a document is updated.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentUpdatedEvent extends AbstractDocumentEvent
{
Modified:
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
===================================================================
---
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/event/DocumentUpdatingEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,13 +20,13 @@
package org.xwiki.bridge.event;
import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
/**
* An event triggered before a document is updated.
*
* @version $Id$
+ * @since 2.7RC1
*/
public class DocumentUpdatingEvent extends AbstractDocumentEvent
{
@@ -35,7 +35,7 @@
* changes.
*/
private static final long serialVersionUID = 1L;
-
+
/**
* Constructor initializing the event filter with an
* {@link org.xwiki.observation.event.filter.AlwaysMatchingEventFilter}, meaning that
this event will match any
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/cache/DefaultDocumentCache.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -24,6 +24,7 @@
import java.util.HashSet;
import java.util.List;
+import org.xwiki.bridge.event.AbstractDocumentEvent;
import org.xwiki.bridge.event.DocumentCreatedEvent;
import org.xwiki.bridge.event.DocumentDeletedEvent;
import org.xwiki.bridge.event.DocumentUpdatedEvent;
@@ -39,7 +40,6 @@
import org.xwiki.model.reference.EntityReferenceSerializer;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.ObservationManager;
-import org.xwiki.model.event.AbstractDocumentEvent;
import org.xwiki.observation.event.Event;
/**
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractAttachmentEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,7 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
-import org.xwiki.model.event.AbstractDocumentEvent;
+import org.xwiki.bridge.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
import org.xwiki.observation.event.filter.FixedNameEventFilter;
Modified:
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
===================================================================
---
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/internal/event/AbstractCommentEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -20,7 +20,7 @@
*/
package com.xpn.xwiki.internal.event;
-import org.xwiki.model.event.AbstractDocumentEvent;
+import org.xwiki.bridge.event.AbstractDocumentEvent;
import org.xwiki.observation.event.filter.EventFilter;
import org.xwiki.observation.event.filter.FixedNameEventFilter;
Copied:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
(from rev 33375,
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java)
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
(rev 0)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/legacy/internal/LegacyEventDispatcher.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -0,0 +1,120 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.xwiki.legacy.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xwiki.bridge.event.DocumentCreatedEvent;
+import org.xwiki.bridge.event.DocumentDeletedEvent;
+import org.xwiki.bridge.event.DocumentUpdatedEvent;
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.logging.AbstractLogEnabled;
+import org.xwiki.component.manager.ComponentLookupException;
+import org.xwiki.component.manager.ComponentManager;
+import org.xwiki.observation.EventListener;
+import org.xwiki.observation.ObservationManager;
+import org.xwiki.observation.event.DocumentDeleteEvent;
+import org.xwiki.observation.event.DocumentSaveEvent;
+import org.xwiki.observation.event.DocumentUpdateEvent;
+import org.xwiki.observation.event.Event;
+
+/**
+ * An event listener that forwards received events to their corresponding legacy events.
This allows depreciated events
+ * to continue be supported.
+ *
+ * @version $Id$
+ */
+@Component("legacyEventDispatcher")
+public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
+{
+ /**
+ * Component manager, used to get access to the observation manager that we cannot
get injected because of a cyclic
+ * dependency.
+ */
+ @Requirement
+ private ComponentManager componentManager;
+
+ /**
+ * Observation manager, used to notify legacy events.
+ */
+ private ObservationManager observationManager;
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName()
+ {
+ return "legacyEventDispatcher";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<Event> getEvents()
+ {
+ return new ArrayList<Event>()
+ {
+ {
+ add(new DocumentDeletedEvent());
+ add(new DocumentCreatedEvent());
+ add(new DocumentUpdatedEvent());
+ }
+ };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onEvent(Event event, Object source, Object data)
+ {
+ if (event instanceof DocumentDeletedEvent) {
+ this.getObservationManager().notify(
+ new DocumentDeleteEvent(((DocumentDeletedEvent)
event).getEventFilter()), source, data);
+ } else if (event instanceof DocumentCreatedEvent) {
+ this.getObservationManager().notify(new
DocumentSaveEvent(((DocumentCreatedEvent) event).getEventFilter()),
+ source, data);
+ } else if (event instanceof DocumentUpdatedEvent) {
+ this.getObservationManager().notify(
+ new DocumentUpdateEvent(((DocumentUpdatedEvent)
event).getEventFilter()), source, data);
+ }
+ }
+
+ /**
+ * Helper to lazily lookup the observation manager.
+ *
+ * @return the observation manager
+ */
+ private ObservationManager getObservationManager()
+ {
+ if (this.observationManager != null) {
+ return this.observationManager;
+ }
+ try {
+ this.observationManager =
this.componentManager.lookup(ObservationManager.class);
+ } catch (ComponentLookupException e) {
+ this.getLogger().error("Failed to lookup observation manager",
e);
+ }
+ return this.observationManager;
+ }
+
+}
Deleted:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/LegacyEventDispatcher.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -1,115 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * 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.xwiki.observation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.xwiki.bridge.event.DocumentCreatedEvent;
-import org.xwiki.bridge.event.DocumentDeletedEvent;
-import org.xwiki.bridge.event.DocumentUpdatedEvent;
-import org.xwiki.component.annotation.Component;
-import org.xwiki.component.annotation.Requirement;
-import org.xwiki.component.logging.AbstractLogEnabled;
-import org.xwiki.component.manager.ComponentLookupException;
-import org.xwiki.component.manager.ComponentManager;
-import org.xwiki.observation.event.DocumentDeleteEvent;
-import org.xwiki.observation.event.DocumentSaveEvent;
-import org.xwiki.observation.event.DocumentUpdateEvent;
-import org.xwiki.observation.event.Event;
-
-/**
- * An event listener that forwards received events to their corresponding legacy events.
This allows depreciated events
- * to continue be supported.
- *
- * @version $Id$
- */
-@Component("legacyEventDispatcher")
-public class LegacyEventDispatcher extends AbstractLogEnabled implements EventListener
-{
- /**
- * Component manager, used to get access to the observation manager that we cannot
get injected because of a cyclic
- * dependency.
- */
- @Requirement
- private ComponentManager componentManager;
-
- /**
- * Observation manager, used to notify legacy events.
- */
- private ObservationManager observationManager;
-
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return "legacyEventDispatcher";
- }
-
- /**
- * {@inheritDoc}
- */
- public List<Event> getEvents()
- {
- return new ArrayList<Event>()
- {
- {
- add(new DocumentDeletedEvent());
- add(new DocumentCreatedEvent());
- add(new DocumentUpdatedEvent());
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- public void onEvent(Event event, Object source, Object data)
- {
- if (event instanceof DocumentDeletedEvent) {
- this.getObservationManager().notify(new DocumentDeleteEvent(), source,
data);
- } else if (event instanceof DocumentCreatedEvent) {
- this.getObservationManager().notify(new DocumentSaveEvent(), source, data);
- } else if (event instanceof DocumentUpdatedEvent) {
- this.getObservationManager().notify(new DocumentUpdateEvent(), source,
data);
- }
- }
-
- /**
- * Helper to lazily lookup the observation manager.
- *
- * @return the observation manager
- */
- private ObservationManager getObservationManager()
- {
- if (this.observationManager != null) {
- return this.observationManager;
- }
- try {
- this.observationManager =
this.componentManager.lookup(ObservationManager.class);
- } catch (ComponentLookupException e) {
- this.getLogger().error("Failed to lookup observation manager",
e);
- }
- return this.observationManager;
- }
-
-}
Modified:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/AbstractDocumentEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -27,7 +27,9 @@
* Base class for all document {@link Event events}.
*
* @version $Id$
+ * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.AbstractDocumentEvent}
instead
*/
+@Deprecated
public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
{
/**
@@ -41,7 +43,7 @@
*/
public AbstractDocumentEvent()
{
- super();
+ super();
}
/**
Modified:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentDeleteEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -26,7 +26,7 @@
* An event triggered when a document is deleted.
*
* @version $Id$
- * @deprecated use {@link org.xwiki.bridge.event.DocumentDeletedEvent} instead
+ * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentDeletedEvent}
instead
*/
@Deprecated
public class DocumentDeleteEvent extends AbstractDocumentEvent
Modified:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentSaveEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -26,7 +26,7 @@
* An event triggered when a document is saved for the first time (a new document is
created).
*
* @version $Id$
- * @deprecated use {@link org.xwiki.bridge.event.DocumentCreatedEvent} instead
+ * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentCreatedEvent}
instead
*/
@Deprecated
public class DocumentSaveEvent extends AbstractDocumentEvent
Modified:
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/main/java/org/xwiki/observation/event/DocumentUpdateEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -26,7 +26,7 @@
* An event triggered when an existing document is saved (updated).
*
* @version $Id$
- * @deprecated use {@link org.xwiki.bridge.event.DocumentUpdatedEvent} instead
+ * @deprecated since 2.7RC1 use {@link org.xwiki.bridge.event.DocumentUpdatedEvent}
instead
*/
@Deprecated
public class DocumentUpdateEvent extends AbstractDocumentEvent
Modified: platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
===================================================================
--- platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
2010-12-14 09:19:33 UTC (rev 33375)
+++ platform/core/trunk/xwiki-legacy/src/main/resources/META-INF/components.txt
2010-12-14 14:01:28 UTC (rev 33376)
@@ -1 +1 @@
-org.xwiki.observation.LegacyEventDispatcher
+org.xwiki.legacy.internal.LegacyEventDispatcher
Deleted:
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
===================================================================
---
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -1,108 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * 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.xwiki.observation;
-
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.xwiki.bridge.event.DocumentCreatedEvent;
-import org.xwiki.bridge.event.DocumentDeletedEvent;
-import org.xwiki.bridge.event.DocumentUpdatedEvent;
-import org.xwiki.observation.event.DocumentDeleteEvent;
-import org.xwiki.observation.event.DocumentSaveEvent;
-import org.xwiki.observation.event.DocumentUpdateEvent;
-import org.xwiki.observation.event.Event;
-import org.xwiki.test.AbstractComponentTestCase;
-
-public class LegacyEventDispatcherTest extends AbstractComponentTestCase
-{
-
- private boolean hasBeenNotified;
-
- private ObservationManager om;
-
- @Before
- public void setUp() throws Exception
- {
- this.hasBeenNotified = false;
- this.om = this.getComponentManager().lookup(ObservationManager.class);
- }
-
- @Test
- public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
- {
- this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
- om.notify(new DocumentDeletedEvent(), new Object());
- // The notification is synchronous, so the following assertion will only be
tested
- // once all matching event listeners have been notified.
- Assert.assertTrue("Should have been notified by legacy event
dispatcher", this.hasBeenNotified);
- }
-
- @Test
- public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
- {
- this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
- om.notify(new DocumentCreatedEvent(), new Object());
- // The notification is synchronous, so the following assertion will only be
tested
- // once all matching event listeners have been notified.
- Assert.assertTrue("Should have been notified by legacy event
dispatcher", this.hasBeenNotified);
- }
-
- @Test
- public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
- {
- this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
- om.notify(new DocumentUpdatedEvent(), new Object());
- // The notification is synchronous, so the following assertion will only be
tested
- // once all matching event listeners have been notified.
- Assert.assertTrue("Should have been notified by legacy event
dispatcher", this.hasBeenNotified);
- }
-
- private void registerListenerWithLegacyEvent(final Event event)
- {
- this.om.addListener(new EventListener()
- {
- public String getName()
- {
- return "testLegacyEventDispatchEventListener";
- }
-
- public List<Event> getEvents()
- {
- return Collections.<Event> singletonList(event);
- }
-
- public void onEvent(Event event, Object source, Object data)
- {
- setNotified();
- }
-
- });
- }
-
- private void setNotified()
- {
- this.hasBeenNotified = true;
- }
-}
Copied:
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
(from rev 33375,
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/LegacyEventDispatcherTest.java)
===================================================================
---
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
(rev 0)
+++
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -0,0 +1,111 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.xwiki.observation.event;
+
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.xwiki.bridge.event.DocumentCreatedEvent;
+import org.xwiki.bridge.event.DocumentDeletedEvent;
+import org.xwiki.bridge.event.DocumentUpdatedEvent;
+import org.xwiki.model.reference.DocumentReference;
+import org.xwiki.observation.EventListener;
+import org.xwiki.observation.ObservationManager;
+import org.xwiki.observation.event.DocumentDeleteEvent;
+import org.xwiki.observation.event.DocumentSaveEvent;
+import org.xwiki.observation.event.DocumentUpdateEvent;
+import org.xwiki.observation.event.Event;
+import org.xwiki.observation.event.filter.EventFilter;
+import org.xwiki.observation.event.filter.FixedNameEventFilter;
+import org.xwiki.test.AbstractComponentTestCase;
+
+public class LegacyEventDispatcherTest extends AbstractComponentTestCase
+{
+ private Event receivedEvent;
+
+ private ObservationManager om;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ this.om = getComponentManager().lookup(ObservationManager.class);
+ }
+
+ @Test
+ public void testLegacyDocumentDeleteEventGetsDispatched() throws Exception
+ {
+ this.registerListenerWithLegacyEvent(new DocumentDeleteEvent());
+ this.om.notify(new DocumentDeletedEvent(new DocumentReference("wiki",
"space", "name")), new Object());
+
+ // The notification is synchronous, so the following assertion will only be
tested
+ // once all matching event listeners have been notified.
+ Assert.assertNotNull("Should have been notified by legacy event
dispatcher", this.receivedEvent);
+ Assert.assertEquals("Wrong event filter", "wiki:space.name",
((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
+ }
+
+ @Test
+ public void testLegacyDocumentSaveEventGetsDispatched() throws Exception
+ {
+ this.registerListenerWithLegacyEvent(new DocumentSaveEvent());
+ this.om.notify(new DocumentCreatedEvent(new DocumentReference("wiki",
"space", "name")), new Object());
+
+ // The notification is synchronous, so the following assertion will only be
tested
+ // once all matching event listeners have been notified.
+ Assert.assertNotNull("Should have been notified by legacy event
dispatcher", this.receivedEvent);
+ Assert.assertEquals("Wrong event filter", "wiki:space.name",
((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
+ }
+
+ @Test
+ public void testLegacyDocumentUpdateEventGetsDispatched() throws Exception
+ {
+ this.registerListenerWithLegacyEvent(new DocumentUpdateEvent());
+ this.om.notify(new DocumentUpdatedEvent(new DocumentReference("wiki",
"space", "name")), new Object());
+
+ // The notification is synchronous, so the following assertion will only be
tested
+ // once all matching event listeners have been notified.
+ Assert.assertNotNull("Should have been notified by legacy event
dispatcher", this.receivedEvent);
+ Assert.assertEquals("Wrong event filter", "wiki:space.name",
((EventFilter)((FilterableEvent)this.receivedEvent).getEventFilter()).getFilter());
+ }
+
+ private void registerListenerWithLegacyEvent(final Event event)
+ {
+ this.om.addListener(new EventListener()
+ {
+ public String getName()
+ {
+ return "testLegacyEventDispatchEventListener";
+ }
+
+ public List<Event> getEvents()
+ {
+ return Collections.<Event> singletonList(event);
+ }
+
+ public void onEvent(Event event, Object source, Object data)
+ {
+ receivedEvent = event;
+ }
+ });
+ }
+}
Property changes on:
platform/core/trunk/xwiki-legacy/src/test/java/org/xwiki/observation/event/LegacyEventDispatcherTest.java
___________________________________________________________________
Added: svn:keywords
+ Id
Deleted:
platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
===================================================================
---
platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
2010-12-14 09:19:33 UTC (rev 33375)
+++
platform/core/trunk/xwiki-model/src/main/java/org/xwiki/model/event/AbstractDocumentEvent.java
2010-12-14 14:01:28 UTC (rev 33376)
@@ -1,68 +0,0 @@
-/*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * 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.xwiki.model.event;
-
-import org.xwiki.model.internal.reference.DefaultStringEntityReferenceSerializer;
-import org.xwiki.model.reference.DocumentReference;
-import org.xwiki.observation.event.AbstractFilterableEvent;
-import org.xwiki.observation.event.Event;
-import org.xwiki.observation.event.filter.EventFilter;
-
-/**
- * Base class for all document {@link Event events}.
- *
- * @version $Id$
- */
-public abstract class AbstractDocumentEvent extends AbstractFilterableEvent
-{
- /**
- * The version identifier for this Serializable class. Increment only if the
<i>serialized</i> form of the class
- * changes.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * This event will match any other document event of the same type.
- */
- public AbstractDocumentEvent()
- {
- super();
- }
-
- /**
- * This event will match only events of the same type affecting the same document.
- *
- * @param documentReference the reference of the document relater to this event
- */
- public AbstractDocumentEvent(DocumentReference documentReference)
- {
- super(new
DefaultStringEntityReferenceSerializer().serialize(documentReference));
- }
-
- /**
- * Constructor using a custom {@link EventFilter}.
- *
- * @param eventFilter the filter to use for matching events
- */
- public AbstractDocumentEvent(EventFilter eventFilter)
- {
- super(eventFilter);
- }
-}
\ No newline at end of file
_______________________________________________
notifications mailing list
notifications(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications
_______________________________________________
devs mailing list
devs(a)xwiki.org