Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.59 topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.60 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.59 Thu Dec 13 16:49:53 2007 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java Thu Dec 20 14:29:30 2007 @@ -23,9 +23,9 @@ * * @author poussin * - * @version $Revision: 1.59 $ + * @version $Revision: 1.60 $ * - * Last update: $Date: 2007-12-13 16:49:53 $ by : $Author: ruchaud $ + * Last update: $Date: 2007-12-20 14:29:30 $ by : $Author: ruchaud $ */ package org.codelutin.topia.framework; @@ -62,6 +62,7 @@ import org.codelutin.topia.TopiaException; import org.codelutin.topia.TopiaNotFoundException; import org.codelutin.topia.event.TopiaContextListener; +import org.codelutin.topia.event.TopiaEntitiesVetoable; import org.codelutin.topia.event.TopiaEntityListener; import org.codelutin.topia.event.TopiaEntityVetoable; import org.codelutin.topia.event.TopiaTransactionListener; @@ -803,6 +804,10 @@ return result; } + /* + * (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#find(java.lang.String, java.lang.Object[]) + */ public List find(String hql, Object ... args) throws TopiaException { checkClosed("Ce contexte a ete ferme, impossible de faire une recherche"); try { @@ -1116,6 +1121,10 @@ } } + public List getPersistenceClasses() { + return persistenceClasses; + } + /* Adders */ public void addTopiaEntityListener(TopiaEntityListener listener) { getFiresSupport().addTopiaEntityListener(listener); @@ -1182,8 +1191,12 @@ getFiresSupport().removeTopiaContextListener(listener); } - public List getPersistenceClasses() { - return persistenceClasses; + public void addTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable) { + getFiresSupport().addTopiaEntitiesVetoable(vetoable); + } + + public void removeTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable) { + getFiresSupport().removeTopiaEntitiesVetoable(vetoable); } } //TopiaContextImpl Index: topia2/src/java/org/codelutin/topia/framework/TopiaFiresSupport.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaFiresSupport.java:1.9 topia2/src/java/org/codelutin/topia/framework/TopiaFiresSupport.java:1.10 --- topia2/src/java/org/codelutin/topia/framework/TopiaFiresSupport.java:1.9 Thu Dec 13 15:26:48 2007 +++ topia2/src/java/org/codelutin/topia/framework/TopiaFiresSupport.java Thu Dec 20 14:29:30 2007 @@ -24,6 +24,7 @@ import java.beans.VetoableChangeSupport; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -35,6 +36,8 @@ import org.codelutin.topia.TopiaVetoException; import org.codelutin.topia.event.TopiaContextEvent; import org.codelutin.topia.event.TopiaContextListener; +import org.codelutin.topia.event.TopiaEntitiesEvent; +import org.codelutin.topia.event.TopiaEntitiesVetoable; import org.codelutin.topia.event.TopiaEntityEvent; import org.codelutin.topia.event.TopiaEntityListener; import org.codelutin.topia.event.TopiaEntityVetoable; @@ -89,6 +92,9 @@ protected CategorisedListenerSet entityListeners = new CategorisedListenerSet(); protected CategorisedListenerSet entityVetoables = new CategorisedListenerSet(); + /* Pour les listes d'entités */ + protected ListenerSet entitiesVetoables = new ListenerSet(); + /* Pour les actions du topia context */ protected ListenerSet topiaContextListeners = new ListenerSet(); @@ -666,6 +672,27 @@ } } + /** + * Notify entities listeners for load operation + * @param entities entities loaded + */ + public List fireEntitiesLoad(TopiaContextImplementor context, List entities) { + if (log.isDebugEnabled()) { + log.debug("fireEntitiesLoad"); + } + + List result = entities; + for(Iterator l=entitiesVetoables.iterator(); l.hasNext();) { + try { + TopiaEntitiesEvent event = new TopiaEntitiesEvent(context, result); + result = l.next().load(event); + } catch (Exception eee) { + throw new TopiaVetoException(eee); + } + } + return result; + } + /* Getters */ public CategorisedListenerSet getEntityListeners() { return entityListeners; @@ -687,6 +714,10 @@ return topiaContextListeners; } + public ListenerSet getTopiaEntitiesVetoable() { + return entitiesVetoables; + } + /* Adders */ public void addTopiaEntityListener(TopiaEntityListener listener) { addTopiaEntityListener(TopiaEntity.class, listener); @@ -720,6 +751,10 @@ topiaContextListeners.add(listener); } + public void addTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable) { + entitiesVetoables.add(vetoable); + } + /* Removers */ public void removeTopiaEntityListener(TopiaEntityListener listener) { removeTopiaEntityListener(TopiaEntity.class, listener); @@ -753,5 +788,8 @@ topiaContextListeners.remove(listener); } + public void removeTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable) { + entitiesVetoables.remove(vetoable); + } }