Index: topia2/src/java/org/codelutin/topia/persistence/TopiaDAO.java diff -u topia2/src/java/org/codelutin/topia/persistence/TopiaDAO.java:1.1.1.1 topia2/src/java/org/codelutin/topia/persistence/TopiaDAO.java:1.2 --- topia2/src/java/org/codelutin/topia/persistence/TopiaDAO.java:1.1.1.1 Mon Jan 2 13:54:35 2006 +++ topia2/src/java/org/codelutin/topia/persistence/TopiaDAO.java Wed Jan 4 13:21:51 2006 @@ -23,9 +23,9 @@ * Created: 30 déc. 2005 03:00:57 * * @author poussin - * @version $Revision: 1.1.1.1 $ + * @version $Revision: 1.2 $ * - * Last update: $Date: 2006/01/02 13:54:35 $ + * Last update: $Date: 2006/01/04 13:21:51 $ * by : $Author: bpoussin $ */ @@ -34,8 +34,9 @@ import java.util.List; import java.util.Map; -import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaException; +import org.codelutin.topia.event.TopiaEntityListener; +import org.codelutin.topia.framework.TopiaContextImplementor; /** * @author poussin @@ -45,19 +46,30 @@ public interface TopiaDAO { /** - * When TopiaContext create the TopiaDAOHibernate, it must call this method just + * When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just * after * * @param entityClass */ - public void init(TopiaContext context, Class entityClass) throws TopiaException; + public void init(TopiaContextImplementor context, Class entityClass) throws TopiaException; /** * @return Returns the context. */ - public abstract TopiaContext getContext(); + public abstract TopiaContextImplementor getContext(); /** + * Adds a new TopiaEntityListener to the subscribers list. + * @param l - the TopiaEntityListener to add to the subscribers list. + */ + public void addTopiaEntityListener(TopiaEntityListener l); + + /** + * Removes a TopiaEntityListener from the subscribers list. + * @param l - the TopiaEntityListener to remove from the subscribers. + */ + public void removeTopiaEntityListener(TopiaEntityListener l); + /** * appelé lorsque le context a eu un commit de fait * TODO il faudrait peut-etre plutot faire un commit a deux phase * car plusieurs type de persistence peuvent etre melangé, et il Index: topia2/src/java/org/codelutin/topia/persistence/TopiaDAOAbstract.java diff -u topia2/src/java/org/codelutin/topia/persistence/TopiaDAOAbstract.java:1.1.1.1 topia2/src/java/org/codelutin/topia/persistence/TopiaDAOAbstract.java:1.2 --- topia2/src/java/org/codelutin/topia/persistence/TopiaDAOAbstract.java:1.1.1.1 Mon Jan 2 13:54:35 2006 +++ topia2/src/java/org/codelutin/topia/persistence/TopiaDAOAbstract.java Wed Jan 4 13:21:51 2006 @@ -23,9 +23,9 @@ * Created: 31 déc. 2005 13:10:34 * * @author poussin - * @version $Revision: 1.1.1.1 $ + * @version $Revision: 1.2 $ * - * Last update: $Date: 2006/01/02 13:54:35 $ + * Last update: $Date: 2006/01/04 13:21:51 $ * by : $Author: bpoussin $ */ @@ -43,8 +43,9 @@ import org.apache.commons.lang.ObjectUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaException; +import org.codelutin.topia.event.TopiaEntityListener; +import org.codelutin.topia.framework.TopiaContextImplementor; import org.codelutin.topia.persistence.hibernate.TopiaDAOHibernate; import org.hibernate.HibernateException; import org.hibernate.metadata.ClassMetadata; @@ -72,15 +73,15 @@ protected Class entityClass = null; - protected TopiaContext context = null; + protected TopiaContextImplementor context = null; /** - * When TopiaContext create the TopiaDAOHibernate, it must call this method just + * When TopiaContextImpl create the TopiaDAOHibernate, it must call this method just * after * * @param entityClass */ - public void init(TopiaContext context, Class entityClass) throws TopiaException { + public void init(TopiaContextImplementor context, Class entityClass) throws TopiaException { log.debug("init dao for " + entityClass.getName()); this.context = context; this.entityClass = entityClass; @@ -89,7 +90,7 @@ /* (non-Javadoc) * @see org.codelutin.topia.TopiaDAO#getContext() */ - public TopiaContext getContext() { + public TopiaContextImplementor getContext() { return context; } @@ -128,6 +129,15 @@ return result; } + public void addTopiaEntityListener(TopiaEntityListener l) { + getContext().getListeners().add(entityClass, l); + } + + public void removeTopiaEntityListener(TopiaEntityListener l) { + getContext().getListeners().remove(entityClass, l); + } + + /** * Par defaut ne fait rien */ Index: topia2/src/java/org/codelutin/topia/persistence/TopiaDAODelegator.java diff -u topia2/src/java/org/codelutin/topia/persistence/TopiaDAODelegator.java:1.1.1.1 topia2/src/java/org/codelutin/topia/persistence/TopiaDAODelegator.java:1.2 --- topia2/src/java/org/codelutin/topia/persistence/TopiaDAODelegator.java:1.1.1.1 Mon Jan 2 13:54:35 2006 +++ topia2/src/java/org/codelutin/topia/persistence/TopiaDAODelegator.java Wed Jan 4 13:21:51 2006 @@ -23,9 +23,9 @@ * Created: 30 déc. 2005 22:28:48 * * @author poussin - * @version $Revision: 1.1.1.1 $ + * @version $Revision: 1.2 $ * - * Last update: $Date: 2006/01/02 13:54:35 $ + * Last update: $Date: 2006/01/04 13:21:51 $ * by : $Author: bpoussin $ */ @@ -34,8 +34,9 @@ import java.util.List; import java.util.Map; -import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaException; +import org.codelutin.topia.event.TopiaEntityListener; +import org.codelutin.topia.framework.TopiaContextImplementor; /** @@ -72,19 +73,27 @@ } /* (non-Javadoc) - * @see org.codelutin.topia.TopiaDAO#init(org.codelutin.topia.TopiaContext, java.lang.Class) + * @see org.codelutin.topia.TopiaDAO#init(org.codelutin.topia.TopiaContextImpl, java.lang.Class) */ - public void init(TopiaContext context, Class entityClass) throws TopiaException { + public void init(TopiaContextImplementor context, Class entityClass) throws TopiaException { // rien a faire cette methode a ete appele sur le parentDAO } /* (non-Javadoc) * @see org.codelutin.topia.TopiaDAO#getContext() */ - public TopiaContext getContext() { + public TopiaContextImplementor getContext() { return getParentDAO().getContext(); } + public void addTopiaEntityListener(TopiaEntityListener l) { + getParentDAO().addTopiaEntityListener(l); + } + + public void removeTopiaEntityListener(TopiaEntityListener l) { + getParentDAO().removeTopiaEntityListener(l); + } + public void commitTransaction() throws TopiaException { getParentDAO().commitTransaction(); }