Index: topia/src/java/org/codelutin/topia/AsynchronousLoader.java diff -u /dev/null topia/src/java/org/codelutin/topia/AsynchronousLoader.java:1.3 --- /dev/null Wed Jul 20 12:49:57 2005 +++ topia/src/java/org/codelutin/topia/AsynchronousLoader.java Wed Jul 20 12:49:52 2005 @@ -0,0 +1,52 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * 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. + *##%*/ + +/* * + * AsynchronousLoader.java + * + * Created: Sep 1, 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.3 $ + * + * Last update : $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia; + +import java.util.Set; + + +/** + * + */ +public interface AsynchronousLoader extends Runnable { + + public abstract void addListener(AsynchronousLoaderListener listener); + + public abstract void removeListener(AsynchronousLoaderListener listener); + + public abstract Set getListeners(); + + public abstract int size(); + + public abstract Object getObjectAt(int index); + +} \ No newline at end of file Index: topia/src/java/org/codelutin/topia/AsynchronousLoaderEvent.java diff -u /dev/null topia/src/java/org/codelutin/topia/AsynchronousLoaderEvent.java:1.3 --- /dev/null Wed Jul 20 12:49:57 2005 +++ topia/src/java/org/codelutin/topia/AsynchronousLoaderEvent.java Wed Jul 20 12:49:52 2005 @@ -0,0 +1,103 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * 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. + *##%*/ + +/* * + * AsynchronousLoaderEvent.java + * + * Created: Sep 1, 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.3 $ + * + * Last update : $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia; + +import java.util.Date; + +/** + * + */ +public class AsynchronousLoaderEvent { + + public static int SIZE_IS_AVAILABLE = 0; + + public static int OBJECTS_LOADED = 1; + + protected AsynchronousLoader loader = null; + + protected int type = 0; + + protected int startIndex = 0; + + protected int endIndex = 0; + + protected Date date = null; + + public AsynchronousLoaderEvent(AsynchronousLoader loader, int type) { + this(loader, type, 0, 0); + } + + public AsynchronousLoaderEvent(AsynchronousLoader loader, int type, + int startIndex, int endIndex) { + this.loader = loader; + this.type = type; + this.startIndex = startIndex; + this.endIndex = endIndex; + date = new Date(System.currentTimeMillis()); + } + + /** + * @return Returns the loader. + */ + public AsynchronousLoader getLoader() { + return loader; + } + + /** + * @return Returns the endIndex. + */ + public int getEndIndex() { + return endIndex; + } + + /** + * @return Returns the startIndex. + */ + public int getStartIndex() { + return startIndex; + } + + /** + * @return Returns the type. + */ + public int getType() { + return type; + } + + /** + * Le moment ou l'event a ete créé. + */ + public Date getCreationDate() { + return date; + } + +} \ No newline at end of file Index: topia/src/java/org/codelutin/topia/AsynchronousLoaderListener.java diff -u /dev/null topia/src/java/org/codelutin/topia/AsynchronousLoaderListener.java:1.3 --- /dev/null Wed Jul 20 12:49:57 2005 +++ topia/src/java/org/codelutin/topia/AsynchronousLoaderListener.java Wed Jul 20 12:49:52 2005 @@ -0,0 +1,46 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * 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. + *##%*/ + +/* * + * AsynchronousLoaderListener.java + * + * Created: Aug 31, 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.3 $ + * + * Last update : $Date: 2005/07/20 12:49:52 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.topia; + +import java.util.EventListener; + +/** + * + */ +public interface AsynchronousLoaderListener extends EventListener { + + /** + * Appelé lorsque de nouvelles données ont été chargées + */ + public void dataLoaded(AsynchronousLoaderEvent event); + +} Index: topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java diff -u topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.7 topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.8 --- topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.7 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * - * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -35,7 +35,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -public abstract class AbstractTopiaPersistenceService extends AbstractTopiaService implements TopiaPersistenceService { // AbstractTopiaPersistenceService +public abstract class AbstractTopiaPersistenceService extends AbstractTopiaService implements TopiaPersistenceService { // AbstractTopiaPersistenceService /** to use log facility, just put in your code: log.info(\"...\"); */ static private Logger log = Logger.getLogger("org.codelutin.topia.AbstractTopiaPersistenceService"); @@ -117,7 +117,7 @@ * @return a List containing all TopiaEntity related to this CRUD according to the given TopiaQuery. */ public List find(TopiaQuery query) throws TopiaException{ - return getContext().getPersistenceHelper().find(normalizeQuery(query)); + return (List)getContext().getPersistenceHelper().find(normalizeQuery(query)); } /** Index: topia/src/java/org/codelutin/topia/ContextHelper.java diff -u topia/src/java/org/codelutin/topia/ContextHelper.java:1.3 topia/src/java/org/codelutin/topia/ContextHelper.java:1.4 --- topia/src/java/org/codelutin/topia/ContextHelper.java:1.3 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/ContextHelper.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -48,7 +48,7 @@ protected TopiaContext context = null; protected Properties properties = null; - protected HashMap singleton = new HashMap(); + protected HashMap singletonCache = new HashMap(); public ContextHelper(TopiaContext context, Properties properties){ this.context = context; @@ -95,7 +95,7 @@ // load properties for helper String propertiesFilename = properties.getProperty(propertyId+".properties"); - Properties properties = new Properties(this.properties); + properties = new Properties(properties); if (propertiesFilename != null && !propertiesFilename.equals("")) { try { URL propURL = Resource.getURL(propertiesFilename); @@ -118,12 +118,12 @@ if(singleton){ // on ajoute dans les properties la class pour discreminer les singletons properties.put(className, className); - result = singleton.get(properties); + result = singletonCache.get(properties); if(result == null){ Constructor constructor = mappedClass.getDeclaredConstructor(new Class[] {Properties.class}); constructor.setAccessible(true); result = constructor.newInstance(new Object[] {properties}); - singleton.put(properties, result); + singletonCache.put(properties, result); } } else { Constructor constructor = mappedClass.getDeclaredConstructor(new Class[] {TopiaContext.class, Properties.class}); Index: topia/src/java/org/codelutin/topia/DefaultEntitiesHelper.java diff -u topia/src/java/org/codelutin/topia/DefaultEntitiesHelper.java:1.2 topia/src/java/org/codelutin/topia/DefaultEntitiesHelper.java:1.3 --- topia/src/java/org/codelutin/topia/DefaultEntitiesHelper.java:1.2 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/DefaultEntitiesHelper.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * Created: 6 juillet 2005 16:34:59 CEST * * @author Benjamin POUSSIN - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Last update: $Date: 2005/07/19 13:15:13 $ + * Last update: $Date: 2005/07/20 12:49:52 $ * by : $Author: bpoussin $ */ @@ -36,7 +36,7 @@ import java.util.Properties; import org.apache.commons.lang.ObjectUtils; -public class DefaultEntitiesHelper { // DefaultEntitiesHelper +public class DefaultEntitiesHelper implements EntitiesHelper { // DefaultEntitiesHelper /** to use log facility, just put in your code: log.info(\"...\"); */ static private Logger log = Logger.getLogger("org.codelutin.topia.DefaultEntitiesHelper"); Index: topia/src/java/org/codelutin/topia/TopiaContext.java diff -u topia/src/java/org/codelutin/topia/TopiaContext.java:1.38 topia/src/java/org/codelutin/topia/TopiaContext.java:1.39 --- topia/src/java/org/codelutin/topia/TopiaContext.java:1.38 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/TopiaContext.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.38 $ +* @version $Revision: 1.39 $ * -* Mise a jour: $Date: 2005/07/19 13:15:13 $ +* Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -49,13 +49,15 @@ import org.codelutin.topia.distribution.DistributionHelper; import org.codelutin.topia.hook.HookHelper; import org.codelutin.topia.persistence.PersistenceHelper; -import org.codelutin.topia.security.TopiaAccessController; -import org.codelutin.topia.security.TopiaGroupPrincipal; -import org.codelutin.topia.security.TopiaPermission; -import org.codelutin.topia.security.TopiaPermissionEvent; -import org.codelutin.topia.security.TopiaPermissionListener; -import org.codelutin.topia.security.TopiaSecurityException; -import org.codelutin.topia.security.TopiaUserPrincipal; +import org.codelutin.topia.security.TopiaSecurityHelper; +// import org.codelutin.topia.security.TopiaGroupPrincipal; +// import org.codelutin.topia.security.TopiaPermission; +// import org.codelutin.topia.security.TopiaPermissionEvent; +// import org.codelutin.topia.security.TopiaPermissionListener; +// import org.codelutin.topia.security.TopiaSecurityException; +// import org.codelutin.topia.security.TopiaUserPrincipal; +import org.codelutin.topia.persistence.TransactionHelper; +import org.codelutin.topia.persistence.TopiaTransaction; import org.codelutin.util.CategorisedListenerSet; import org.codelutin.util.HashMapMultiKey; import org.codelutin.util.ListenerSet; @@ -86,13 +88,10 @@ protected CategorisedListenerSet listeners = new CategorisedListenerSet( TopiaEntityListener.class); - protected ListenerSet permissionListeners = new ListenerSet( - TopiaPermissionListener.class); - /** Toutes les propriétés qui permette de paramètrer le context */ protected Properties properties = null; - protected HashMap cacheService = new HashMap(); + protected HashMap cacheService = new HashMap(); /** * Constructeur du context. Il est protégé car les contexts doivent-être @@ -111,6 +110,10 @@ this.parentContext = parentContext; } + public Properties getProperties(){ + return properties; + } + /** * Retourne tous les listeners */ @@ -134,13 +137,15 @@ getListeners().remove(this, l); } + abstract protected TopiaContextChild createChild(); + public TopiaContextChild beginTransaction() throws TopiaException { - TopiaContextChild result = new TopiaContextChild(this); + TopiaContextChild result = createChild(); TopiaTransaction tt = null; if(getTransaction() == null){ tt = getTransactionHelper().newTranstaction(); } else { - tt = getTransaction().newSubTranstaction(); + tt = getTransaction().newSubTransaction(); } result.setTransaction(tt); result.getPersistenceHelper().beginTransaction(); @@ -231,12 +236,12 @@ // if can't find mapping, try with default dist class clazz = Util.getClazz(serviceInterfacez.getName() + "Impl"); } - result = contextHelper.getInstance(clazz); + result = (A)contextHelper.getInstance(clazz); } else { - result = getDistributionHelper().createProxy(serviceInterfacez); + result = (A)getDistributionHelper().createProxy(serviceInterfacez); } - result = getHookHelper().addHookSupport(result, + result = (A)getHookHelper().addHookSupport(result, new Class[] { serviceInterfacez }); if (result instanceof TopiaPersistenceService) { @@ -244,7 +249,7 @@ } cacheService.put(serviceInterfacez, result); } - return (TopiaService) result; + return result; } /** @@ -285,21 +290,21 @@ return hookHelper; } - public TopiaSecurityHelper getSecurityHelper(){ + public TopiaSecurityHelper getSecurityHelper() throws TopiaNotFoundException { if(securityHelper == null){ securityHelper = (TopiaSecurityHelper)contextHelper.getHelper(TopiaConst.HELPER_SECURITY); } return securityHelper; } - public TransactionHelper getTransactionHelper(){ + public TransactionHelper getTransactionHelper() throws TopiaNotFoundException { if(transactionHelper == null){ transactionHelper = (TransactionHelper)contextHelper.getHelperSingleton(TopiaConst.HELPER_TRANSACTION); } return transactionHelper; } - public EntitiesHelper getEntitiesHelper(){ + public EntitiesHelper getEntitiesHelper() throws TopiaNotFoundException { if(entitiesHelper == null){ entitiesHelper = (EntitiesHelper)contextHelper.getHelper(TopiaConst.HELPER_ENTIIES); if(entitiesHelper == null){ Index: topia/src/java/org/codelutin/topia/TopiaContextFactory.java diff -u topia/src/java/org/codelutin/topia/TopiaContextFactory.java:1.7 topia/src/java/org/codelutin/topia/TopiaContextFactory.java:1.8 --- topia/src/java/org/codelutin/topia/TopiaContextFactory.java:1.7 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/TopiaContextFactory.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * - * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -139,7 +139,7 @@ Level.FINEST, "Class used for context is " + contextClassName); try { contextClass = Class.forName(contextClassName); - context = createContext(contextClassName, properties); + context = createContext(contextClass, properties); } catch (Exception eee) { throw new TopiaNotFoundException( "TopiaContext can't be instanciated: " + contextClassName @@ -154,7 +154,7 @@ Constructor constructor = contextClass.getDeclaredConstructor( Properties.class); constructor.setAccessible(true); - A context = constructor.newInstance(properties); + A context = (A)constructor.newInstance(properties); return context; } Index: topia/src/java/org/codelutin/topia/TopiaEntityEvent.java diff -u topia/src/java/org/codelutin/topia/TopiaEntityEvent.java:1.2 topia/src/java/org/codelutin/topia/TopiaEntityEvent.java:1.3 --- topia/src/java/org/codelutin/topia/TopiaEntityEvent.java:1.2 Wed Jun 30 13:40:36 2004 +++ topia/src/java/org/codelutin/topia/TopiaEntityEvent.java Wed Jul 20 12:49:52 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Mise a jour: $Date: 2004/06/30 13:40:36 $ - * par : $Author: pineau $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ + * par : $Author: bpoussin $ */ package org.codelutin.topia; @@ -40,7 +40,7 @@ public class TopiaEntityEvent extends EventObject { // TopiaEntityEvent protected long date = 0; - protected List entities = null; + protected List entities = null; /** * @param source l'objet d'ou provient l'event Index: topia/src/java/org/codelutin/topia/TopiaPersistenceService.java diff -u topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.9 topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.10 --- topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.9 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/TopiaPersistenceService.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -37,7 +37,7 @@ * Common interface to all CRUD services (CRUD stands for Creation, Research, Update and Deletion) * Note : Implementation class are required to have a public empty constructor. */ -public interface TopiaPersistenceService extends TopiaService { +public interface TopiaPersistenceService extends TopiaService { /** * Adds a new TopiaEntityListener to the subscribers list. @@ -64,7 +64,6 @@ * @param topiaEntity - the TopiaEntity to persist. * * @return the persistent TopiaEntity. - * @deprecated create method make the entity persistence directly now */ public Entity makePersistent(Entity topiaEntity) throws TopiaException; Index: topia/src/java/org/codelutin/topia/Util.java diff -u topia/src/java/org/codelutin/topia/Util.java:1.13 topia/src/java/org/codelutin/topia/Util.java:1.14 --- topia/src/java/org/codelutin/topia/Util.java:1.13 Tue Jul 19 13:15:13 2005 +++ topia/src/java/org/codelutin/topia/Util.java Wed Jul 20 12:49:52 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * - * Mise a jour: $Date: 2005/07/19 13:15:13 $ + * Mise a jour: $Date: 2005/07/20 12:49:52 $ * par : $Author: bpoussin $ */ @@ -95,7 +95,7 @@ } public static A getInstance(Class clazz, Object [] args) throws TopiaNotFoundException{ - Object result = null; + A result = null; try{ Expression e = new Expression(clazz, "new", args); result = (A)e.getValue();