Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.9 topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.10 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.9 Mon Jan 23 13:51:52 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java Mon Jan 30 14:38:53 2006 @@ -23,9 +23,9 @@ * * @author poussin * - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Last update: $Date: 2006/01/23 13:51:52 $ by : $Author: bpoussin $ + * Last update: $Date: 2006/01/30 14:38:53 $ by : $Author: thimel $ */ package org.codelutin.topia.framework; @@ -51,10 +51,14 @@ import org.codelutin.topia.TopiaVetoException; import org.codelutin.topia.event.TopiaEntityEvent; import org.codelutin.topia.event.TopiaEntityListener; +import org.codelutin.topia.event.TopiaEntityLoadEvent; +import org.codelutin.topia.event.TopiaEntityLoadListener; import org.codelutin.topia.event.TopiaTransactionEvent; import org.codelutin.topia.event.TopiaTransactionListener; import org.codelutin.topia.event.TopiaVetoableEntityEvent; import org.codelutin.topia.event.TopiaVetoableEntityListener; +import org.codelutin.topia.event.TopiaVetoableEntityLoadEvent; +import org.codelutin.topia.event.TopiaVetoableEntityLoadListener; import org.codelutin.topia.persistence.TopiaDAO; import org.codelutin.topia.persistence.TopiaDAODelegator; import org.codelutin.topia.persistence.TopiaEntity; @@ -154,9 +158,15 @@ protected CategorisedListenerSet listeners = new CategorisedListenerSet( TopiaEntityListener.class); + protected CategorisedListenerSet loadListeners = new CategorisedListenerSet( + TopiaEntityLoadListener.class); + protected ListenerSet vetoableListeners = new ListenerSet( TopiaVetoableEntityListener.class); + protected ListenerSet vetoableLoadListeners = new ListenerSet( + TopiaVetoableEntityLoadListener.class); + protected ListenerSet transactionListeners = new ListenerSet( TopiaTransactionListener.class); @@ -406,19 +416,25 @@ return result; } - /* - * (non-Javadoc) - * + /* (non-Javadoc) * @see org.codelutin.topia.framework.TopiaContextImplementor#getListeners() */ public CategorisedListenerSet getListeners() { return listeners; } + public CategorisedListenerSet getLoadListeners() { + return loadListeners; + } + public ListenerSet getVetoableListeners() { return this.vetoableListeners; } - + + public ListenerSet getVetoableLoadListeners() { + return vetoableLoadListeners; + } + /** * @return Returns the transactionListeners. */ @@ -434,6 +450,14 @@ this.vetoableListeners.remove(l); } + public void addVetoableLoadListener(TopiaVetoableEntityLoadListener l) { + this.vetoableLoadListeners.add(l); + } + + public void removeVetoableLoadListener(TopiaVetoableEntityLoadListener l) { + this.vetoableLoadListeners.remove(l); + } + public void addTransactionListener(TopiaTransactionListener l) { this.transactionListeners.add(l); } @@ -485,6 +509,41 @@ getListeners().remove(entityClass, l); } + + /* (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#addTopiaEntityLoadListener( + * org.codelutin.topia.event.TopiaEntityLoadListener) + */ + public void addTopiaEntityLoadListener(TopiaEntityLoadListener l) { + addTopiaEntityLoadListener(Object.class, l); + } + + /* (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#addTopiaEntityLoadListener( + * java.lang.Class, org.codelutin.topia.event.TopiaEntityLoadListener) + */ + public void addTopiaEntityLoadListener(Class entityClass, + TopiaEntityLoadListener l) { + getLoadListeners().add(entityClass, l); + } + + /* (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#removeTopiaEntityLoadListener( + * org.codelutin.topia.event.TopiaEntityLoadListener) + */ + public void removeTopiaEntityLoadListener(TopiaEntityLoadListener l) { + removeTopiaEntityLoadListener(Object.class, l); + } + + /* (non-Javadoc) + * @see org.codelutin.topia.TopiaContext#removeTopiaEntityLoadListener( + * java.lang.Class, org.codelutin.topia.event.TopiaEntityLoadListener) + */ + public void removeTopiaEntityLoadListener(Class entityClass, + TopiaEntityLoadListener l) { + getLoadListeners().remove(entityClass, l); + } + /* * (non-Javadoc) * @@ -660,8 +719,8 @@ log.debug("fireVetoableLoad: " + id); } try { - TopiaVetoableEntityEvent event = new TopiaVetoableEntityEvent(this, entityClass, id); - for(Iterator l=getVetoableListeners().iterator(); l.hasNext();) { + TopiaVetoableEntityLoadEvent event = new TopiaVetoableEntityLoadEvent(this, entityClass, id); + for(Iterator l=getVetoableLoadListeners().iterator(); l.hasNext();) { l.next().loadEntity(event); } if (getParentContext() != null) { @@ -744,9 +803,9 @@ ((TopiaEntityAbstract) entity).setTopiaContext(this); } try { - TopiaEntityEvent event = new TopiaEntityEvent(this, entity); + TopiaEntityLoadEvent event = new TopiaEntityLoadEvent(this, entity); transactionEvents.add(new TopiaTransactionEvent(this, entityClass, id)); - for(Iterator l=getListeners().iterator(entity.getClass()); l.hasNext();) { + for(Iterator l=getLoadListeners().iterator(entity.getClass()); l.hasNext();) { l.next().entityLoaded(event); } } catch (Exception eee) { @@ -1034,4 +1093,5 @@ } } } + } Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.3 topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.4 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.3 Fri Jan 6 12:15:20 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java Mon Jan 30 14:38:53 2006 @@ -23,10 +23,10 @@ * Created: 3 janv. 2006 21:27:24 * * @author poussin - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Last update: $Date: 2006/01/06 12:15:20 $ - * by : $Author: bpoussin $ + * Last update: $Date: 2006/01/30 14:38:53 $ + * by : $Author: thimel $ */ package org.codelutin.topia.framework; @@ -98,11 +98,21 @@ public CategorisedListenerSet getListeners(); /** + * Retourne tous les loadListeners + */ + public CategorisedListenerSet getLoadListeners(); + + /** * @return Returns the vetoableListeners. */ public ListenerSet getVetoableListeners(); /** + * @return Returns the vetoableLoadListeners. + */ + public ListenerSet getVetoableLoadListeners(); + + /** * @return Returns the transactionListeners. */ public ListenerSet getTransactionListeners();