Index: topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java:1.1 --- /dev/null Wed Jan 4 13:21:56 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java Wed Jan 4 13:21:51 2006 @@ -0,0 +1,92 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * TopiaEntityEvent.java + * + * Created: 14 mai 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2006/01/04 13:21:51 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.event; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.EventObject; + +import org.codelutin.topia.persistence.TopiaEntity; + +public class TopiaEntityEvent extends EventObject { // TopiaEntityEvent + + /** */ + private static final long serialVersionUID = 1L; + + protected long date = 0; + protected Collection entities = null; + + /** + * @param source l'objet d'ou provient l'event + * @param entity l'entity sur lequel porte l'event + */ + public TopiaEntityEvent(Object source, Object entity){ + super(source); + date = System.currentTimeMillis(); + ArrayList tmp = new ArrayList(); + tmp.add(entity); + this.entities = Collections.unmodifiableList(tmp); + } + + /** + * @param source l'objet d'ou provient l'event + * @param entities la liste des entitées sur lequel porte l'event + */ + public TopiaEntityEvent(Object source, Collection entities){ + super(source); + date = System.currentTimeMillis(); + // on fait une copie pour que l'on ne soit pas affecté par des + // changement fait sur la collection passé en parametre + ArrayList tmp = new ArrayList(); + tmp.addAll(entities); + this.entities = Collections.unmodifiableCollection(tmp); + } + + /** + * Retourne la liste des entitées sur lequel porte l'event + * @return une liste non modifiable d'entité + */ + public Collection getTopiaEntities(){ + return entities; + } + + /** + * Le moment ou l'event a ete créé. + */ + public Date getCreationDate(){ + return new Date(date); + } + +} // TopiaEntityEvent + Index: topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java:1.1 --- /dev/null Wed Jan 4 13:21:56 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java Wed Jan 4 13:21:51 2006 @@ -0,0 +1,51 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * TopiaEntityListener.java + * + * Created: 14 mai 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2006/01/04 13:21:51 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.event; + +import java.util.EventListener; + +public interface TopiaEntityListener extends EventListener { + + /** + * Appelé lorsqu'une ou plusieurs entités ont été créées + */ + public void entityCreated(TopiaEntityEvent event); + /** + * Appelé lorsqu'une ou plusieurs entités ont été modifiées + */ + public void entityUpdated(TopiaEntityEvent event); + /** + * Appelé lorsqu'une ou plusieurs entités ont été supprimées + */ + public void entityDeleted(TopiaEntityEvent event); + +}