Author: michiel
Date: 2010-04-02 18:05:14 +0200 (Fri, 02 Apr 2010)
New Revision: 41743
Removed:
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AbstractEventBroker.java
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AllEventBroker.java
mmbase/trunk/core/src/main/java/org/mmbase/core/event/Event.java
mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventBroker.java
mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventListener.java
Log:
moved to utils
Deleted:
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AbstractEventBroker.java
===================================================================
---
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AbstractEventBroker.java
2010-04-02 16:04:23 UTC (rev 41742)
+++
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AbstractEventBroker.java
2010-04-02 16:05:14 UTC (rev 41743)
@@ -1,55 +0,0 @@
-/*
- * This software is OSI Certified Open Source Software.
- * OSI Certified is a certification mark of the Open Source Initiative. The
- * license (Mozilla version 1.0) can be read at the MMBase site. See
- * http://www.MMBase.org/license
- */
-package org.mmbase.core.event;
-
-import java.util.*;
-import java.util.concurrent.CopyOnWriteArraySet;
-import org.mmbase.util.logging.Logger;
-import org.mmbase.util.logging.Logging;
-
-/**
- * An EventBroker which administrates the listeners in a {...@link
java.util.concurrent.CopyOnWriteArraySet}.
- *
- * @author Ernst Bunders
- * @since MMBase-1.8
- * @version $Id$
- */
-public abstract class AbstractEventBroker extends EventBroker {
-
- private static final Logger log =
Logging.getLoggerInstance(AbstractEventBroker.class);
-
- private final Set<EventListener> listeners = new
CopyOnWriteArraySet<EventListener>();
-
- protected Collection<EventListener> backing() {
- return listeners;
- }
-
- public boolean addListener(EventListener listener) {
- if (canBrokerForListener(listener)) {
- if (! listeners.add(listener)) {
- if (log.isDebugEnabled()) {
- log.debug("" + listener + " was already in " + getClass()
+ ". Ignored.");
- }
- return false;
- } else if (log.isDebugEnabled()) {
- log.debug("listener added to " + getClass());
- }
- return true;
- } else {
- log.warn("Ignored listener for" + getClass() + " because it cannot
broker for that.");
- }
- return false;
- }
-
- public void removeListener(EventListener listener) {
- if (! listeners.remove(listener)) {
- log.warn("Tried to remove " + listener + " from " + getClass()+ "
but it was not found. Ignored.");
- }
-
- }
-
-}
Deleted:
mmbase/trunk/core/src/main/java/org/mmbase/core/event/AllEventBroker.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/core/event/AllEventBroker.java
2010-04-02 16:04:23 UTC (rev 41742)
+++ mmbase/trunk/core/src/main/java/org/mmbase/core/event/AllEventBroker.java
2010-04-02 16:05:14 UTC (rev 41743)
@@ -1,47 +0,0 @@
-/*
- * This software is OSI Certified Open Source Software.
- * OSI Certified is a certification mark of the Open Source Initiative.
- *
- * The license (Mozilla version 1.0) can be read at the MMBase site.
- * See http://www.MMBase.org/license
- */
-package org.mmbase.core.event;
-
-
-/**
- * A simple broker for AllEventListener. Primarily created for {...@link
- * org.mmbase.clustering.ClusterManager}, which has to propagate all local
events to the mmbase
- * cluster.
- * It brokers every event which is not a {...@link LocalEvent}
- *
- * @author Ernst Bunders
- * @since 1.8
- * @version $Id$
- * @see AllEventListener
- *
- */
-public class AllEventBroker extends AbstractEventBroker {
-
- public boolean canBrokerForListener(EventListener listener) {
- if (listener instanceof AllEventListener) {
- return true;
- }
- return false;
- }
-
- public boolean canBrokerForEvent(Event event) {
- return ! (event instanceof LocalEvent);
- }
-
- protected void notifyEventListener(Event event, EventListener listener)
throws ClassCastException {
- ((AllEventListener)listener).notify(event);
- }
-
- /* (non-Javadoc)
- * @see org.mmbase.core.event.AbstractEventBroker#toString()
- */
- public String toString() {
- return "All Event Broker";
- }
-
-}
Deleted: mmbase/trunk/core/src/main/java/org/mmbase/core/event/Event.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/core/event/Event.java
2010-04-02 16:04:23 UTC (rev 41742)
+++ mmbase/trunk/core/src/main/java/org/mmbase/core/event/Event.java
2010-04-02 16:05:14 UTC (rev 41743)
@@ -1,85 +0,0 @@
-/*
- * This software is OSI Certified Open Source Software.
- * OSI Certified is a certification mark of the Open Source Initiative. The
- * license (Mozilla version 1.0) can be read at the MMBase site. See
- * http://www.MMBase.org/license
- */
-package org.mmbase.core.event;
-
-import java.io.Serializable;
-import java.util.*;
-
-import org.mmbase.module.core.MMBaseContext;
-
-/**
- * This class is the base class for all mmbase events
- *
- * @author Ernst Bunders
- * @since MMBase-1.8
- * @version $Id$
- */
-public abstract class Event implements Serializable,
org.mmbase.util.PublicCloneable<Event> {
-
- private static final long serialVersionUID = 3931865804317363984L;
-
- public static final int TYPE_UNSPECIFIED = -1;
- public static final int TYPE_NEW = 0;
- public static final int TYPE_CHANGE = 1;
- public static final int TYPE_DELETE = 2;
-
- protected int eventType = TYPE_UNSPECIFIED;
- protected String machine;
- private UUID machineId;
-
- /**
- * Every event originates from a certain machine, which is identified by a
String.
- * If this equals {...@link MMBaseContext#getMachineName()} then this is a
local event.
- */
- public String getMachine() {
- return machine;
- }
- public boolean isLocal() {
- return machineId != null ? EventManager.getUUID().equals(machineId) :
EventManager.getMachineName().equals(machine);
- }
-
-
- /**
- * Most events will come in certain 'types', default contants which are
provided are {...@link
- * #TYPE_NEW}, {...@link #TYPE_CHANGE} and {...@link #TYPE_DELETE}.
- */
- public int getType() {
- return eventType;
- }
-
- /**
- * @param machine The machine name. If <code>null</code> the local machine
name is extracted from MMBase, using
- * {...@link MMBaseContext#getMachineName()}
- */
- public Event(String machine, int type) {
- this.machine = machine == null ?
- EventManager.getMachineName() :
- machine;
- this.eventType = type;
- this.machineId = EventManager.getUUID();
- }
-
- public Event(String machine) {
- this(machine, TYPE_UNSPECIFIED);
- }
-
- /**
- * @since MMBase-1.8.4
- */
- public Event() {
- this(null);
- }
-
- public Event clone(){
- Object clone = null;
- try {
- clone = super.clone();
- } catch (CloneNotSupportedException e) {}
- return (Event) clone;
- }
-
-}
Deleted: mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventBroker.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventBroker.java
2010-04-02 16:04:23 UTC (rev 41742)
+++ mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventBroker.java
2010-04-02 16:05:14 UTC (rev 41743)
@@ -1,104 +0,0 @@
-/*
- * This software is OSI Certified Open Source Software.
- * OSI Certified is a certification mark of the Open Source Initiative. The
- * license (Mozilla version 1.0) can be read at the MMBase site. See
- * http://www.MMBase.org/license
- */
-package org.mmbase.core.event;
-
-import java.util.*;
-import org.mmbase.util.logging.Logger;
-import org.mmbase.util.logging.Logging;
-
-/**
- * This is the base class for all event brokers in mmbase. the function of an
- * event broker is to know about a specific kind of event, as well as a
specific
- * kind of event listener. All events should be derived from the
- * org.mmbase.core.event.Event class, and all listeners from the
- * org.mmbase.core.event.EventListener interface.<br/> Allthough event
- * listeners have to implement the EventListener interface, the actual method
- * that will be called to pass on the event is not part of this interface, as
it
- * is specific for the kind of event you want to listen for. This is a contract
- * between the broker implementation and the event listerer interface.<br/>
- * This class does most of the work of keeping references to all the listeners
- * and allowing for adding/removing them. Only a fiew type specific actions are
- * delegated to the super class.<br/> The EventListener also provides a method
- * for passing on constraint properties to a event broker. If you want to
create
- * your own event type you can use this feature to accomplish that not all
- * events of your type are propagated to the listener.
- *
- * @author Ernst Bunders
- * @since MMBase-1.8
- * @version $Id$
- */
-public abstract class EventBroker {
-
- private static final Logger log =
Logging.getLoggerInstance(EventBroker.class);
-
- /**
- * this method should return true if this broker can accept and propagate
- * events to the listener of this type. There are no fixed criteria for
this.
-
- * Most implementions do <code>event instanceof <EventListener
associated with this broker></code>
- *
- * @param listener
- */
- public abstract boolean canBrokerForListener(EventListener listener);
-
- /**
- * this method should return true if this event broker can broker for
- * events of this type. There are no fixed criteria for this.
- *
- * Most implementions do <code>event instanceof <EvenType associated
with this broker></code>
- *
- * @param event
- */
- public abstract boolean canBrokerForEvent(Event event);
-
- /**
- * This method has two functions. It must cast both event and listener to
- * the proper type and invoke the event on the listener. But it must allso
- * check if the listener has constraint properties set. if so it must use
- * them to decide if the event should be invoked on this listener.
- *
- * @param event
- * @param listener
- * @throws ClassCastException
- */
- protected abstract void notifyEventListener(Event event, EventListener
listener) throws ClassCastException;
-
- public abstract boolean addListener(EventListener listener);
-
- public abstract void removeListener(EventListener listener);
-
- /**
- * @since MMBase-1.8.5
- */
- protected abstract Collection<EventListener> backing();
-
- /**
- * @since MMBase-1.8.5
- */
- public Collection<EventListener> getListeners() {
- return Collections.unmodifiableCollection(backing());
- }
-
-
- public void notifyForEvent(Event event) {
- for (EventListener listener : backing()) {
- assert canBrokerForListener(listener);
- notifyEventListener(event, listener);
- }
- }
-
- public abstract String toString();
-
- public boolean equals(Object o) {
- // we can only have one instance so this will do to prevent adding
more instances of an envent broker
- return o != null && this.getClass().equals(o.getClass());
- }
-
- public int hashCode() {
- return this.getClass().hashCode();
- }
-}
Deleted:
mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventListener.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventListener.java
2010-04-02 16:04:23 UTC (rev 41742)
+++ mmbase/trunk/core/src/main/java/org/mmbase/core/event/EventListener.java
2010-04-02 16:05:14 UTC (rev 41743)
@@ -1,20 +0,0 @@
-/*
- * This software is OSI Certified Open Source Software.
- * OSI Certified is a certification mark of the Open Source Initiative. The
- * license (Mozilla version 1.0) can be read at the MMBase site. See
- * http://www.MMBase.org/license
- */
-package org.mmbase.core.event;
-
-/**
- * This interface is the common type for custom EventListener interfaces. to
- * create such a interface extend this one and add a method that will receive
an
- * event of the specific type.
- *
- * @author Ernst Bunders
- * @since MMBase-1.8
- * @version $Id$
- */
-public interface EventListener {
-
-}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs