Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.38 topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.39 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java:1.38 Mon Oct 16 15:20:55 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImpl.java Mon Oct 16 15:38:20 2006 @@ -23,9 +23,9 @@ * * @author poussin * - * @version $Revision: 1.38 $ + * @version $Revision: 1.39 $ * - * Last update: $Date: 2006/10/16 15:20:55 $ by : $Author: ruchaud $ + * Last update: $Date: 2006/10/16 15:38:20 $ by : $Author: bpoussin $ */ package org.codelutin.topia.framework; @@ -61,9 +61,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codelutin.topia.IndexEnginService; +import org.codelutin.topia.TopiaIndexService; import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaHistoryService; import org.codelutin.topia.TopiaNotFoundException; import org.codelutin.topia.TopiaVetoException; import org.codelutin.topia.event.TopiaEntityEvent; @@ -78,6 +79,7 @@ import org.codelutin.topia.event.TopiaVetoableEntityLoadEvent; import org.codelutin.topia.event.TopiaVetoableEntityLoadListener; import org.codelutin.topia.index.IndexEnginImplementor; +import org.codelutin.topia.index.NotIndexable; import org.codelutin.topia.persistence.TopiaDAO; import org.codelutin.topia.persistence.TopiaDAODelegator; import org.codelutin.topia.persistence.TopiaEntity; @@ -137,8 +139,11 @@ * topia.persistence.classes pour d'autres classes * * - * @author poussin + * @see TopiaSecurityManager + * @see TopiaIndexService + * @see TopiaHistoryService * + * @author poussin */ public class TopiaContextImpl implements TopiaContext, TopiaContextImplementor { @@ -155,6 +160,8 @@ static final private String TOPIA_INDEX_ENGIN = "topia.index.engin"; + static final private String TOPIA_HISTORY = "topia.history"; + /** * Le pere de ce context, les contexts initaux n'ont pas de context pere */ @@ -211,6 +218,7 @@ protected IndexEnginImplementor indexEngin = null; + protected TopiaHistoryService historyService = null; /** * Manager pour la sécurité */ @@ -225,6 +233,7 @@ this.config = config; initSecurity(); initIndexEngin(); + initHistory(); } /** @@ -1340,9 +1349,10 @@ .getSession()); if (context != null) { Object id = event.getId(); + Object entity = event.getEntity(); context.fireOnUpdated(event.getPersister().getMappedClass( - EntityMode.POJO), id, event.getEntity()); - if (context.isIndexEnabled()) { + EntityMode.POJO), id, entity); + if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) { context.getIndexEnginImplementor().recordForIndexation(id, event.getState()); } } @@ -1358,9 +1368,10 @@ .getSession()); if (context != null) { Object id = event.getId(); + Object entity = event.getEntity(); context.fireOnDeleted(event.getPersister().getMappedClass( - EntityMode.POJO), id, event.getEntity()); - if (context.isIndexEnabled()) { + EntityMode.POJO), id, entity); + if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) { context.getIndexEnginImplementor().recordForIndexation(id, null); } } @@ -1371,6 +1382,45 @@ * Initialise le TopiaSecurityManager en fonction des * propriétés du context. Si le type n'est pas connu, la variable reste à * null. + */ + protected void initHistory() { + Properties props = getConfig(); + historyService = null; + if (props != null) { + String classHistory = props.getProperty(TOPIA_HISTORY); + try { + Class forName = Class.forName(classHistory); + Object newInstance = forName.newInstance(); + historyService = (TopiaHistoryService) newInstance; + historyService.init(this); + } catch (Throwable eee) { + if(log.isErrorEnabled()) { + log.error("HistoryService inconnu : " + classHistory); + } + if(log.isDebugEnabled()) { + log.debug(eee); + } + } + } + } + + public boolean isHistoryEnabled() { + return getHistoryService() != null; + } + + public TopiaHistoryService getHistoryService() { + TopiaContextImplementor parent = getParentContext(); + if(parent != null) { + return parent.getHistoryService(); + } else { + return historyService; + } + } + + /** + * Initialise le TopiaSecurityManager en fonction des + * propriétés du context. Si le type n'est pas connu, la variable reste à + * null. */ protected void initIndexEngin() { Properties props = getConfig(); @@ -1394,11 +1444,11 @@ } public boolean isIndexEnabled() { - return getIndexEngin() != null; + return getIndexService() != null; } - public IndexEnginService getIndexEngin() { - IndexEnginService result = getIndexEnginImplementor(); + public TopiaIndexService getIndexService() { + TopiaIndexService result = getIndexEnginImplementor(); return result; } Index: topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java diff -u topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.12 topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.13 --- topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java:1.12 Fri Oct 13 12:20:00 2006 +++ topia2/src/java/org/codelutin/topia/framework/TopiaContextImplementor.java Mon Oct 16 15:38:20 2006 @@ -23,9 +23,9 @@ * Created: 3 janv. 2006 21:27:24 * * @author poussin - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * - * Last update: $Date: 2006/10/13 12:20:00 $ + * Last update: $Date: 2006/10/16 15:38:20 $ * by : $Author: bpoussin $ */ @@ -34,7 +34,7 @@ import java.util.Properties; import java.util.Set; -import org.codelutin.topia.IndexEnginService; +import org.codelutin.topia.TopiaIndexService; import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaException; import org.codelutin.topia.TopiaNotFoundException;